Skip to content
Open
33 changes: 33 additions & 0 deletions libra_toolbox/neutron_detection/activation_foils/calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ class Reaction:
reactant: Nuclide
product: Nuclide
cross_section: float
type: str = "(n,2n)"
"""
Class to hold the information of a reaction.
Attributes
Expand All @@ -113,6 +114,7 @@ class Reaction:
The product of the reaction.
cross_section :
The cross section of the reaction in cm2.
type: The type of the reaction (default is "(n,2n)").
"""

nb93_n2n = Reaction(
Expand All @@ -133,6 +135,7 @@ class CheckSource:
nuclide: Nuclide
activity_date: datetime.date
activity: float
activity_error: float = 0.0

"""
Class to hold the information of a check source.
Expand Down Expand Up @@ -175,6 +178,36 @@ def get_expected_activity(self, date: datetime.date) -> float:
time = (date - activity_datetime).total_seconds()
act_expec = self.activity * np.exp(-decay_constant * time)
return act_expec

def get_expected_activity_error(self, date: datetime.date) -> float:
"""Returns the expected activity error of the check source at a given date.
Time is assumed to have no error in its measurement.

Args:
date: the date to calculate the expected activity error for.

Returns:
the expected activity error of the check source in Bq
"""

decay_constant = np.log(2) / self.nuclide.half_life

# Convert date to datetime if needed
if isinstance(self.activity_date, datetime.date) and not isinstance(
self.activity_date, datetime.datetime
):

activity_datetime = datetime.datetime.combine(
self.activity_date, datetime.datetime.min.time()
)
# add a timezone
activity_datetime = activity_datetime.replace(tzinfo=date.tzinfo)
else:
activity_datetime = self.activity_date

time = (date - activity_datetime).total_seconds()
act_expec = self.activity_error * np.exp(-decay_constant * time)
return act_expec


@dataclass
Expand Down
Loading
Loading