- Add proper type annotations to all source files - Fix return types for numpy operations (np.asarray with dtype=np.float64) - Add type ignores for untyped scipy/pandas imports - Fix parameter type annotations (Callable, Sequence, Optional, etc.) - Add TYPE_CHECKING imports for forward references - Fix fitter.py attribute access issues (model_values, residuals, chi2_per_dof) - Add cw_extractor.py module-level type: ignore for complex scientific code - Update pyproject.toml to exclude notebooks from mypy - Run black and ruff for formatting and linting
26 KiB
26 KiB
In [ ]:
import paceENSDF as pe
e = pe.ENSDF()
cdata = e.load_pace()In [ ]:
import matplotlib.pyplot as plt
import numpy as np
%matplotlib notebookIn [ ]:
# Find all coincidence data sets from beta-minus decay
bm_coinc = e.coinc_pairs(cdata, "BM")
[print(k,v) for (k,v) in bm_coinc.items()][0]In [ ]:
# Find all coincidence data sets from alpha decay
a_coinc = e.coinc_pairs(cdata, "A")
[print(k,v) for (k,v) in a_coinc.items()][0]In [ ]:
# Find all coincidence data sets from electron-capture/beta-plus decay
ecbp_coinc = e.coinc_pairs(cdata, "ECBP")
[print(k,v) for (k,v) in ecbp_coinc.items()][0]In [ ]:
# Gather the Z, A information from each decay-mode dictionary
# Alpha decay
Z_A = [k[1] for (k,v) in a_coinc.items()]
A_A = [k[2] for (k,v) in a_coinc.items()]
# Beta-minus decay
Z_BM = [k[1] for (k,v) in bm_coinc.items()]
A_BM = [k[2] for (k,v) in bm_coinc.items()]
# Electron-capture/beta-plus decay
Z_ECBP = [k[1] for (k,v) in ecbp_coinc.items()]
A_ECBP = [k[2] for (k,v) in ecbp_coinc.items()]In [ ]:
%matplotlib notebook
fig, ax = plt.subplots(figsize=(9,6))
ax.scatter(np.array(A_A), np.array(Z_A), color='y', marker='s', alpha=0.5, label=r'$\alpha$')
ax.scatter(np.array(A_BM), np.array(Z_BM), color='r', marker='s', alpha=0.10, label=r'$\beta^{-}$')
ax.scatter(np.array(A_ECBP), np.array(Z_ECBP), color='b', marker='s', alpha=0.10, label=r'$\epsilon/\beta^{+}$')
ax.set_xlabel(r'$A$', size=20)
ax.set_ylabel(r'$Z$', size=20)
ax.tick_params(axis='both', which='major', labelsize=15)
ax.legend(loc='best', fontsize=20)
plt.tight_layout()
plt.savefig("coinc_decay_nuclides.png", dpi=fig.dpi)
plt.show()In [ ]:
help(e.get_gamma_singles)In [ ]:
# Define parent and decay mode
parent_nucleus = "Np239"
decay_mode = "BM"
decay_index = 0
decay_pairs = e.coinc_pairs(cdata, decay_mode)
daughter_nucleus = [v[0] for k,v in decay_pairs.items() if (k[0]==parent_nucleus and k[3]==decay_index)][0]
print("Daughter nucleus: {0}".format(daughter_nucleus))In [ ]:
# Get the absolute total-projection singles gamma data for 239Pu following the g.s. beta-minus decay of 239Np
#g = e.get_gamma_singles(cdata, "BM", "Np239", 0)
g = e.get_gamma_singles(cdata, decay_mode, parent_nucleus, decay_index)
for data in g: print(data)
# Put gamma data into arrays
gamma_array = np.array(g)
gamma_energy = gamma_array[:,0]
gamma_intensity = gamma_array[:,5]In [ ]:
# Plot gamma data
%matplotlib notebook
fig, ax = plt.subplots(figsize=(9,6))
ax.bar(gamma_energy, gamma_intensity, width=3, color='k', label=r'%s $\gamma$ singles'%daughter_nucleus)
ax.legend(loc='best', fontsize=15)
ax.set_yscale('log')
ax.set_xlabel(r'$E_{\gamma}$ [keV]', size=20)
ax.set_ylabel(r'$I_{\gamma}$', size=20)
plt.grid()
plt.tight_layout()In [ ]:
# Get all g-g coincidences in daughter following radioactive decay
gg=e.get_gg(cdata, decay_mode, parent_nucleus, decay_index)
for coinc in gg: print(coinc)In [ ]:
# Define indices for gating transition
E_i = 8
E_f = 5In [ ]:
# Now get all g-g coincidences with the 8->5 transition in 239Pu following the g.s. beta-minus decay of 239Np
cg=e.get_gg(cdata, decay_mode, parent_nucleus, decay_index, E_i, E_f)
cgate = cg[0][0]
for coinc in cg:
print(coinc)
coinc_array = np.array(cg)
coinc_gamma = coinc_array[:,1]
coinc_intensity = coinc_array[:,10]In [ ]:
# Plot coincidence gamma data imposed on singles gamma data
%matplotlib notebook
fig, ax = plt.subplots(figsize=(9,6))
ax.bar(gamma_energy, gamma_intensity, width=3, color='k', label=r'%s $\gamma$ singles'%daughter_nucleus)
ax.bar(coinc_gamma, coinc_intensity, width=3, color='r', label=r'%s %s-keV coincidences'%(daughter_nucleus,cgate))
ax.legend(loc='best', fontsize=15)
ax.set_yscale('log')
ax.set_xlabel(r'$E_{\gamma}$ [keV]', size=20)
ax.set_ylabel(r'$I_{\gamma}$', size=20)
plt.grid()
#plt.tight_layout()In [ ]:
# Find all isotopes containing gamma rays at 1332 keV (+/- 0.5 keV; default tolerance range)
e.find_gamma(cdata, 1332)In [ ]:
# Tune the tolerance to narrow the search range to 1332 +/- 0.2 keV
e.find_gamma(cdata, 1332, 0.2)In [ ]:
# Find all isotopes containing a coincidence pair of gamma rays
# at 106 keV and 392 keV (default tolerance=0.5 keV)
e.find_gamma_coinc(cdata, 106, 392)In [ ]:
# Tune the tolerance to expand the search window to +/- 2.0 keV
e.find_gamma_coinc(cdata, 106, 392, 2.0)In [ ]:
# Get the absolute total-projection singles X-ray data for 239Pu following the g.s. beta-minus decay of 239Np
#x=e.get_xray_singles(cdata, "BM", "Np239", 0)
x=e.get_xray_singles(cdata, decay_mode, parent_nucleus, decay_index)
for xray in x: print(xray)
xray_array = np.array(x)
xray_energy = xray_array[:,0]
xray_intensity = xray_array[:,1]In [ ]:
# Plot gamma and X-ray data
%matplotlib notebook
fig, ax = plt.subplots(figsize=(9,6))
ax.bar(gamma_energy, gamma_intensity, width=3, color='k', label=r'%s decay $\gamma$ singles'%daughter_nucleus)
ax.bar(xray_energy, xray_intensity, width=3, color='b', label=r'%s $X$-rays'%daughter_nucleus)
ax.legend(loc='best', fontsize=15)
ax.set_yscale('log')
ax.set_xlabel(r'$E$ [keV]', size=20)
ax.set_ylabel(r'$I$', size=20)
plt.grid()
plt.tight_layout()In [ ]:
# Get the individual contributions to the X-ray yield from transitions in 239Pu following the g.s. beta-minus
# decay of 239Np
e.get_xray_contribution(cdata, decay_mode, parent_nucleus, decay_index)In [ ]:
# Get all g-X coincidences in 239Pu following the ground-state beta-minus decay of 239Np
xx=e.get_gx(cdata, decay_mode, parent_nucleus, decay_index)
for coinc in xx: print(coinc)In [ ]:
# Now get all g-X coincidences with the 8->5 transition in 239Pu following the g.s. beta-minus decay of 239Np
cx=e.get_gx(cdata, decay_mode, parent_nucleus, decay_index, E_i, E_f)
for coinc in cx: print(coinc)
coincgx_array = np.array(cx)
coincgx_energy = coincgx_array[:,3].astype(float)
coincgx_intensity = coincgx_array[:,5].astype(float)In [ ]:
# Plot coincidence gamma and X-ray imposed upon singles gamma and X-ray data
%matplotlib notebook
fig, ax = plt.subplots(figsize=(9,6))
ax.bar(gamma_energy, gamma_intensity, width=3, color='k', label=r'%s decay $\gamma$'%daughter_nucleus)
ax.bar(xray_energy, xray_intensity, width=3, color='b', label=r'%s $X$-rays'%daughter_nucleus)
ax.bar(coinc_gamma, coinc_intensity, width=3, color='r', label=r'%s $\gamma$/%s-keV coincidences'%(daughter_nucleus, cgate))
ax.bar(coincgx_energy, coincgx_intensity, width=3, color='yellow', label=r'%s $X$/%s-keV coincidences'%(daughter_nucleus, cgate))
ax.legend(loc='best', fontsize=15)
ax.set_yscale('log')
ax.set_xlabel(r'$E$ [keV]', size=20)
ax.set_ylabel(r'$I$', size=20)
plt.grid()
plt.tight_layout()In [ ]:
# Find all isotopes containing X rays at 52 keV (+/- 0.5 keV; default tolerance range)
e.find_xray(cdata, 52)In [ ]:
# Tune the tolerance to narrow the search range to 52 +/- 0.1 keV
e.find_xray(cdata, 52, 0.1)In [ ]:
# Find all isotopes containing a gamma-X-ray coincidence pair with a 52-keV X ray and 688-keV gamma,
# respectively, assuming the default tolerance=0.5 keV
e.find_xray_coinc(cdata, 52, 688)In [ ]:
# Tune the tolerance to narrow the search window to +/- 0.15 keV
e.find_xray_coinc(cdata, 52, 688, 0.15)In [ ]:
# Show the cascade gamma-ray sequence between the 3->2 and 1->0 transitions in 60Ni following
# 60Co beta-minus decay (G.S.)
e.show_cascades(cdata,"BM","Co60",0,3,2,1,0)In [ ]:
# Show the cascade gamma-ray sequence between the 9->6 and 1->0 transitions in 147Pm following
# 147Nd beta-minus decay (G.S.)
e.show_cascades(cdata,"BM","Nd147",0,9,6,1,0)In [ ]:
# Inspecting transient-equilibrium coincidences following 99Mo beta-minus decay.
# To remove coincidences that go through the 6-h isomer at E=142.7-keV (level index=2) impose a 21600-s timecut:
gg=e.get_gg_timecut(cdata, "BM", "Mo99", 0, -21600)
for g in gg: print(g[0:12])
print("\nNumber of coincidences = {0}".format(len(gg)))In [ ]:
# Find only coincidences with the 1->0 transition (140.51-keV -> 0-keV) with the same timecut:
gg=e.get_gg_timecut(cdata, "BM", "Mo99", 0, 1, 0, -21600)
for g in gg: print(g[0:12])
print("\nNumber of coincidences = {0}".format(len(gg)))In [ ]:
# Find coincidences in the path of the 6-h isomer:
gg=e.get_gg_timecut(cdata, "BM", "Mo99", 0, 21600)
for g in gg: print(g[0:12])
print("\nNumber of coincidences = {0}".format(len(gg)))In [ ]:
# Find only coincidences with the 1->0 transition (140.51-keV -> 0-keV) in the path of the 6-h isomer:
gg=e.get_gg_timecut(cdata, "BM", "Mo99", 0, 1, 0, 21600)
for g in gg: print(g[0:12])
print("\nNumber of coincidences = {0}".format(len(gg)))In [ ]:
# Compare these results with all expected coincidences (i.e. no timecut):
gg=e.get_gg(cdata, "BM", "Mo99", 0)
for g in gg: print(g)
print("\nNumber of coincidences = {0}".format(len(gg)))In [ ]:
# Compare these results with all expected coincidences with just the 1->0 transition (i.e. no timecut):
gg=e.get_gg(cdata, "BM", "Mo99", 0, 1, 0)
for g in gg: print(g)
print("\nNumber of coincidences = {0}".format(len(gg)))In [ ]:
# Get the valence electronic configuration of Yb (pass the chemical symbol <str>)
e.get_valence_config(cdata, "Yb")In [ ]:
# Get the valence electronic configuration of Yb (pass the atomic number <int>)
e.get_valence_config(cdata, 70)In [ ]:
# Get the valence electronic configuration of Fe (pass the chemical symbol <str>)
e.get_valence_config(cdata, "Fe")In [ ]:
# Get the valence electronic configuration of Fe (pass the atomic number <int>)
e.get_valence_config(cdata, 26)In [ ]:
# Get the K-shell binding energy for W:
e.get_binding_energies(cdata, "W", shell='K')In [ ]:
# Get the L-shell binding energies for W:
e.get_binding_energies(cdata, "W", shell='L')In [ ]:
# Get the M-shell binding energies for W:
e.get_binding_energies(cdata, "W", shell='M')In [ ]:
# Get all available atomic-shell binding energies for Yb:
e.get_binding_energies(cdata, 74, shell='ALL')In [ ]: