mirror of
https://github.com/pim-n/pg-rad
synced 2026-03-23 21:58:12 +01:00
Add isotope lookup dictionary, so isotopes can be loaded from string in config.
This commit is contained in:
@ -2,9 +2,8 @@
|
||||
__ignore__ = ["logger"]
|
||||
|
||||
from pg_rad.isotopes import isotope
|
||||
from pg_rad.isotopes import presets
|
||||
|
||||
from pg_rad.isotopes.isotope import (Isotope,)
|
||||
from pg_rad.isotopes.presets import (CS137,)
|
||||
from pg_rad.isotopes.isotope import (CS137, Isotope, get_isotope,
|
||||
preset_isotopes,)
|
||||
|
||||
__all__ = ['CS137', 'Isotope', 'isotope', 'presets']
|
||||
__all__ = ['CS137', 'Isotope', 'get_isotope', 'isotope', 'preset_isotopes']
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
from typing import Dict, Type
|
||||
|
||||
from pg_rad.physics.attenuation import get_mass_attenuation_coeff
|
||||
|
||||
|
||||
@ -25,3 +27,24 @@ class Isotope:
|
||||
self.E = E
|
||||
self.b = b
|
||||
self.mu_mass_air = get_mass_attenuation_coeff(E / 1000)
|
||||
|
||||
|
||||
class CS137(Isotope):
|
||||
def __init__(self):
|
||||
super().__init__(
|
||||
name="Cs-137",
|
||||
E=661.66,
|
||||
b=0.851
|
||||
)
|
||||
|
||||
|
||||
preset_isotopes: Dict[str, Type[Isotope]] = {
|
||||
"CS137": CS137
|
||||
}
|
||||
|
||||
|
||||
def get_isotope(isotope_str: str) -> Isotope:
|
||||
"""Lazy factory function to create isotope objects."""
|
||||
if isotope_str not in preset_isotopes:
|
||||
raise ValueError(f"Unknown isotope: {isotope_str}")
|
||||
return preset_isotopes[isotope_str]()
|
||||
|
||||
@ -1,10 +0,0 @@
|
||||
from .isotope import Isotope
|
||||
|
||||
|
||||
class CS137(Isotope):
|
||||
def __init__(self):
|
||||
super().__init__(
|
||||
name="Cs-137",
|
||||
E=661.66,
|
||||
b=0.851
|
||||
)
|
||||
Reference in New Issue
Block a user