From 0c81b4df899a28ab6f0e2fe6264c819d647ca83c Mon Sep 17 00:00:00 2001 From: Pim Nelissen Date: Mon, 9 Feb 2026 15:31:53 +0100 Subject: [PATCH] Add mu_mass_air to isotope automatically calculated from energy and fix error msg --- src/pg_rad/isotopes/isotope.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/pg_rad/isotopes/isotope.py b/src/pg_rad/isotopes/isotope.py index ea758b8..78ac54e 100644 --- a/src/pg_rad/isotopes/isotope.py +++ b/src/pg_rad/isotopes/isotope.py @@ -1,3 +1,6 @@ +from pg_rad.physics import get_mass_attenuation_coeff + + class Isotope: """Represents the essential information of an isotope. @@ -11,13 +14,14 @@ class Isotope: name: str, E: float, b: float - ): + ): if E <= 0: raise ValueError("primary_gamma must be a positive energy (keV).") 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.E = E self.b = b + self.mu_mass_air = get_mass_attenuation_coeff(E / 1000)