Commit 129e49cd authored by Erik Asbjørn Mikkelsen Jensen's avatar Erik Asbjørn Mikkelsen Jensen
Browse files

tidied up a few things

parent adc705a8
......@@ -2,17 +2,55 @@ import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
import matplotlib.patheffects as pe
mpl.style.use('seaborn-colorblind')
# IMPORT DATA
n, Z, N, QEC, QB, Qa, QECp, QBn, QEC2p, QB2n, QECa, QBa, QECp_est, QBn_est, QEC2p_est, \
QB2n_est, QECa_est, QBa_est, half_life, half_life_est, half_life_stbl = np.loadtxt('examples/beta-delayed.dat', unpack=True)
# DEFINE HELPFUL SCALARS AND ARRAYS
xmin = int(np.min(N))
xmax = int(np.max(N))
ymin = int(np.min(Z))
ymax = int(np.max(Z))
xlower = xupper = ylower = yupper = np.array([])
for i in range(xmin, xmax + 1):
x_indices = np.argwhere(Z == i)
xlower = np.append(xlower, np.max(N[x_indices]))
xupper = np.append(xupper, np.min(N[x_indices]))
for i in range(ymin, ymax + 1):
y_indices = np.argwhere(N == i)
ylower = np.append(ylower, np.min(Z[y_indices]))
yupper = np.append(yupper, np.max(Z[y_indices]))
# fix data-inherent shortcomings and align arrays
xupper[0] = 0
xupper[2] = 0
ylower[0] = 0
yupper = np.append(yupper, yupper[-1])
yupper = np.roll(yupper, -1)
xlower = np.append(xlower, xlower[-1])
xlower = np.roll(xlower, -1)
# SET SOME GENERAL PROPERTIES ON OUTPUT FIGURE
ax = plt.gca()
ax.set_xticks(np.arange(xmin, xmax + 1, 8))
ax.set_yticks(np.arange(xmin, xmax + 1, 8))
ax.set_xticks(np.arange(xmin, xmax + 1, 4), minor=True)
ax.set_yticks(np.arange(xmin, xmax + 1, 4), minor=True)
ax.set_axisbelow(True)
ax.grid(which='both', linestyle='--', alpha=0.3)
ax.set_aspect('equal')
plt.xlim(xmin - 0.5, 36 + 0.5)
plt.ylim(xmin - 0.5, 36 + 0.5)
plt.xlabel('$N$')
plt.ylabel('$Z$')
# DEFINE THE DISTINCTIONS TO BE MADE BETWEEN NUCLIDES IN THE CHART OF NUCLIDES
filters = [(np.ones(len(n), dtype=bool)),
(half_life_stbl == 1),
(
......@@ -28,13 +66,12 @@ filters = [(np.ones(len(n), dtype=bool)),
(((QBa > 0) & (QB > 0) & (half_life > 1e-4)) | ((QECa > 0) & (QEC > 0) & (half_life > 1e-4))),
((half_life < 1e-4) | (np.isnan(half_life))) & ~(half_life_stbl == 1)
]
labels = ['',
'$\mathtt{Stable}$',
'$\mathtt{ECp}$ / $\mathtt{\\beta^{-}n}$',
'$\mathtt{EC2p}$ / $\mathtt{\\beta^{-}2n}$',
'$\mathtt{EC\\alpha}$ / $\mathtt{\\beta^{-}\\alpha}$',
'$\mathtt{t_{1/2} }$ < 0.1 ms or \n$\mathtt{t_{1/2} }$ unknown']
'Stable',
'ECp / $\mathtt{\\beta^{-}}$n',
'EC2p / $\mathtt{\\beta^{-}}$2n',
'EC$\mathtt{\\alpha}$ / $\mathtt{\\beta^{-}\\alpha}$',
'$t_{1/2}$ < 0.1 ms or \n$t_{1/2}$ unknown']
rectcenters = [0.5, 0.5, 0.5, 0.5, 0.3, 0.5]
rectsizes = [1.0, 1.0, 1.0, 1.0, 0.6, 1.0]
linewidths = [0.0, 0.0, 0.0, 0.0, 0.2, 0.0]
......@@ -43,23 +80,8 @@ edgecolors = ['w', 'k', 'C5', 'C2', 'k', 'C9']
facecolors = ['w', 'k', 'C5', 'C2', 'C4', 'C9']
shapes = ['s', 's', 's', 's', 'D', 's']
xlower = xupper = ylower = yupper = np.array([])
for i in range(xmin, xmax + 1):
x_indices = np.argwhere(Z == i)
xlower = np.append(xlower, np.max(N[x_indices]))
xupper = np.append(xupper, np.min(N[x_indices]))
for i in range(ymin, ymax + 1):
y_indices = np.argwhere(N == i)
ylower = np.append(ylower, np.min(Z[y_indices]))
yupper = np.append(yupper, np.max(Z[y_indices]))
ax = plt.gca()
ax.set_xticks(np.arange(xmin, xmax + 1, 8))
ax.set_yticks(np.arange(xmin, xmax + 1, 8))
ax.set_xticks(np.arange(xmin, xmax + 1, 4), minor=True)
ax.set_yticks(np.arange(xmin, xmax + 1, 4), minor=True)
ax.set_axisbelow(True)
ax.grid(which='both', linestyle='--', alpha=0.3)
# PLOT THE DISTINCTIONS
for i in range(len(filters)):
if i > 0: # no legend for white squares which are printed for all existing nuclides (otherwise grid is obstructing)
plt.plot(-100, -100, marker=shapes[i], markeredgecolor=edgecolors[i], markersize=markersizes[i],
......@@ -73,20 +95,18 @@ for i in range(len(filters)):
ax.add_patch(plt.Rectangle((x, y - np.sqrt(2)*rectcenters[i]),
rectsizes[i], rectsizes[i], edgecolor=edgecolors[i],
facecolor=facecolors[i], linewidth=linewidths[i], angle=45.0))
ax.set_aspect('equal')
handles, labels = plt.gca().get_legend_handles_labels()
order = [0, 1, 2, 3, 4]
L = plt.legend([handles[idx] for idx in order], [labels[idx] for idx in order], fontsize=8.0)
plt.setp(L.texts, family='monospace')
# align arrays and fix data-inherent shortcomings
yupper = np.append(yupper, yupper[-1])
yupper = np.roll(yupper, -1)
xupper[0] = 0
xupper[2] = 0
ylower[0] = 0
xlower = np.append(xlower, xlower[-1])
xlower = np.roll(xlower, -1)
# PLOT A GRID ON TOP OF ALL KNOWN NUCLIDES
plt.vlines(np.array(range(int(xmin), int(xmax) + 1)) + 0.5, ylower - 0.5, yupper[0:-1] + 0.5, lw=0.4, color='k', capstyle='round')
plt.hlines(np.array(range(int(ymin), int(ymax) + 1)) + 0.5, xlower[0:-1] + 0.5, xupper - 0.5, lw=0.4, color='k', capstyle='round')
# HIGHLIGHT SPECIFIC NUCLIDES
text0 = plt.annotate("$\mathtt{^{21}Mg}$", (9, 12), (3.5, 17), arrowprops=dict(arrowstyle="wedge", lw=1, facecolor='k'), ha="right", path_effects=[pe.withStroke(linewidth=0.6, foreground='lightgrey')])
text0.arrow_patch.set_path_effects([pe.Stroke(linewidth=1.6, foreground='lightgrey'), pe.Normal()])
text1 = plt.annotate("$\mathtt{^{22}Al}$", (9, 13), (7.5, 21), arrowprops=dict(arrowstyle="wedge", lw=1, edgecolor='whitesmoke', facecolor='whitesmoke'), ha="right", color='whitesmoke', path_effects=[pe.withStroke(linewidth=0.6, foreground='k')])
......@@ -94,13 +114,6 @@ text1.arrow_patch.set_path_effects([pe.Stroke(linewidth=1.6, foreground='k'), pe
text2 = plt.annotate("$\mathtt{^{26}P}$", (11, 15), (11, 21), arrowprops=dict(arrowstyle="wedge", lw=1, edgecolor='whitesmoke', facecolor='whitesmoke'), ha="right", color='whitesmoke', path_effects=[pe.withStroke(linewidth=0.6, foreground='k')])
text2.arrow_patch.set_path_effects([pe.Stroke(linewidth=1.6, foreground='k'), pe.Normal()])
plt.xlim(xmin - 0.5, 36 + 0.5)
plt.ylim(xmin - 0.5, 36 + 0.5)
plt.xlabel('$N$')
plt.ylabel('$Z$')
handles, labels = plt.gca().get_legend_handles_labels()
order = [0, 1, 2, 3, 4]
L = plt.legend([handles[idx] for idx in order], [labels[idx] for idx in order], fontsize=8.0)
plt.setp(L.texts, family='monospace')
plt.savefig('examples/beta-delayed.pdf', bbox_inches='tight', dpi=300)
# SAVE THE FIGURE
plt.savefig('examples/beta-delayed.pdf', bbox_inches='tight', dpi=300)
......@@ -105,18 +105,14 @@ while True:
result2 = re2.findall(line2)
result3 = re3.findall(line3)
result4 = re4.findall(line4)
result5 = re5.findall(line4)
while not is_ground_state(result4): # all data files nicely follow the same ordering of isotopes if none-ground state isotopes are skipped in file4
line4 = file4.readline()
result4 = re4.findall(line4)
result5 = re5.findall(line4) # regex patterns 4, 5, 6 and 7 all refer to file4
result6 = re6.findall(line4)
result7 = re7.findall(line4) # regex patterns 4, 5, 6 and 7 all refer to file4
result7 = re7.findall(line4)
for i in range(len(code_strings)):
#all data files nicely follow the same ordering of isotopes if none-ground state isotopes are skipped in file4
while not is_ground_state(result4):
line4 = file4.readline()
result4 = re4.findall(line4)
result5 = re5.findall(line4)
result6 = re6.findall(line4)
result7 = re7.findall(line4)
exec(code_strings[i])
t.Fill()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment