Skip to content

Commit deced2e

Browse files
committed
Refactor getting the level spin from the NUBASE file
1 parent b23ee04 commit deced2e

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

pynch/nubase_parse.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,16 @@ def _read_all_halflife_data(self, line: str) -> tuple:
4747
self._read_halflife_error(line)
4848
)
4949

50+
def _read_spin(self, line: str) -> str:
51+
"""Extract the spin of the isotope and it's level."""
52+
# 2020 brought in '*' for directly measured. Just remove it for the moment
53+
# TODO parse the spin parity with the new characters
54+
spin = self._read_substring(line, self.START_SPIN, self.END_SPIN)
55+
if spin and spin.find('*') != -1:
56+
spin = spin.replace('*', '')
57+
58+
return spin
59+
5060
def _read_decay_string(self, line: str) -> str:
5161
"""Extract the decay mode and do some book keeping for consistency."""
5262
decay_string = (
@@ -98,11 +108,7 @@ def _read_line(self, line: str) -> dict:
98108

99109
data["HalfLifeValue"], data["HalfLifeUnit"], data["HalfLifeError"] = self._read_all_halflife_data(line)
100110

101-
# 2020 brought in '*' for directly measured. Just remove it for the moment
102-
# TODO parse the spin parity with the new characters
103-
data["LevelSpin"] = self._read_substring(line, self.START_SPIN, self.END_SPIN)
104-
if data["LevelSpin"] and data["LevelSpin"].find("*") != -1:
105-
data["LevelSpin"] = data["LevelSpin"].replace("*", "")
111+
data["LevelSpin"] = self._read_spin(line)
106112

107113
data["DiscoveryYear"] = (
108114
self._read_as_int(line, self.START_YEAR, self.END_YEAR, default=1900)

0 commit comments

Comments
 (0)