Skip to content

Commit 3b192ab

Browse files
committed
Changes to allow distinguishing metastable isotopes in plot (see issue #45)
examples/outputplotting/plotnuclideheat.py - plotting all isotopes of one element with get_all_isotopes as before, here Sc - plotting one specific ZAI with new get_all_isotopes_states, here Sc45m - plotting all isotopes and states of an element with new get_all_isotopes_states, here Sc pypact/analysis/__init__.py - import new get_all_isotopes_states() pypact/analysis/propertyplotter.py - NuclideDataEntry class(): added self.state, IndexError handling if get_all_isotopes() is used instead of of get_all_isotopes_states() - plotproperty(): also distinguish by state, labels pypact/library/nuclidelib.py - new function get_all_isotopes_states(): multiplying by STATE_MAPPINGS
1 parent 41b84cc commit 3b192ab

File tree

4 files changed

+35
-8
lines changed

4 files changed

+35
-8
lines changed

examples/outputplotting/plotnuclideheat.py

+13-3
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,23 @@
33
import os
44
import pypact as pp
55
import pypact.analysis as ppa
6+
from pypact.library.nuclidelib import get_zai
67

78
filename = os.path.join(os.path.dirname(os.path.abspath(__file__)),
89
'..', '..', 'reference', 'test127.out')
910

10-
tz = ppa.TimeZone.COOL
11-
properties = ['heat', 'grams', 'ingestion']
12-
isotopes = [ ppa.NuclideDataEntry(i) for i in ppa.get_all_isotopes() if ppa.find_z(i[0]) <= 10]
11+
tz = ppa.TimeZone.BOTH
12+
properties = ['heat', 'grams', 'inhalation']
13+
14+
# plot all isotopes of a specific element regardless of state, here Sc
15+
#isotopes = [ ppa.NuclideDataEntry(i) for i in ppa.get_all_isotopes() if ppa.find_z(i[0]) == 21]
16+
17+
# plot specific isotope with specific state, here Sc45m
18+
#isotopes = [ ppa.NuclideDataEntry(i) for i in ppa.get_all_isotopes_states() if get_zai(i[0]+str(i[1])+str(i[2])) == 210451 ]
19+
20+
# plot all isotopes and states of an element, here Sc
21+
isotopes = [ ppa.NuclideDataEntry(i) for i in ppa.get_all_isotopes_states() if ppa.find_z(i[0]) == 21 ]
22+
1323

1424
plt = ppa.LinePlotAdapter()
1525

pypact/analysis/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@
1111
from pypact.library.nuclidelib import find_element
1212
from pypact.library.nuclidelib import find_z
1313
from pypact.library.nuclidelib import get_all_isotopes
14+
from pypact.library.nuclidelib import get_all_isotopes_states

pypact/analysis/propertyplotter.py

+10-5
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,21 @@ class NuclideDataEntry(object):
77
def __init__(self, nuclide):
88
self.element = nuclide[0]
99
self.isotope = nuclide[1]
10-
10+
try:
11+
self.state = nuclide[2]
12+
except IndexError:
13+
self.state = ""
14+
1115
self.reset()
1216

1317
def reset(self):
1418
self.times = []
1519
self.values = []
20+
1621

1722
def __str__(self):
18-
return str.format("Isotope {0}-{1} values: {2}",
19-
self.element, self.isotope, self.values)
23+
return str.format("Isotope {0}-{1}-{2} values: {3}",
24+
self.element, self.isotope, self.state, self.values)
2025

2126

2227
def plotproperty(output,
@@ -40,7 +45,7 @@ def plotproperty(output,
4045
value = getattr(n, property)
4146
total += value
4247
for i in isotopes:
43-
if n.element == i.element and n.isotope == i.isotope:
48+
if n.element == i.element and n.isotope == i.isotope and n.state == i.state:
4449
i.times.append(t.irradiation_time + t.cooling_time)
4550
i.values.append(value)
4651

@@ -60,7 +65,7 @@ def plotproperty(output,
6065

6166
f = plotter.lineplot(x=i.times,
6267
y=i.values,
63-
datalabel=str.format('{0}-{1}', i.element, i.isotope),
68+
datalabel=str.format('{0}-{1}{2}', i.element, i.isotope, i.state),
6469
xlabel="time [s]",
6570
ylabel=yaxislabel,
6671
logx=(timeperiod != TimeZone.IRRAD),

pypact/library/nuclidelib.py

+11
Original file line numberDiff line numberDiff line change
@@ -197,3 +197,14 @@ def get_all_isotopes():
197197
all_list[count] = (n[ELEMENT_KEY], i)
198198
count += 1
199199
return all_list
200+
201+
def get_all_isotopes_states():
202+
all_list_2 = [('', 0,'')] * NUMBER_OF_ISOTOPES * len(STATE_MAPPINGS)
203+
count = 0
204+
for n in NUCLIDE_DICTIONARY:
205+
if ELEMENT_KEY in n and ISOTOPES_KEY in n:
206+
for i in n[ISOTOPES_KEY]:
207+
for k in STATE_MAPPINGS:
208+
all_list_2[count] = (n[ELEMENT_KEY], i, STATE_MAPPINGS[k])
209+
count += 1
210+
return all_list_2

0 commit comments

Comments
 (0)