Skip to content

Commit

Permalink
Adding Config Validation for Abundance
Browse files Browse the repository at this point in the history
  • Loading branch information
DhruvSondhi committed Apr 26, 2021
1 parent 747390d commit 6c6fc89
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions tardis/io/model_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,21 @@ def read_uniform_abundances(abundances_section, no_of_shells):
try:
if element_symbol_string in nucname.name_zz:
z = nucname.name_zz[element_symbol_string]
abundance.loc[z] = float(
abundances_section[element_symbol_string]
)
if abundances_section[element_symbol_string] > 0:
abundance.loc[z] = float(
abundances_section[element_symbol_string]
)
else:
raise ValueError(f"Abundance Must Be A Positive Value")
else:
mass_no = nucname.anum(element_symbol_string)
z = nucname.znum(element_symbol_string)
isotope_abundance.loc[(z, mass_no), :] = float(
abundances_section[element_symbol_string]
)
if abundances_section[element_symbol_string] > 0:
isotope_abundance.loc[(z, mass_no), :] = float(
abundances_section[element_symbol_string]
)
else:
raise ValueError(f"Abundance Must Be A Positive Value")

except RuntimeError as err:
raise RuntimeError(
Expand Down

0 comments on commit 6c6fc89

Please sign in to comment.