Skip to content

Commit 45d94fc

Browse files
committed
Update Nubase to NUBASE
To align with AME, always refer to NUBASE in all capital letters.
1 parent bb03278 commit 45d94fc

File tree

5 files changed

+28
-28
lines changed

5 files changed

+28
-28
lines changed

README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ For example, track how the accuracy of the mass excess of 18B changes once it is
4040
```python
4141
>>> import pynch.mass_table as mt
4242
>>> df = mt.MassTable().full_data
43-
>>> df[(df['A'] == 18) & (df['Z'] == 5)][['Experimental', 'NubaseMassExcess', 'NubaseMassExcessError', 'NubaseRelativeError', 'DiscoveryYear']]
44-
Experimental NubaseMassExcess NubaseMassExcessError NubaseRelativeError DiscoveryYear
43+
>>> df[(df['A'] == 18) & (df['Z'] == 5)][['Experimental', 'NUBASEMassExcess', 'NUBASEMassExcessError', 'NUBASERelativeError', 'DiscoveryYear']]
44+
Experimental NUBASEMassExcess NUBASEMassExcessError NUBASERelativeError DiscoveryYear
4545
TableYear
4646
2003 False 52320.0 800.0 0.015291 1900
4747
2012 True 51850.0 170.0 0.003279 2010
@@ -52,7 +52,7 @@ Or for all of the A=100 isotopes from the 2012 table that have a mass-excess err
5252
```python
5353
>>> import pynch.mass_table as mt
5454
>>> df = mt.MassTable().full_data
55-
>>> df.query('TableYear == 2012 and A == 100 and NubaseMassExcessError < 10.0')[['A', 'Z', 'Symbol', 'DiscoveryYear']]
55+
>>> df.query('TableYear == 2012 and A == 100 and NUBASEMassExcessError < 10.0')[['A', 'Z', 'Symbol', 'DiscoveryYear']]
5656
A Z Symbol DiscoveryYear
5757
TableYear
5858
2012 100 40 Zr 1970
@@ -68,12 +68,12 @@ Or how does the NUBASE mass-excess compare with the AME value for experimentally
6868
>>> import pynch.mass_table as mt
6969
>>> df = mt.MassTable().full_data
7070
>>> # Create a new column comparing the measured values
71-
>>> df['NUBASE-AME'] = df['NubaseMassExcess'] - df['AMEMassExcess']
71+
>>> df['NUBASE-AME'] = df['NUBASEMassExcess'] - df['AMEMassExcess']
7272
>>> # Extract the data for measured isotopes and from the latest table
7373
>>> df_comparison = df.query('TableYear == 2020 and Experimental == True')
7474
>>> # Sort the difference in measured data by absolute value and print the columns we are interested in
75-
>>> df_comparison.sort_values(by=['NUBASE-AME'], key=abs, ascending=False)[['A', 'Z', 'Symbol', 'NubaseMassExcess', 'AMEMassExcess', 'NUBASE-AME']].head(n=10)
76-
A Z Symbol NubaseMassExcess AMEMassExcess NUBASE-AME
75+
>>> df_comparison.sort_values(by=['NUBASE-AME'], key=abs, ascending=False)[['A', 'Z', 'Symbol', 'NUBASEMassExcess', 'AMEMassExcess', 'NUBASE-AME']].head(n=10)
76+
A Z Symbol NUBASEMassExcess AMEMassExcess NUBASE-AME
7777
TableYear
7878
2020 221 91 Pa 20370.0 20374.937 -4.937
7979
2020 57 23 V -44440.0 -44435.063 -4.937

pynch/mass_table.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from pynch.ame_mass_parse import AMEMassParser
1010
from pynch.ame_reaction_1_parse import AMEReactionParserOne
1111
from pynch.ame_reaction_2_parse import AMEReactionParserTwo
12-
from pynch.nubase_parse import NubaseParser
12+
from pynch.nubase_parse import NUBASEParser
1313

1414

