Add mu_mass_air to isotope automatically calculated from energy and fix error msg

This commit is contained in:
Pim Nelissen
2026-02-09 15:31:53 +01:00
parent 2c436c52ad
commit 0c81b4df89

View File

@ -1,3 +1,6 @@
from pg_rad.physics import get_mass_attenuation_coeff
class Isotope: class Isotope:
"""Represents the essential information of an isotope. """Represents the essential information of an isotope.
@ -16,8 +19,9 @@ class Isotope:
raise ValueError("primary_gamma must be a positive energy (keV).") raise ValueError("primary_gamma must be a positive energy (keV).")
if not (0 <= b <= 1): if not (0 <= b <= 1):
raise ValueError("branching_ratio_pg must be a ratio (0 <= b <= 1)") raise ValueError("branching_ratio_pg must be a ratio b in [0,1]")
self.name = name self.name = name
self.E = E self.E = E
self.b = b self.b = b
self.mu_mass_air = get_mass_attenuation_coeff(E / 1000)