1515
class MassTable:
@@ -79,7 +79,7 @@ def _validate_year(self, year: int) -> int:
7979
def _parse_nubase_data(self, year: int) -> pd.DataFrame:
8080
"""Get the nubase for the given year as a pandas.DataFrame."""
8181
year = self._validate_year(year)
82-
return NubaseParser(self._get_nubase_datafile(year), year).read_file()
82+
return NUBASEParser(self._get_nubase_datafile(year), year).read_file()
8383

8484
def _parse_ame_data(self, year: int) -> pd.DataFrame:
8585
"""Combine all the AME files from the given year into a pandas.DataFrame."""
@@ -98,14 +98,14 @@ def _combine_all_data(self) -> pd.DataFrame:
9898
common_columns = ['A', 'Z', 'N', 'TableYear', 'Symbol']
9999
df = self.nubase.merge(self.ame, on=common_columns)
100100

101-
df["NubaseRelativeError"] = abs(
102-
df["NubaseMassExcessError"] / df["NubaseMassExcess"]
101+
df["NUBASERelativeError"] = abs(
102+
df["NUBASEMassExcessError"] / df["NUBASEMassExcess"]
103103
)
104104
df["AMERelativeError"] = abs(df["AMEMassExcessError"] / df["AMEMassExcess"])
105105

106106
# 12C has a 0.0 +/ 0.0 mass excess by definition so calculating relative error -> NaN
107107
# Set the value to 0.0 as that's what it is
108-
df.loc[(df.Symbol == "C") & (df.A == 12), "NubaseRelativeError"] = 0.0
108+
df.loc[(df.Symbol == "C") & (df.A == 12), "NUBASERelativeError"] = 0.0
109109
df.loc[(df.Symbol == "C") & (df.A == 12), "AMERelativeError"] = 0.0
110110

111111
# 198Au has a typo in it's decay mode in the 2012 table. It is recorded as '-'

pynch/nubase_file.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from pynch.parse import Parse
33

44

5-
class NubaseFile(Parse):
5+
class NUBASEFile(Parse):
66
"""Easy access to where variables are in the NUBASE file.
77
88
The NUBASE data file is formatted by location in the line, values exist

pynch/nubase_parse.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66

77
import pandas as pd
88

9-
from pynch.nubase_file import NubaseFile
9+
from pynch.nubase_file import NUBASEFile
1010

1111

12-
class NubaseParser(NubaseFile):
12+
class NUBASEParser(NUBASEFile):
1313
"""Parse the NUBASE data file.
1414
1515
A collection of functions to parse the weird format of the NUBASE file.
@@ -96,8 +96,8 @@ def _read_line(self, line: str) -> dict:
9696
"TableYear": self.year,
9797
"A": self._read_as_int(line, self.START_A, self.END_A),
9898
"Z": self._read_as_int(line, self.START_Z, self.END_Z),
99-
"NubaseMassExcess": self._read_as_float(line, self.START_ME, self.END_ME),
100-
"NubaseMassExcessError": self._read_as_float(line, self.START_DME, self.END_DME),
99+
"NUBASEMassExcess": self._read_as_float(line, self.START_ME, self.END_ME),
100+
"NUBASEMassExcessError": self._read_as_float(line, self.START_DME, self.END_DME),
101101
# "LevelEnergy" : self._read_as_float(,
102102
# line, self.START_ISOMER, self.END_ISOMER
103103
# )

tests/test_nubase_parse.py

+12-12
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55

66
def test_read_halflife_value():
7-
parser = nbp.NubaseParser(pathlib.Path("."), 2003)
7+
parser = nbp.NUBASEParser(pathlib.Path("."), 2003)
88

99
line_01 = "232 0950 232Am 43400# 300# 1.31 m 0.04 91 B+=?;A=2#;B+SF=0.069 10"
1010
assert parser._read_halflife_value(line_01) == 1.31
@@ -14,7 +14,7 @@ def test_read_halflife_value():
1414

1515

1616
def test_read_halflife_error():
17-
parser = nbp.NubaseParser(pathlib.Path("."), 2003)
17+
parser = nbp.NUBASEParser(pathlib.Path("."), 2003)
1818

1919
line_01 = "113 0500 113Sn -88333 4 115.09 d 0.03 1/2+ 00 B+=100"
2020
assert parser._read_halflife_error(line_01) == 0.03
@@ -24,14 +24,14 @@ def test_read_halflife_error():
2424

2525

2626
def test_no_decay_mode():
27-
parser = nbp.NubaseParser(pathlib.Path("."), 2012)
27+
parser = nbp.NUBASEParser(pathlib.Path("."), 2012)
2828

2929
no_decay = "044 0212 44Scn -37669.9 1.8 146.224 0.022 50.4 us 0.7 0- 99"
3030
assert parser._read_decay_string(no_decay) == "UNKNOWN"
3131

3232

3333
def test_readable_line():
34-
parser = nbp.NubaseParser(pathlib.Path("."), 2003)
34+
parser = nbp.NUBASEParser(pathlib.Path("."), 2003)
3535

3636
bad_line01 = "003 0030 3Li 28670# 2000# RN p-unst 98 p ?"
3737
bad_line02 = "130 0556 130Csx -86873 17 27 15 R=.2~~~.1 fsmix"
@@ -47,7 +47,7 @@ def test_readable_line():
4747

4848

4949
def test_read_line():
50-
parser = nbp.NubaseParser(pathlib.Path("."), 2003)
50+
parser = nbp.NUBASEParser(pathlib.Path("."), 2003)
5151

5252
iso_line = "183 0791 183Aum -30114 10 73.3 0.4 >1 us (1/2)+ 99 IT=100"
5353
assert parser._read_line(iso_line) == dict()
@@ -59,8 +59,8 @@ def test_read_line():
5959
assert d['Z'] == 29
6060
assert d['N'] == 28
6161
assert d['Experimental'] is True
62-
assert d['NubaseMassExcess'] == -47310.0
63-
assert d['NubaseMassExcessError'] == 16.0
62+
assert d['NUBASEMassExcess'] == -47310.0
63+
assert d['NUBASEMassExcessError'] == 16.0
6464
assert d['HalfLifeValue'] == 196.3
6565
assert d['HalfLifeUnit'] == "ms"
6666
assert d['HalfLifeError'] == 0.7
@@ -75,8 +75,8 @@ def test_read_line():
7575
assert d['Z'] == 53
7676
assert d['N'] == 57
7777
assert d['Experimental'] is False
78-
assert d['NubaseMassExcess'] == -60320
79-
assert d['NubaseMassExcessError'] == 310
78+
assert d['NUBASEMassExcess'] == -60320
79+
assert d['NUBASEMassExcessError'] == 310
8080
assert d['HalfLifeValue'] == 650
8181
assert d['HalfLifeUnit'] == "ms"
8282
assert d['HalfLifeError'] == 20
@@ -85,7 +85,7 @@ def test_read_line():
8585
assert d['Decay'] == "B+"
8686

8787
# 2020 table has a new format
88-
parser = nbp.NubaseParser(pathlib.Path("."), 2020)
88+
parser = nbp.NUBASEParser(pathlib.Path("."), 2020)
8989

9090
# Use the same isotope as previously tested
9191
gs_line = "057 0290 57Cu -47309.0 0.5 196.4 ms 0.7 3/2-* 98 1976 B+=100"
@@ -95,8 +95,8 @@ def test_read_line():
9595
assert d['Z'] == 29
9696
assert d['N'] == 28
9797
assert d['Experimental'] is True
98-
assert d['NubaseMassExcess'] == -47309.0
99-
assert d['NubaseMassExcessError'] == 0.5
98+
assert d['NUBASEMassExcess'] == -47309.0
99+
assert d['NUBASEMassExcessError'] == 0.5
100100
assert d['HalfLifeValue'] == 196.4
101101
assert d['HalfLifeUnit'] == "ms"
102102
assert d['HalfLifeError'] == 0.7

0 commit comments

Comments
 (0)