nerea package
Submodules
nerea.calculated module
- class nerea.calculated.CalculatedSpectralIndex(data, model_id, deposit_ids)[source]
Bases:
_Calculatednerea.CalculatedSpectralIndexSpectral Index calculated in any simulation. Can be created from Serpent outputs. Can be created from ratio of Serpent detectors or from a direct tally of the ratio.
- \*\*data**
the calculated spectral index value and uncertainty.
- Type:
pd.DataFrame
- \*\*model_id**
metadata for model identifier.
- Type:
str
- \*\*deposit_ids**
two-element list with the deposits considered in the spectral index. First element for numerator, second for denominator.
- Type:
list[str]
- data: DataFrame
- model_id: str
- deposit_ids: list[str]
- classmethod from_sts(file, detector_name, **kwargs)[source]
nerea.CalculatedSpectralIndex.from_sts()
Creates an instance using data extracted from a Serpent det.m file for a specific detector.
- param **file**:
The file path from which data will be read.
- type **file**:
str- param **detector_name**:
The name of the detector from which data will be extracted.
- type **detector_name**:
str- returns:
An instance of the nerea.CalculatedSpectralIndex class created from the specified file.
- rtype:
nerea.CalculatedSpectralIndex
- Parameters:
file (str)
detector_name (str)
- Return type:
Self
- classmethod from_sts_detectors(file, detector_names, normalize=False, xs_kwargs={}, **kwargs)[source]
nerea.CalculatedSpectralIndex.from_sts_detectors()
Creates an instance using data extracted from a Serpent det.m file for multiple detectors.
- param **file**:
The file path from which data will be read.
- type **file**:
str- param **detector_names**:
Keys can be
'numerator'or'denominator', while values are the names of the detectors from which data will be extracted.- type **detector_names**:
dict[str, str]- param **xs_kwargs**:
Additional arguments for
nerea.Xsinstance creationmass_normalized (
bool, optional), whether the cross section is mass-normalized.volume_normalized (
bool, optional), whether the cross section is volume-normalized.volume (
float, optional), volume for volume normalization.
- type **xs_kwargs**:
dict- param *kwargs:
Additional arguments for instance creation
model_id (
str), model identitydeposit_ids (
list[str]), nuclide identifiers
- returns:
An instance of the CalculatedSpectralIndex class created from the specified file.
- rtype:
nerea.CalculatedSpectralIndex
- Parameters:
file (str)
detector_names (dict[str, str])
xs_kwargs (dict)
- Return type:
Self
- calculate()[source]
nerea.CalculatedSpectralIndex.calculate()
Computes the C value. Alias for self.data.
- returns:
data frame containing C
'value'and'uncertainty'columns.- rtype:
pd.DataFrame
Examples
>>> c_instance = CalculatedSpectralIndex(data=pd.DataFrame({'value': [0.5], 'uncertainty': [0.05]}), model_id='Model1', deposit_ids='Dep1') >>> c_instance.compute() value uncertainty 0 0.5 0.05
- Parameters:
data (DataFrame)
model_id (str)
deposit_ids (list[str])
- class nerea.calculated.CalculatedTraverse(data, model_id, deposit_id)[source]
Bases:
_Calculatednerea.CalculatedTraverseTraverse calculated in any simulation. Can be created from Serpent outputs.
- \*\*data**
the calculated traverse values and uncertainties.
- Type:
pd.DataFrame
- \*\*model_id*
metadata for model identifier.
- Type:
str
- \*\*deposit_ids**
the deposits of the tally considered.
- Type:
str
- data: DataFrame
- model_id: str
- deposit_id: str
- classmethod from_sts(file, detector_names, **kwargs)[source]
nerea.CalculatedTraverse.from_sts()
Creates an instance using data extracted from a Serpent det.m file for multiple detectors.
- param **file**:
The file path from which data will be read.
- type **file**:
str- param **detector_names**:
The names of the detectors from which data will be extracted.
- type **detector_names**:
Iterable[str]- param **normalization**:
The detector name to normalize the traveres to. Defaults to None, normalizing to the one with the highest counts.
- type **normalization**:
str, optional- returns:
An instance of the CalculatedTraverse class created from the specified file.
- rtype:
nerea.CalculatedTraverse
- Parameters:
file (str)
detector_names (list[str])
- Return type:
Self
- calculate(normalization=None)[source]
nerea.CalculatedTraverse.calculate()
Computes the C value. Normalized self.data.
- param **normalization**:
The detector name to normalize the traveres to. Defaults to
None, normalizing to the one with the highest counts.- type **normalization**:
str, optional- returns:
data frame containing C ‘value’ and ‘uncertainty’ columns.
- rtype:
pd.DataFrame
- Parameters:
normalization (str)
- Parameters:
data (DataFrame)
model_id (str)
deposit_id (str)
nerea.classes module
- class nerea.classes.EffectiveDelayedParams(lambda_i, beta_i)[source]
Bases:
objectnerea.EffectiveDelayedParamsClass storing and pre-processing effective delayed parameters.
- \*\*lambda_i**
precursor-group-wise effective decay constant.
- Type:
pd.DataFrame
- \*\*beta_i**
precursor-group-wise effective decay fraction.
- Type:
pd.DataFrame
- lambda_i: DataFrame
- beta_i: DataFrame
- classmethod from_sts(file)[source]
nerea.EffectiveDelayedParams.from_sts()
Creates an instance using data extracted from a Serpent res.m.
- param **file**:
The file path from which data will be read.
- type **file**:
str- returns:
An instance of the nerea.EffectiveDelayedParams class created from the specified file.
- rtype:
nerea.EffectiveDelayedParams
- Parameters:
file (str)
- Return type:
Self
- Parameters:
lambda_i (DataFrame)
beta_i (DataFrame)
- class nerea.classes.Xs(data, mass_normalized=False, volume_normalized=False, volume=1.0)[source]
Bases:
objectnerea.XsClass storing one group cross section data.
- \*\*data**
data frame with cross section data (index is nuclide identifier).
- Type:
pd.DataFrame
- \*\*mass_normalized**
whether the cross section is mass-normalized. Default is False.
- Type:
bool, optional
- \*\*volume_normalized**
whether the cross section is volume-normalized. Default is False.
- Type:
bool, optional
- \*\*volume**
volume for volume normalization. Default is 1.0.
- Type:
float, optional
- data: DataFrame
- mass_normalized: bool
- volume_normalized: bool
- volume: float
- classmethod from_file(file, read, *args, **kwargs)[source]
nerea.Xs.from_file()
Create Xs object from serpent detector output file.
- param **file**:
Serpent output file path from which data will be read.
- type **file**:
str- param **read**:
The nuclide (key) associated with each detector (value).
- type **read**:
dict[str, str]- param **args:
Additional arguments for instance creation
mass_normalized (
bool, optional), whether the cross section is mass-normalized.volume_normalized (
bool, optional), whether the cross section is volume-normalized.volume (
float, optional), volume for volume normalization.
- param **kwargs:
Additional arguments for instance creation
mass_normalized (
bool, optional), whether the cross section is mass-normalized.volume_normalized (
bool, optional), whether the cross section is volume-normalized.volume (
float, optional), volume for volume normalization.
- rtype:
nerea.Xs
- Parameters:
file (str)
read (dict[str, str])
- Return type:
Self
- Parameters:
data (DataFrame)
mass_normalized (bool)
volume_normalized (bool)
volume (float)
nerea.comparisons module
- class nerea.comparisons.CoverE(num, den, _enable_checks=True)[source]
Bases:
_Comparisonnerea.CoverECalculates the C/E inheriting from nerea._Comparison.
- \*\*num**
the calculated quantity to use as numerator.
- Type:
nerea._Calculated
- \*\*den**
the measured quantity to use as denominator.
- Type:
nerea._Experimental
- \*\*_enable_checks**
flag to enable consistency checks. Default is
True.- Type:
bool, optional
- Parameters:
num (_Calculated)
den (_Experimental)
_enable_checks (bool)
- class nerea.comparisons.CoverC(num, den, _enable_checks=True)[source]
Bases:
_Comparisonnerea.CoverCCalculates the C/C inheriting from nerea._Comparison.
Attributes:
- num:
nerea._Calculated the calculated quantity to use as numerator.
- den:
nerea._Calculated the calculated quantity to use as denominator.
- _enable_checks:
bool, optional flag to enable consistency checks. Default is
True.
- Parameters:
num (_Calculated)
den (_Calculated)
_enable_checks (bool)
- num:
- class nerea.comparisons.FrameCompare(num, den)[source]
Bases:
objectnerea.FrameCompareA class to compute the ratio comparison of two
pd.DataFrameinstances. Each data frame should be nerea-formatted, with'value'and'uncertainty'columns.- \*\*num**
the numerator.
- Type:
pd.DataFrame
- \*\*den**
the denominator.
- Type:
pd.DataFrame
- num: DataFrame
- den: DataFrame
- compute(_minus_one_percent=False)[source]
nerea.FrameCompare.compute()
Computes the comparison value as ratio of num and den.
- param **_minus_one_percent**:
computes the C/E-1 [%]. Defaults to False.
- type **_minus_one_percent**:
bool, optional- returns:
data frame containing the comparison value.
- rtype:
pd.DataFrame
- Return type:
DataFrame
- Parameters:
num (DataFrame)
den (DataFrame)
nerea.constants module
nerea.control_rod module
- class nerea.control_rod.ControlRodCalibration(count_rates, critical_height, name)[source]
Bases:
objectnerea.ControlRodCalibrationSuperclass for control rod calibration.
- \*\*count_rates**
The count rates associated with the calibration. key is the control rod height and value is the associated ount rate.
- Type:
dict[float, nerea.CountRate]
- \*\*critical_height**
the critical control rod height.
- Type:
float
- \*\*name**
metadata for control rod identification.
- Type:
int
- critical_height: float
- name: int
- get_reactivity_worth(x0, x1, delayed_data, order, dtc_kwargs={}, ap_kwargs={})[source]
nerea.ControlRodCalibration.get_reactivity_worth()
Computes the reactivity worth given by a control rod movement.
- param **x0**:
starting control rod position.
- type **x0**:
float- param **x1**:
final control rod position.
- type **x1**:
float- param **delayed_data**:
delayed neutron data to use to calculate the reactivity.
- type **delayed_data**:
nerea.EffectiveDelayedParams- param **order**:
polynomial order for the control rod calibration curve.
- type **order**:
int- param **dtc_kwargs**:
keyword arguments for count rate dead time correction. Default is
{}taking values from nerea.defaults.py.- type **dtc_kwargs**:
dict, optional- param **ap_kwargs**:
keyword arguments for asymptotic count rate identification. Default is
{}taking values from nerea.defaults.py.- type **ap_kwargs**:
dict, optional- returns:
The reactivity worth associated with the chosen control rod movement.
- rtype:
pd.DataFrame
- Parameters:
x0 (float)
x1 (float)
delayed_data (EffectiveDelayedParams)
order (int)
dtc_kwargs (dict)
ap_kwargs (dict)
- Return type:
DataFrame
- plot(dtc_kwargs={}, ap_kwargs={})[source]
nerea.ControlRodCalibration.plot()
Computes the reactivity worth given by a control rod movement. Plots the data handled.
- param **dtc_kwargs**:
keyword arguments for count rate dead time correction. Default is {} taking values from nerea.defaults.py.
- type **dtc_kwargs**:
dict, optional- param **ap_kwargs**:
keyword arguments for asymptotic count rate identification. Default is {} taking values from nerea.defaults.py.
- type **ap_kwargs**:
dict, optional- returns:
The Figure and Axes produced.
- rtype:
tuple[plt.Figure, plt.Axes]
- Parameters:
dtc_kwargs (dict)
ap_kwargs (dict)
- Return type:
tuple[Figure, Axes]
- Parameters:
count_rates (dict[float, CountRate])
critical_height (float)
name (int)
- class nerea.control_rod.DifferentialNoCompensation(count_rates, critical_height, name)[source]
Bases:
ControlRodCalibrationnerea.DifferentialNoCompensationClass for differential control rod calibration without compensation. Inherits from nerea.ControlRodCalibration
- \*\*count_rates**
The count rates associated with the calibration. key is the control rod height and value is the associated ount rate.
- Type:
dict[float, nerea.CountRate]
- \*\*critical_height**
the critical control rod height.
- Type:
float
- \*\*name**
metadata for control rod identification.
- Type:
int
- get_reactivity_curve(delayed_data, dtc_kwargs={}, ap_kwargs={}, visual=False, savefig='')[source]
” nerea.DifferentialNoCompensation.get_reactivity_curve() ——————————————————— Computes the differential reacitivty curve dr/dh for measurements without compensation.
- Parameters:
**delayed_data** (
nerea.EffectiveDelayedParams) – path to the Serpent ‘res.m’ output file to read effective delayed neutron data from.**dtc_kwargs** (
dict, optional) – kwargs for nerea.CountRate.dead_time_corrected. Default is{}.**ap_kwargs** (
dict, optional) – kwargs for nerea.CountRate.asymptotic_period. Default is{}.**visual** (
bool, optional) – Whether to plot the processed data. Default isFalse.**savefig** (
str, optional) – File name to save the plotted data to. Default is ‘’ for no plotting.delayed_data (EffectiveDelayedParams)
dtc_kwargs (dict)
ap_kwargs (dict)
visual (bool)
savefig (str)
- Return type:
pd.DataFrame
- Parameters:
count_rates (dict[float, CountRate])
critical_height (float)
name (int)
- class nerea.control_rod.IntegralNoCompensation(count_rates, critical_height, name)[source]
Bases:
ControlRodCalibrationnerea.IntegralNoCompensationClass for integral control rod calibration without compensation. Inherits from nerea.ControlRodCalibration
Attributes:
- count_rates:`` dict[float, nerea.CountRate]``
The count rates associated with the calibration. key is the control rod height and value is the associated ount rate.
- critical_height:`` float``
the critical control rod height.
- name:`` int``
metadata for control rod identification.
- get_reactivity_curve(delayed_data, dtc_kwargs={}, ap_kwargs={}, visual=False, savefig='')[source]
” nerea.IntegralNoCompensation.get_reactivity_curve() —————————————————– Computes the integral reacitivty curve dr/dh for measurement without compensation.
- Parameters:
**delayed_data** (
nerea.EffectiveDelayedParams) – path to the Serpent res.m output file to read effective delayed neutron data from.**dtc_kwargs** (
dict, optional) – kwargs for nerea.CountRate.dead_time_corrected. Default is{}.**ap_kwargs** (
dict, optional) – kwargs for nerea.CountRate.asymptotic_period. Default is{}.**visual** (
bool, optional) – Whether to plot the processed data. Default is False.**savefig** (
str, optional) – File name to save the plotted data to. Default is ‘’ for no plotting.delayed_data (EffectiveDelayedParams)
dtc_kwargs (dict)
ap_kwargs (dict)
visual (bool)
savefig (str)
- Return type:
pd.DataFrame
Note
alias for
self._get_rhos.
- Parameters:
count_rates (dict[float, CountRate])
critical_height (float)
name (int)
- class nerea.control_rod.DifferentialCompensation(count_rates, critical_height, name)[source]
Bases:
ControlRodCalibrationnerea.DifferentialCompensation
Class for differential control rod calibration with compensation. Inherits from nerea.ControlRodCalibration
- \*\*count_rates**
The count rates associated with the calibration. key is the control rod height and value is the associated ount rate.
- Type:
dict[float, nerea.CountRate]
- \*\*critical_height**
the critical control rod height.
- Type:
float
- \*\*name**
metadata for control rod identification.
- Type:
int
- get_reactivity_curve(delayed_data, dtc_kwargs={}, ap_kwargs={}, visual=False, savefig='')[source]
” nerea.DifferentialCompensation.get_reactivity_curve() ——————————————————- Computes the differential reacitivty curve dr/dh for measurements with compensation.
- Parameters:
**delayed_data** (nerea.E`ffectiveDelayedParams`) – path to the Serpent res.m output file to read effective delayed neutron data from.
**dtc_kwargs** (
dict, optional) – kwargs for nerea.CountRate.dead_time_corrected. Default is {}.**ap_kwargs** (
dict, optional) – kwargs for nerea.CountRate.asymptotic_period. Default is {}.**visual** (
bool, optional) – Whether to plot the processed data. Default is False.**savefig** (
str, optional) – File name to save the plotted data to. Default is ‘’ for no plotting.delayed_data (EffectiveDelayedParams)
dtc_kwargs (dict)
ap_kwargs (dict)
visual (bool)
savefig (str)
- Return type:
pd.DataFrame
- Parameters:
count_rates (dict[float, CountRate])
critical_height (float)
name (int)
- class nerea.control_rod.IntegralCompensation(count_rates, critical_height, name)[source]
Bases:
ControlRodCalibrationnerea.IntegralCompensation
Class for integral control rod calibration with compensation. Inherits from nerea.ControlRodCalibration
- \*\*count_rates**
The count rates associated with the calibration. key is the control rod height and value is the associated ount rate.
- Type:
dict[float, nerea.CountRate]
- \*\*critical_height**
the critical control rod height.
- Type:
float
- \*\*name**
metadata for control rod identification.
- Type:
int
- get_reactivity_curve(delayed_data, dtc_kwargs={}, ap_kwargs={}, visual=False, savefig='')[source]
” nerea.IntegralCompensation.get_reactivity_curve() ————————————————— Computes the integral reacitivty curve dr/dh for measurement with compensation.
- Parameters:
**delayed_data** (
nerea.EffectiveDelayedParams) – path to the Serpent res.m output file to read effective delayed neutron data from.**dtc_kwargs** (
dict, optional) – kwargs for nerea.CountRate.dead_time_corrected. Default is{}.**ap_kwargs** (
dict, optional) – kwargs for nerea.CountRate.asymptotic_period. Default is{}.**visual** (
bool, optional) – Whether to plot the processed data. Default isFalse.**savefig** (
str, optional) – File name to save the plotted data to. Default is ‘’ for no plotting.delayed_data (EffectiveDelayedParams)
dtc_kwargs (dict)
ap_kwargs (dict)
visual (bool)
savefig (str)
- Return type:
pd.DataFrame
Note
alias for
self._get_rhos.
- Parameters:
count_rates (dict[float, CountRate])
critical_height (float)
name (int)
- nerea.control_rod.evaluate_integral_differential_cr(x, order, coef, coef_cov)[source]
Integrates a polynomial.
- Parameters:
x (float) – The point whereto evaluate the integral.
order (int) – Polynomial order to integrate
coef (Iterable[float]) – Polynomial coefficients.
coef_cov (Iterable[Iterable[float]]) – Polynomial coefficients covariance matrix.
Returns
-------- – pd.DataFrame
Notes
------
rods. (Used for differential control)
- Return type:
DataFrame
- nerea.control_rod.evaluate_integral_integral_cr(x, order, coef, coef_cov)[source]
Evaluates a olynomial.
- Parameters:
x (float) – The point where to evaluate the integral.
order (int) – Polynomial order to integrate
coef (Iterable[float]) – Polynomial coefficients.
coef_cov (Iterable[Iterable[float]]) – Polynomial coefficients covariance matrix.
Returns
-------- – pd.DataFrame
Notes
------
rods. (Used for integral control)
- Return type:
DataFrame
nerea.count_rate module
- class nerea.count_rate.CountRate(data, start_time, campaign_id, experiment_id, detector_id, deposit_id, timebase=1.0, _dead_time_corrected=False, _vlines=<factory>)[source]
Bases:
objectnerea.CountRateClass storing and processing count rate data acquired as a function of time.
- \*\*data**
the count rate as a function of time data.
- Type:
pd.DataFrame
- \*\*start_time**
acquisition start time.
- Type:
datetime
- \*\*campaign_id**
metadatada for experimental campaign identification.
- Type:
str
- \*\*experiment_id**
metadata for experiment identification
- Type:
str
- \*\*detector_id**
metadata for detector identification
- Type:
int|str
- \*\*deposit_id**
metadata for deposit identification
- Type:
str
- \*\*timebase**
acquisition timebase in seconds. Default is
1.0.- Type:
float, optional
- _dead_time_corrected
flag labelling whether the count rates have been corrected for dead time. Handled internally. Default is
False.- Type:
bool, optional
- _vlines
lines to draw plotting. Handled internally. Default is
[].- Type:
Iterable[datetime], optional
- data: DataFrame
- start_time: datetime
- campaign_id: str
- experiment_id: str
- detector_id: str
- deposit_id: str
- timebase: float
- average(start_time, duration)[source]
nerea.CountRate.average()
Calculates the average value and uncertainty of time series data within a specified duration.
- param **start_time**:
The starting time for the data to be analyzed.
- type **start_time**:
datetime.datetime- param **duration**:
The length of time in seconds for which the average is calculated.
- type **duration**:
float- returns:
data frame containing average ‘value’ and ‘uncertainty’ columns.
- rtype:
pd.DataFrame
Notes
uncertainty computed assuming Poisson distribution: 1/sqrt(value)
Examples
>>> from datetime import datetime >>> data = pd.DataFrame({'Time': pd.date_range('2021-01-01', periods=100, freq='S'), 'value': np.random.rand(100)}) >>> pm = CountRate(data=data, start_time=datetime(2021, 1, 1), campaign_id='C1', experiment_id='E1', detector_id='M1') >>> avg_df = pm.average(datetime(2021, 1, 1, 0, 0, 30), 10) >>> print(avg_df)
- Parameters:
start_time (datetime)
duration (float)
- Return type:
DataFrame
- smooth(**kwargs)[source]
nerea.CountRate.smooth()
Smooths the count rate data to ease feature recognition.
- param **kwargs:
- param Argumnents for
nerea.functions.smoothing(): renormalize (
bool): Whether to renormalize the data.smoothing_method (
str): The mehtod to implement for smoothing.arguments for the chosen
nerea.functions.smoothing.
- returns:
data frame with time and counts columns.
- rtype:
pd.DataFrame
Notes
- Allowed methods are
'moving_average'(requireswindow)'ewm''savgol_filter'(requireswindow_length,polyorder)'fit'``(requires ``ch_before_max,order)
- Return type:
Self
- integrate(timebase, start_time=None)[source]
nerea.CountRate.integrate()
Integrates data over a specified timebase starting from a given start time.
- param **timebase**:
The interval of time in seconds over which to calculate the average. This interval is used to group the data for averaging.
- type **timebase**:
int- param **start_time**:
The starting time for the integration process. Default is
self.start_time.- type **start_time**:
datetime, optional- returns:
data frame containing average ‘value’ and ‘uncertainty’ columns.
- rtype:
pd.DataFrame
Notes
uncertainty computed assuming Poisson distribution: 1/sqrt(value)
Examples
>>> from datetime import datetime >>> data = pd.DataFrame({'Time': pd.date_range('2021-01-01', periods=100, freq='S'), 'value': np.random.rand(100)}) >>> pm = CountRate(data=data, start_time=datetime(2021, 1, 1), campaign_id='C1', experiment_id='E1', detector_id='M1') >>> integrated_df = pm.integrate(10) >>> print(integrated_df)
- Parameters:
timebase (int)
start_time (datetime | None)
- Return type:
DataFrame
- plateau(sigma=2, timebase=10)[source]
nerea.CountRate.plateau()
The plateau with the largest integral counts in the detector.
- param **sigma**:
the amount of standard deviations to consider for the uncertainty on the plateau. Defaults to
2.- type **sigma**:
int, optional- param **timebase**:
the time base for integration in plateau search in seconds. Defaults to
10s.- type **timebase**:
int, optional- returns:
with
'Time'and'value'columns.- rtype:
pd.DataFrame
- Parameters:
sigma (int)
timebase (int)
- Return type:
DataFrame
- per_unit_power(monitor, **kwargs)[source]
nerea.CountRate.per_unit_power()
Normalizes the count rate to a power monitor.
- param **monitor**:
The power monitor for the count rate normalization.
- type **monitor**:
nerea.CountRate- param **kwargs:
arguments for
self.plateau(). - sigma (int): standard deviations for plateau finding. - timebase (int): integration timebase in seconds.- returns:
with
'value'and'uncertainty'columns.- rtype:
pd.DataFrame
- Parameters:
monitor (Self)
- Return type:
DataFrame
- per_unit_time_power(monitor, *args, **kwargs)[source]
nerea.CountRate.per_unit_time_power()
Normalizes the count rate to a power monitor and gives the conunt rate per unit power.
- param monitor:
The power monitor for the count rate normalization.
- type monitor:
CountRate
- param **monitor**:
The power monitor for the count rate normalization.
- type **monitor**:
nerea.CountRate- param **kwargs:
arguments for
self.plateau(). - sigma (int): standard deviations for plateau finding. - timebase (int): integration timebase in seconds.- returns:
with
'value'and'uncertainty'columns.- rtype:
pd.DataFrame
- Parameters:
monitor (Self)
- Return type:
DataFrame
- dead_time_corrected(tau_p=8.8e-08, tau_np=1.08e-07)[source]
nerea.CountRate.dead_time_corrected()
Apply dead time correction to the count rate data.
- param **tau_p**:
paralizable dead time constant. Defaults to
88e-9.- type **tau_p**:
float, optional- param **tau_np**:
non-paralizable dead time constant. Defaults to
108e-9.- type **tau_np**:
float, optional- returns:
instance with dead time corrected data.
- rtype:
nerea.CountRate
- Parameters:
tau_p (float)
tau_np (float)
- Return type:
Self
- cut(start, end)[source]
nerea.CountRate.cut()
Cuts count rate data from a set start to an end.
- param **start**:
start time of the new nerea.CountRate.
- type **start**:
datetime- param **end**:
end time of the new nerea.CountRate.
- type **end**:
datetime- returns:
instance with truncated data.
- rtype:
nerea.CountRate
Notes
Left boundary included, right boundary excluded.
- Parameters:
start (datetime)
end (datetime)
- Return type:
Self
- get_asymptotic_period(scan_dt=0.0, scan_dt0=20.0, scan_tol=0.01, log=True)[source]
nerea.CountRate.get_asymptotic_period()
Calculats the reactor period from a CountRate instance.
- param **scan_dt**:
time delta to evaluate asymptotic convergence. In seconds. Default is
0.for no scan.- type **scan_dt**:
float, optional- param **scan_dt0**:
seconds to skip from last: buffer time to have a reasonable period estimate to converge to. In seconds. Default is
20..- type **scan_dt0**:
float, optional- param **scan_tol**:
tolerance to evaluate asymptotic convergence. Relative. Default is
1e-2.- type **scan_tol**:
float, optional- param **log**:
flag to log fit R^2. Default is
True.- type **log**:
bool, optional- returns:
with reactor asymptotic period value and uncertainty.
- rtype:
pd.DataFrame
Note
The scan is performed backwards, starting from the later time in
self-scan_dt0. time spacing is defined byscan_dtand tolerance byscan_tol.- Parameters:
scan_dt (float)
scan_dt0 (float)
scan_tol (float)
log (bool)
- Return type:
DataFrame
- get_reactivity(delayed_data, ap_kwargs={})[source]
nerea.CountRate.get_reactivity()
Calculates the reactor reactivity based on the Count Rate-estimated reactor period and on effective nuclear data computed by Serpent.
- param **delayed_data**:
effective delayed neutron paramters to use for reactivity calculation.
- type **delayed_data**:
nerea.EffectiveDelayedParams- returns:
data frame with
'value'and'uncertainty'columns.- rtype:
pd.DataFrame
- Parameters:
delayed_data (EffectiveDelayedParams)
ap_kwargs (dict)
- Return type:
DataFrame
- plot(start_time=None, duration=None, experiment_time=False, ax=None, c='k', **kwargs)[source]
nerea.CountRate.plot()
Plot data in this CountRate instance.
- param **start_time**:
The time the count rate is considered from. Default is
Nonefor first acquisition time.- type **start_time**:
datetime.datetime, optional- param **duration**:
The time-span the count rate is considered for. Default is
Nonefor until last acquisition time.- type **duration**:
int, optional- param **ax**:
The ax where the plot is drawn. Defauls is
Nonefor a new axes.- type **ax**:
plt.Axes, optional- param **c**:
The color of the plotted seriese. Default is
'k'.- type **c**:
str, optional- param **kwargs:
Additional arguments for
pd.DataFrame.plot()- returns:
with the plotted data.
- rtype:
plt.Axes
- Parameters:
start_time (datetime)
duration (int)
experiment_time (bool)
ax (Axes)
c (str)
- Return type:
Axes
- classmethod from_ascii(file, filetype='infer', **kwargs)[source]
nerea.CountRate.from_ascii()
Method to create a
nerea.CountRateinstance from an ASCII file.- param **file**:
Path to the ASCII file.
- type **file**:
str- param **filetype**:
Type of ASCII file to process. Default is
'infer'to infer it from file extension.- type **filetype**:
str, optional- param **kwargs:
additional arguments for class creation deposit_id (
str): metadata for detector deposit detector_id (str): metadata for detector identification experiment_id (str): metadata for experiment identification campaign_id (str): metadata for experimental campaign identification.- returns:
A new
CountRateinstance.- rtype:
nerea.CountRate
- Parameters:
file (str)
filetype (str)
- Return type:
Self
- classmethod from_files(files, filetype='infer', **kwargs)[source]
nerea.CountRate.from_files()
Method to create a
nerea.CountRateinstance joing data from ASCII files of the same type.- param **file**:
Path to the ASCII file.
- type **file**:
str- param **filetype**:
Type of ASCII file to process. Default is
'infer'to infer it from file extension.- type **filetype**:
str, optional- param **kwargs:
additional arguments for class creation deposit_id (
str): metadata for detector deposit detector_id (str): metadata for detector identification experiment_id (str): metadata for experiment identification campaign_id (str): metadata for experimental campaign identification.- returns:
A new
CountRateinstance.- rtype:
nerea.CountRate
- Parameters:
files (Iterable[str])
filetype (str)
- Return type:
Self
- Parameters:
data (DataFrame)
start_time (datetime)
campaign_id (str)
experiment_id (str)
detector_id (str)
deposit_id (str)
timebase (float)
_dead_time_corrected (bool)
_vlines (Iterable[datetime])
- class nerea.count_rate.CountRates(detectors, _enable_checks=True)[source]
Bases:
objectnerea.CountRatesClass storing and processing count rate data acquired as a function of time. Stores data of many detectors/acquisitions.
- \*\*detectors**
Links detector id and its conunt rate.
keyis the id andvaluethe count rate.- Type:
dict[int, nerea.CountRate]
- _enable_checks
flag to enable consistency checks. Default is
True.- Type:
bool, optional
- property campaign_id: str
nerea.CountRates.campaign_id()
Campaign id of the first count rate in
self.detectors.- returns:
the campaign id of the first detector.
- rtype:
str
- property experiment_id: str | int
nerea.CountRates.experiment_id()
Experiment id of the first count rate in
self.detectors.- returns:
the campaign id of the first detector.
- rtype:
str
- property deposit_id: str
nerea.CountRates.deposit_id()
The deposit id of the first element of self.detectors.
- returns:
the deposit id of the first detector.
- rtype:
str
- property best: CountRate
nerea.CountRates.best()
Returns the count rate with the highest sum value.
- returns:
Count rate with the highest integral count.
- rtype:
nerea.CountRate
- per_unit_power(monitor, **kwargs)[source]
nerea.CountRates.per_unit_power()
Normalizes the raction rate to a power monitor.
- param **monitor**:
The ID of the count rate to be used as power monitor for the count rate normalization.
- type **monitor**:
int- param **kwargs:
arguments for
CountRate.plateau(). - sigma (int): standard deviations for plateau finding. - timebase (int): integration timebase in seconds.- returns:
with value and uncertainty of the normalized count rate integrated over time. Keys are the detector IDs as in self.detectors.
- rtype:
dict[int, pd.DataFrame]
- Parameters:
monitor (int)
- Return type:
dict[int, DataFrame]
- per_unit_time_power(monitor, **kwargs)[source]
nerea.CountRates.per_unit_time_power()
Normalizes the raction rate to a power monitor and takes the average over time.
- param **monitor**:
The ID of the count rate to be used as power monitor for the count rate normalization.
- type **monitor**:
int- param **kwargs:
arguments for
CountRate.plateau(). - sigma (int): standard deviations for plateau finding. - timebase (int): integration timebase in seconds.- returns:
with value and uncertainty of the normalized count rate averaged over time. Keys are the detector IDs as in self.detectors.
- rtype:
dict[int, pd.DataFrame]
- Parameters:
monitor (int)
- Return type:
dict[int, DataFrame]
- classmethod from_ascii(files, filetypes='infer', **kwargs)[source]
nerea.CountRates.from_ascii()
Creates an instance of
nerea.CountRatesusing data extracted from an ASCII file.The ASCII file should contain columns of data including timestamps and power readings.
The filename is supposed to be formatted as: {Campaign}_{experiment} (ADS) or {Campaign}_{experiment}_{detector} (PHSPA)
- param **files**:
Maps each file to the detectors to read there and the corresponding deposit id.
- key:
str Path to the ASCII files containing the power monitor data.
- key:
- values:
tuple - first:
Iterable[str]|Iterable[int] detector ids for ADS files or
Nonefor PHSPA file (detector id inferred from filename)- second:
Iterable[str] deposit ids
- first:
- values:
- type **files**:
dict[str, tuple[Iterable[str]|Iterable[int]|None, Iterable[str]]]- param **filetype**:
Type of ASCII file to process. Default is
'infer'to infer it from file extension for each file.- type **filetype**:
Iterable[str], optional- param **kwargs:
additional arguments for class creation _enable_checks (
bool): enables consistency checks among detectors- returns:
initialized with the data from the ASCII file.
- rtype:
nerea.CountRates
Note
allows only for formatted source files.
- ADS files requires detectors to be passed as an iterable
in the same order as the ADS processed files.
- Parameters:
files (dict[str, tuple[Iterable[str] | Iterable[int] | None, Iterable[str]]])
filetypes (Iterable[str])
- Return type:
Self
- Parameters:
detectors (dict[int | str, CountRate])
_enable_checks (bool)
nerea.defaults module
nerea.effective_mass module
- class nerea.effective_mass.EffectiveMass(deposit_id, detector_id, data, bins, composition=None)[source]
Bases:
objectnerea.EffectiveMassClass storing effective mass data from fission chamber calibration.
- \*\*deposit_id**
metadata for fission chamber deposit.
- Type:
str,
- \*\*detector_id**
metadata for detector identification.
- Type:
str
- \*\*data**
effective mass data.
- Type:
pd.DataFrame
- \*\*bins**
number of acquisition bins used in the calibration acquisition.
- Type:
int
- \*\*composition**
a nerea-formatted data frame with the fission chamber composition value and uncertainty. Default is
Nonefor monoisotopic chambers.- Type:
pd.DataFrame, optional
- deposit_id: str
- detector_id: str
- data: DataFrame
- bins: int
- composition: DataFrame
- property composition_: DataFrame
nerea.EffectiveMass.composition_()
The material composition of the fission chamber.
- returns:
the material composition nuclide by nuclide (index) with
'value'and'uncertainty'columns.- rtype:
pd.DataFrame
- property R_channel: int
nerea.EffectiveMass.R_channel()
Calculates the channel where half maximum of the pulse height spectrum was found during the calibration.
- returns:
The channel of the calibration half maximum.
- rtype:
int
- property integral: DataFrame
nerea.EffectiveMass.integral()
Computes the EffectiveMass values. Alias for self.data.
Note
alias for
self.data
- to_xlsx(file_path)[source]
nerea.EffectiveMass.to_xslx()
Writes the effective mass to a formatted excel file.
- param **file**:
the file name to write the instance to.
- type **file**:
str- rtype:
None
Note
for nerea read/write performance, filename should be {Deposit}_{Detector}.xlsx
Example
>>> em = EffectiveMass.from_xlsx(file_path) >>> em.to_xlsx(file_path1)
- Parameters:
file_path (str)
- Return type:
None
- classmethod from_xlsx(file)[source]
nerea.EffectiveMass.from_xlsx()
Reads data from an Excel file and extracts deposit and detector ID from the file name. The filename is expected to be formatted as: {Deposit}_{Detector}.xlsx
- param **file**:
File path of an Excel file containing the effective mass data.
- type **file**:
str- returns:
Effective mass instance.
- rtype:
nerea.EffectiveMass
Examples
>>> eff_mass = EffectiveMass.from_xlsx('filename.xlsx')
- Parameters:
file (str)
- Return type:
Self
- Parameters:
deposit_id (str)
detector_id (str)
data (DataFrame)
bins (int)
composition (DataFrame)
nerea.experimental module
- class nerea.experimental.NormalizedPulseHeightSpectrum(phs, effective_mass, power_monitor, _enable_checks=True)[source]
Bases:
_Experimentalnerea.NormalizedPulseHeightSpectrumClass storing and processing the pulse height spectrum (PHS) normalization per unit mass, power and time. Inherits from
nerea.Experimental.- \*\*phs**
the pulse height spectrum to normalize.
- Type:
nerea.PulseHeightSpectrum
- \*\*effective_mass**
the effective mass of the fission chamber used to acquire the PHS.
- Type:
nerea.EffectiveMass
- \*\*power_monitor**
the power monitor of the PHS acquisition.
- Type:
nerea.CountRate
- _enable_checks
flag enabling consistency checks. Default is
True.- Type:
bool, optoinal
- phs: PulseHeightSpectrum
- effective_mass: EffectiveMass
- property measurement_id: str
nerea.NormalizedPulseHeightSpectrum.measurement_id()The measurement ID associated with the pulse height spectrum.
- returns:
The measurement ID attribute of the associated PHS.
- rtype:
str
- property campaign_id: str
nerea.NormalizedPulseHeightSpectrum.campaign_id()The campaign ID associated with the pulse height spectrum.
- returns:
The campaign ID attribute of the associated PHS.
- rtype:
str
- property experiment_id: str
nerea.NormalizedPulseHeightSpectrum.experiment_id()The experiment ID associated with the pulse height spectrum.
- returns:
The experiment ID attribute of the associated PHS.
- rtype:
str
- property location_id: str
nerea.NormalizedPulseHeightSpectrum.location_id()The location ID associated with the pulse height spectrum.
- returns:
The location ID attribute of the associated PHS.
- rtype:
str
- property deposit_id: str
nerea.NormalizedPulseHeightSpectrum.deposit_id()The deposit ID associated with the pulse height spectrum.
- returns:
The deposit ID attribute of the associated PHS.
- rtype:
str
- per_unit_mass(**kwargs)[source]
nerea.NormalizedPulseHeightSpectrum.per_unit_mass()Normalizes
self.pulse_height_spectrum()to theself.effective_massbased on the effective mass discrimination levels.- param **kwargs:
- param arguments for
self.pulse_height_spectrum.integrate(): - param - llds (
Iterable[int|float] | int) low level discriminator(s).: - param - r (
bool): - type - r (
bool): whether discriminators are absolute or fractions of R.
- param - raw_integral (
bool): - type - raw_integral (
bool): whether to integrate the raw data or the smoothed ones.
- param additional arguments for:
- param -
self.pulse_height_spectrum.rebin(): bins (
int): number of binssmooth (
bool): whether to smooth the PHS
- param -
self.pulse_height_spectrum.smooth()only ifsmooth == True: renormalize (
bool): Whether to renormalize the smoothed spectrum.smoothing_method (
str): The mehtod to implement for smoothing.arguments for the chosen
nerea.functions.smoothing.
- param -
self.pulse_height_spectrum.get_max(): fst_ch (
int | str): channel to start max search or max search method.
- returns:
with information of the mass-normalized spectrum.
- rtype:
pd.DataFrame
Note
bins for PHS rebinning are set to self.effective_mass.bins.
- Return type:
DataFrame
- per_unit_mass_and_time(**kwargs)[source]
nerea.NormalizedPulseHeightSpectrum.per_unit_mass_and_time()The integrated PHS normalized per unit mass and time.
- param **kwargs:
- param arguments for
self.per_unit_mass(): - param - llds (
Iterable[int|float] | int) low level discriminator(s).: - param - r (
bool): - type - r (
bool): whether discriminators are absolute or fractions of R.
- param - raw_integral (
bool): - type - raw_integral (
bool): whether to integrate the raw data or the smoothed ones.
- param additional arguments for:
- param -
self.pulse_height_spectrum.rebin(): bins (
int): number of binssmooth (
bool): whether to smooth the PHS
- param -
self.pulse_height_spectrum.smooth()only ifsmooth == True: renormalize (
bool): Whether to renormalize the smoothed spectrum.smoothing_method (
str): The mehtod to implement for smoothing.arguments for the chosen
nerea.functions.smoothing.
- param -
self.pulse_height_spectrum.get_max(): fst_ch (
int | str): channel to start max search or max search method.
- returns:
DataFrame with the information of the mass- and time- normalized spectrum.
- rtype:
pd.DataFrame
Note
bins for PHS rebinning are set to self.effective_mass.bins.
- Return type:
DataFrame
- per_unit_mass_and_power(**kwargs)[source]
nerea.NormalizedPulseHeightSpectrum.per_unit_mass_and_power()The integrated PHS normalized per unit mass and power.
- param **kwargs:
- param arguments for
self.per_unit_mass(): - param - llds (
Iterable[int|float] | int) low level discriminator(s).: - param - r (
bool): - type - r (
bool): whether discriminators are absolute or fractions of R.
- param - raw_integral (
bool): - type - raw_integral (
bool): whether to integrate the raw data or the smoothed ones.
- param additional arguments for:
- param -
self.pulse_height_spectrum.rebin(): bins (
int): number of binssmooth (
bool): whether to smooth the PHS
- param -
self.pulse_height_spectrum.smooth()only ifsmooth == True: renormalize (
bool): Whether to renormalize the smoothed spectrum.smoothing_method (
str): The mehtod to implement for smoothing.arguments for the chosen
nerea.functions.smoothing.
- param -
self.pulse_height_spectrum.get_max(): fst_ch (
int | str): channel to start max search or max search method.
- returns:
with information of the mass- and power- normalized spectrum.
- rtype:
pd.DataFrame
Note
bins for PHS rebinning are set to self.effective_mass.bins.
- Return type:
DataFrame
- per_unit_power_and_time(**kwargs)[source]
nerea.NormalizedPulseHeightSpectrum.per_unit_power_and_time()The integrated PHS normalized per unit power and time.
- param **kwargs:
- param arguments for
self.per_unit_mass(): - param - llds (
Iterable[int|float] | int) low level discriminator(s).: - param - r (
bool): - type - r (
bool): whether discriminators are absolute or fractions of R.
- param - raw_integral (
bool): - type - raw_integral (
bool): whether to integrate the raw data or the smoothed ones.
- param additional arguments for:
- param -
self.pulse_height_spectrum.rebin(): bins (
int): number of binssmooth (
bool): whether to smooth the PHS
- param -
self.pulse_height_spectrum.smooth()only ifsmooth == True: renormalize (
bool): Whether to renormalize the smoothed spectrum.smoothing_method (
str): The mehtod to implement for smoothing.arguments for the chosen
nerea.functions.smoothing.
- param -
self.pulse_height_spectrum.get_max(): fst_ch (
int | str): channel to start max search or max search method.
- returns:
with information of the power- and time- normalized spectrum.
- rtype:
pd.DataFrame
- Return type:
DataFrame
- plateau(int_tolerance=0.01, ch_tolerance=0.01, **kwargs)[source]
nerea.NormalizedPulseHeightSpectrum.plateau()Computes the count rate per unit mass.
- param **int_tolerance**:
Tolerance for the integration check, by default
0.01.- type **int_tolerance**:
float, optional- param **ch_tolerance**:
Tolerance for the channel check, by default
0.01.- type **ch_tolerance**:
float, optional- param **kwargs:
- param arguments for
self.per_unit_mass(): - param - llds (
Iterable[int|float] | int) low level discriminator(s).: - param - r (
bool): - type - r (
bool): whether discriminators are absolute or fractions of R.
- param - raw_integral (
bool): - type - raw_integral (
bool): whether to integrate the raw data or the smoothed ones.
- param additional arguments for:
- param -
self.pulse_height_spectrum.rebin(): bins (
int): number of binssmooth (
bool): whether to smooth the PHS
- param -
self.pulse_height_spectrum.smooth()only ifsmooth == True: renormalize (
bool): Whether to renormalize the smoothed spectrum.smoothing_method (
str): The mehtod to implement for smoothing.arguments for the chosen
nerea.functions.smoothing.
- param -
self.pulse_height_spectrum.get_max(): fst_ch (
int | str): channel to start max search or max search method.
- returns:
containing the count rate per unit mass at convergence. It has
'value'and'uncertainty'columns.- rtype:
pd.DataFrame- raises ValueError:
If the channel values differ beyond the specified tolerance.
- Parameters:
int_tolerance (float)
ch_tolerance (float)
- Return type:
DataFrame
- process(long_output=False, visual=False, savefig='', **kwargs)[source]
nerea.NormalizedPulseHeightSpectrum.process()Computes the count rate.
- param **long_output**:
Flag to turn on/off the full output information, whcih includes values and variances of all the processing elements,
Falseby default.- type **long_output**:
bool, optional- param **visual**:
Flag to display the processed data. Default is
False.- type **visual**:
bool, optional- param **savefig**:
Filename to save the figure to. Default is
''not saving.- type **savefig**:
str, optional- param **kwargs:
- param arguments for
self.plateau(): - param - int_tolerance (
float): - type - int_tolerance (
float): tolerance for integration check.
- param - ch_tolerance (
float): - type - ch_tolerance (
float): tolerance for channel check.
- param additional arguments for:
- param -
self.pulse_height_spectrum.integrate(): llds (
Iterable[int|float] | int) low level discriminator(s).r (
bool): whether discriminators are absolute or fractions of R.raw_integral (
bool): whether to integrate the raw data or the smoothed ones.
- param -
self.pulse_height_spectrum.rebin(): bins (
int): number of binssmooth (
bool): whether to smooth the PHS
- param -
self.pulse_height_spectrum.smooth()only ifsmooth == True: renormalize (
bool): Whether to renormalize the smoothed spectrum.smoothing_method (
str): The mehtod to implement for smoothing.arguments for the chosen
nerea.functions.smoothing.
- param -
self.pulse_height_spectrum.get_max(): fst_ch (
int | str): channel to start max search or max search method.
- returns:
containing the count rate per unint mass and power. It has
'value'and'uncertainty'columns.- rtype:
pd.DataFrame
Note
bins for PHS rebinning are set to self.effective_mass.bins.
Examples
>>> ffs = PulseHeightSpectrum(data=pd.DataFrame({'value': [1.0, 2.0, 3.0], 'uncertainty': [0.1, 0.2, 0.3]}), ... detector_id='D1', deposit_id='Dep1', experiment_id='Exp1') >>> em = EffectiveMass(data=pd.DataFrame({'value': [0.5, 0.6, 0.7], 'uncertainty': [0.05, 0.06, 0.07]}), ... detector_id='D1', deposit_id='Dep1') >>> pm = CountRate(data=pd.DataFrame({'value': [10, 20, 30], 'uncertainty': [1, 2, 3]}), experiment_id='Exp1') >>> rr = NormalizedPulseHeightSpectrum(pulse_height_spectrum=ffs, effective_mass=em, power_monitor=pm) >>> rr.process() value uncertainty 0 35.6 2.449490
- Parameters:
long_output (bool)
visual (bool)
savefig (str)
- Return type:
DataFrame
- plot(discri=None, **kwargs)[source]
nerea.NormalizedPulseHeightSpectrum.plot()
Default plotting method of PHS and monitor considered. It also reports tabulated effective mass values.
Paramters
- discri:
int, optional The discrimination level to highilight in the plots. It is in units of channel of self.pulse_height_spectrum. Default is None.
**kwargs arguments for
self.per_unit_mass(),self.pulse_height_spectrum.integrate()andself.pulse_height_spectrum.plot().- -
self.per_unit_mass() llds (
Iterable[int|float] | int) low level discriminator(s).r (
bool): whether discriminators are absolute or fractions of R.raw_integral (
bool): whether to integrate the raw data or the smoothed ones.
self.pulse_height_spectrum.rebin()bins (
int): number of binssmooth (
bool): whether to smooth the PHS
self.pulse_height_spectrum.smooth()only ifsmooth == Truerenormalize (
bool): Whether to renormalize the smoothed spectrum.smoothing_method (
str): The mehtod to implement for smoothing.arguments for the chosen
nerea.functions.smoothing.
self.pulse_height_spectrum.get_max()fst_ch (
int | str): channel to start max search or max search method.
- rtype:
tuple[plt.Figure, Iterable[plt.Axes]]
- Parameters:
discri (int)
- Return type:
tuple[Figure, Iterable[Axes]]
- discri:
- Parameters:
phs (PulseHeightSpectrum)
effective_mass (EffectiveMass)
power_monitor (CountRate)
_enable_checks (bool)
- class nerea.experimental.SpectralIndex(numerator, denominator, _enable_checks=True)[source]
Bases:
_Experimentalnerea.SpectralIndexClass storing and processing a spectral index. Inherits from
nerea.Experimental.- \*\*numerator**
the spectral index numerator.
- Type:
nerea.NormalizedPulseHeightSpectrum
- \*\*denominator**
the spectral index denominator.
- Type:
nerea.NormalizedPulseHeightSpectrum
- _enable_checks
flag enabling consistency checks. Default is
True.- Type:
bool, optoinal
- numerator: NormalizedPulseHeightSpectrum
- denominator: NormalizedPulseHeightSpectrum
- property deposit_ids: list[str]
nerea.SpectralIndex.deposit_ids()
The deposit IDs associated with the numerator and denominator.
- returns:
A list containing the deposit IDs of the numerator and denominator.
- rtype:
list[str]
Examples
>>> from nerea.CountRate import CountRate >>> ffs_num = CountRate(..., deposit_id='Dep1') >>> ffs_den = CountRate(..., deposit_id='Dep2') >>> spectral_index = SpectralIndex(numerator=ffs_num, denominator=ffs_den) >>> spectral_index.deposit_ids ['Dep1', 'Dep2']
- process(one_g_xs=None, one_g_xs_file=None, nuc_dec_from_file=None, numerator_kwargs={}, denominator_kwargs={}, mass_normalized=False)[source]
nerea.SpectralIndex.process()
Computes the ratio of two count rates.
- param **one_g_xs**:
with nuclides and one group cross sections as. Defaults to
Nonefor no correction.- type **one_g_xs**:
nerea.Xs, optional- param **one_g_xs_file**:
the Serpent detector file to read the one group xs from. Default is
None.- type **one_g_xs_file**:
str, optional- param **nuc_dec_from_file**:
A dictionary mapping each nuclide with the detector associated with its cross section calculation in
one_g_xs_file.- type **nuc_dec_from_file**:
dict[str, str], optional- param **numerator_kwargs**:
Keyword arguments for self.numerator.process()
long_output (
bool): whetehr to output full informationvisual (
bool): whether to display the processed datasavefig (
str): filename to save the figure to.
additional arguments for
self.plateau()int_tolerance (
float): tolerance for integration check.ch_tolerance (
float): tolerance for channel check.
self.pulse_height_spectrum.integrate()llds (
Iterable[int|float] | int) low level discriminator(s).r (
bool): whether discriminators are absolute or fractions of R.raw_integral (
bool): whether to integrate the raw data or the smoothed ones.
self.pulse_height_spectrum.rebin()bins (
int): number of binssmooth (
bool): whether to smooth the PHS
self.pulse_height_spectrum.smooth()only ifsmooth == Truerenormalize (
bool): Whether to renormalize the smoothed spectrum.smoothing_method (
str): The mehtod to implement for smoothing.arguments for the chosen
nerea.functions.smoothing.
self.pulse_height_spectrum.get_max()fst_ch (
int | str): channel to start max search or max search method.
denominator_kwargs : dict[Any] Keyword arguments for self.denominator.process() - long_output (
bool): whetehr to output full information - visual (bool): whether to display the processed data - savefig (str): filename to save the figure to.additional arguments for
self.plateau()int_tolerance (
float): tolerance for integration check.ch_tolerance (
float): tolerance for channel check.
self.pulse_height_spectrum.integrate()llds (
Iterable[int|float] | int) low level discriminator(s).r (
bool): whether discriminators are absolute or fractions of R.raw_integral (
bool): whether to integrate the raw data or the smoothed ones.
self.pulse_height_spectrum.rebin()bins (
int): number of binssmooth (
bool): whether to smooth the PHS
self.pulse_height_spectrum.smooth()only ifsmooth == Truerenormalize (
bool): Whether to renormalize the smoothed spectrum.smoothing_method (
str): The mehtod to implement for smoothing.arguments for the chosen
nerea.functions.smoothing.
self.pulse_height_spectrum.get_max()fst_ch (
int | str): channel to start max search or max search method.
- type **numerator_kwargs**:
dict[Any]
- param **mass_normalized**:
defines whether the result is the ratio of fission rates or of fission rates per unit mass. Default is
False.- type **mass_normalized**:
bool, optional- returns:
with
'value'and'uncertainty'columns.- rtype:
pd.DataFrame
Note
Working in the effective mass framework, it is assumed that all cross sections
for impurities are mass-normalized (nerea.Xs.normalized). Then the processed spectral index result is multiplied by the ratio between numerator and denominator atomic mass to be consistent with the definition of one-group cross section ratio. Else the
mass_normalizedargument should be used passing consistent one group cross sections for impurity correction.- Parameters:
one_g_xs (Xs)
one_g_xs_file (str)
nuc_dec_from_file (dict[str, str])
numerator_kwargs (dict)
denominator_kwargs (dict)
mass_normalized (bool)
- Return type:
DataFrame
- Parameters:
numerator (NormalizedPulseHeightSpectrum)
denominator (NormalizedPulseHeightSpectrum)
_enable_checks (bool)
- class nerea.experimental.Traverse(count_rates, _enable_checks=True)[source]
Bases:
_Experimentalnerea.TraverseClass storing and processing a traverse data. Inherits from nerea.Experimental.
- \*\*count_rates**
Links traverse position to the measured count rate.
keyis the position identifier,valueis the correspondingnerea.CountRateor nerea.CountRates``. Ifnerea.CountRates, the first is considered.- Type:
dict[str, CountRate | CountRates]
- _enable_checks
flag enabling consistency checks. Default is
True.- Type:
bool, optoinal
- count_rates: dict[str, CountRate | CountRates]
- property deposit_id: str
nerea.Traverse.deposit_id()The deposit id of the first count rate.
- rtype:
str
- process(monitors, normalization=None, visual=False, savefig='', palette='tab10', **kwargs)[source]
nerea.Traverse.process()Normalizes all the count rates to the power in
monitorsand to the maximum value.- param **monitors**:
ordered information on the power normalization. Should be
nerea.CountRatewhen mapped to anerea.CountRateand int when mapped tonerea.CountRates. The normalization is passed toCountRate.per_unit_time_power()orCountRates.per_unit_time_power().- type **monitors**:
Iterable[CountRate | int]- param **normalization**:
The
self.count_ratesCountRate identifier to normalize the traveres to. Defaults toNone, normalizing to the one with the highest counts.- type **normalization**:
str, optional- param **visual**:
Plots the processed data. Default is
False.- type **visual**:
bool, optional- param **savefig**:
File name to save the plotted data to. Default is ‘’ for not saving.
- type **savefig**:
str, optional- param **palette**:
Color palette to use for plotting. Default is
'tab10'.- type **palette**:
str, optional- param **kwargs:
for nerea.CountRate.plateau().
sigma (
int): standard deviations for plateau findingtimebase (
int): time base for integration in plateau search.
- returns:
with
'value','uncertainty','uncertainty [%]'and'traverse'columns.- rtype:
pd.DataFrame
Note
Working with
nerea.CountRatesinstances, the first count rate is used.
- Parameters:
monitors (Iterable[CountRate | int])
normalization (int | str)
visual (bool)
savefig (str)
palette (str)
- Return type:
DataFrame
- plot(monitors, palette='tab10', **kwargs)[source]
nerea.Traverse.plot()Plot the data processed in Traverse.
- param **monitors**:
ordered information on the power normalization. Should be
nerea.CountRatewhen mapped to anerea.CountRateandintwhen mapped tonerea.CountRates. The normalization is passed toCountRate.per_unit_time_power()orCountRates.per_unit_time_power().- type **monitors**:
Iterable[CountRate | int]- param **palette**:
plt palette to use for plotting. Default is
'tab10'.- type **palette**:
str, optional- param **kwargs:
for nerea.CountRate.plateau(). - sigma (
int): standard deviations for plateau finding - timebase (int): time base for integration in plateau search.- rtype:
tuple[plt.Figure, Iterable[plt.Axes]]
- Parameters:
monitors (Iterable[CountRate | int])
palette (str)
- Return type:
tuple[Figure, Iterable[Axes]]
- Parameters:
count_rates (dict[str, CountRate | CountRates])
_enable_checks (bool)
nerea.functions module
- nerea.functions.fitting_polynomial(order)[source]
nerea.functions.fitting_polynomial()
Return a callable polynomial function of a given order for curve fitting.
This is typically used as a model function for fitting tools such as scipy.optimize.curve_fit. The returned function takes an independent variable x and a sequence of order + 1 coefficients, and computes:
P(x) = c₀·xⁿ + c₁·xⁿ⁻¹ + … + cₙ
- param **order**:
The order (degree) of the polynomial (n in the equation).
- type **order**:
int- returns:
A function that computes the polynomial value given
xand its coefficients.- rtype:
Callable[[float, \*float], float]- raises ValueError:
If the provided number of coefficients does not match
order + 1.
Notes
Returns a
scipy.curve_fit-suitable function.- Parameters:
order (int)
- Return type:
float
- nerea.functions.polynomial(order, c, x)[source]
nerea.functions.polynomial()
Evaluate a polynomial of a given order at a specific value.
- The polynomial is defined as:
P(x) = c₀·xⁿ + c₁·xⁿ⁻¹ + … + cₙ
- param **order**:
The order (degree) of the polynomial (n in the equation).
- type **order**:
int- param **c**:
Sequence of polynomial coefficients, with length order + 1. Coefficients are ordered from highest degree to constant term.
- type **c**:
Iterable[float]- param **x**:
The point at which to evaluate the polynomial.
- type **x**:
float- returns:
The computed polynomial value at
x.- rtype:
float- raises ValueError:
If the number of coefficients does not match order + 1.
Examples
>>> polynomial(2, [1, -3, 2], 5) 12.0 # computes 1 * 5² - 3 * 5 + 2
- Parameters:
order (int)
c (Iterable[float])
x (float)
- nerea.functions.get_fit_R2(y, fvec, weight=None)[source]
nerea.functions.get_fit_R2()
Calculates the R2 of a fit from the fitted points and the fitting line residuals.
Paramters
- y
Iterable[float] the fitted y points
- fvec
Iterable[float] residuals of the fitting line corresponding to those of y
- weight
Iterable[float], optional the weights for R2 weighting. Degaults to None, meaning w = 1
Returns:
floatthe fit R^2.
Notes
assumes y and fvec share x.
- Parameters:
y (Iterable[float])
fvec (Iterable[float])
weight (Iterable[float])
- Return type:
float
- y
- nerea.functions.polyfit(order, data)[source]
nerea.functions.polyfit()
Fits the data with a polynomial of chosen order.
- param **order**:
fitting polynomial order.
- type **order**:
int- param **data**:
- Dataframe with data to fit. Columns should be:
'x', abscissa'y', ordinate'u', y-uncertainty
- type **data**:
pd.DataFrame- param Returns:
- param ——–:
- param **coef**:
fit coefficients
- type **coef**:
np.array- param **coef_cov**:
fit coefficients covariance matrix
- type **coef_cov**:
np.array- param Notes:
- param ——:
- param - replaces NaN and negative or zero uncertianties with:
non-zero small values to allow fitting.
- Parameters:
order (int)
data (DataFrame)
- Return type:
tuple[array, array, Callable]
- nerea.functions.smoothing(data, smoothing_method='moving_average', renormalize=False, **kwargs)[source]
nerea.functions.smoothing()
Smooths the data in
data.- param **data**:
the data to smooth
- type **data**:
ps.Series- param **smoothing_method**:
- the method to use. Allowed options are:
'moving_average': (requires'window'kwarg)'ewm''savgol_filter': (requires'window_length','polyorder'kwargs)'fit': (requires'ch_before_max','order'kwargs)
Default is
"moving_average"- type **smoothing_method**:
str, optional- param **renormalize**:
whether the smoothed data shall be renormalized to the data integral.
- type **renormalize**:
bool, optional- param **kwargs:
additional arguments for the chosen method
- rtype:
pd.DataFrame
- Parameters:
data (Series)
smoothing_method (str)
renormalize (bool)
- Return type:
DataFrame
- nerea.functions.get_relative_array(a, den='')[source]
nerea.functions.get_relative_array()
Transforms composition array making it relative to its main component.
Paramters
- a
dict[str, float] | pd.DataFrame the array to make relative.
keyis the nuclide string identifier (e.g.,'U235'), andvalueis its array value. Has columns for its value and uncertainty.- den
str, optional flag to make the array relative to one entry
den. Default is''to normalize to the maximum.
- rtype:
pd.DataFrame
- Parameters:
a (dict[str, float] | DataFrame)
den (str)
- Return type:
DataFrame
- a
- nerea.functions.impurity_correction(one_group_xs, composition, xs_den='', drop_main=False, **kwargs)[source]
nerea.functions.impurity_correction()
Calculates the fission chamber calibration coefficient.
Paramters
- one_group_xs
dict[str, float] the one group cross sections of the fission chamber components.
keyis the nuclide string identifier (e.g.,'U235'), andvalueis its one group cross section. Has columns for its value and uncertainty.- composition
pd.DataFrame the fission chamber composition relative to the deposit main nuclide.
keyis the nuclide string identifier (e.g.,'U235'), andvalueis its atomic abundance relative to the main one. Has columns for its value and uncertainty.- xs_den
str, optional the cross section entry of
one_group_xsto normalize the impurity correction to. Default is''for no cross section normalization.- drop_main
bool, optional flag to drop the main nuclide. Default is
False.- **kwargs
arguments for
nerea.utils._make_df()
- rtype:
pd.DataFrame
Note
The implementation features a separate calculation of
value and uncertainty to proper account for uncertianties in dot products where the elements of the two vectors are variable. This also covers for the setting of u(N_main) to 0 in
get_relative_compositionwhen renormalization is required.- Parameters:
one_group_xs (Xs)
composition (DataFrame)
xs_den (str)
drop_main (bool)
- Return type:
DataFrame
- one_group_xs
nerea.logging_config module
nerea.pulse_height_spectrum module
- class nerea.pulse_height_spectrum.PulseHeightSpectrum(start_time, data, campaign_id, experiment_id, detector_id, deposit_id, location_id, measurement_id, live_time, real_time, live_time_uncertainty=0.0, real_time_uncertainty=0.0, _PulseHeightSpectrum__smoothing_verbose_printed=False, _PulseHeightSpectrum__rebin_verbose_printed=False, _PulseHeightSpectrum__max_verbose_printed=False, _PulseHeightSpectrum__r_verbose_printed=False)[source]
Bases:
objectnerea.PulseHeightSpectrumClass storing and processing pulse height spectrum (PHS) data. Inherits from nerea.Experimental.
- \*\*start_time**
the PHS acquisition start date and time.
- Type:
datetime.datetime
- \*\*data**
the PHS data.
- Type:
pd.DataFrame
- \*\*campaign_id**
metadatata for expereimental campaign identification.
- Type:
str
- \*\*experiment_id**
metadatata for experiment identification.
- Type:
str
- \*\*detector_id**
metadatata for detector identification.
- Type:
str
- \*\*deposit_id**
metadatata for ionization chamber deposit identification.
- Type:
str
- \*\*location_id**
metadatata for expereimental location identification.
- Type:
str
- \*\*measurement_id**
metadatata for acquisition identification.
- Type:
str
- \*\*live_time**
the PHS acquisition live time.
- Type:
int
- \*\*real_time**
the PHS acquisition real time.
- Type:
int
- \*\*live_time_uncertainty**
the PHS acquisition live time uncertainty. Default is
0.0.- Type:
float, optional
- \*\*real_time_uncertainty**
the PHS acquisition real time uncertainty. Default is
0.0.- Type:
float, optional
- __smoothing_verbose_printed
flag labelling whether the verbose message for smoothing was printed. Handled internally. Default is
False.- Type:
bool, optional
- __rebin_verbose_printed
flag labelling whether the verbose message for rebinning was printed. Handled internally. Default is
False.- Type:
bool, optional
- __max_verbose_printed
flag labelling whether the verbose message for maximum search was printed. Handled internally. Default is
False.- Type:
bool, optional
- __r_verbose_printed
flag labelling whether the verbose message for R channel was printed. Handled internally. Default is
False.- Type:
bool, optional
- start_time: datetime
- data: DataFrame
- campaign_id: str
- experiment_id: str
- detector_id: str
- deposit_id: str
- location_id: str
- measurement_id: str
- live_time: int
- real_time: int
- live_time_uncertainty: float
- real_time_uncertainty: float
- smooth(**kwargs)[source]
nerea.PulseHeightSpectrum.smooth()
Calculates the sum of ‘value’ and the minimum value of ‘channel’ for each group based on the integer division of ‘channel’ by 10. Contains the data used to find max and hence R.
- param **kwargs:
arguments for the chosen
nerea.functions.smoothing- returns:
With the smoothed pulse height spectrum as data.
- rtype:
nerea.PulseHeightSpectrum
Notes
- Allowed methods are
'moving_average'(requireswindow)'ewm''savgol_filter'(requireswindow_length,polyorder)'fit'``(requires ``ch_before_max,order)
- Return type:
Self
- rebin(bins=None, smooth=True, **kwargs)[source]
nerea.PulseHeightSpectrum.rebin()
Rebins the spectrum.
- param **bins**:
Number of bins for rebinned spectrum. Recommended values are 4096, 2048, 1024, 512. Defaults to None for no rebinning.
- type **bins**:
int, optional- param **smooth**:
Flag to rebin smoothened spectrum. Defaults to True.
- type **smooth**:
bool, optional- param **kwargs:
Additional arguments for
self.smooth()renormalize (
bool): Whether to renormalize the smoothed spectrum.smoothing_method (
str): The mehtod to implement for smoothing.arguments for the chosen
utils.smoothing
- returns:
Rebinned spectrum.
- rtype:
nerea.PulseHeightSpectrum
- Parameters:
bins (int)
smooth (bool)
- Return type:
Self
- get_max(**kwargs)[source]
nerea.PulseHeightSpectrum.get_max()
Finds the channel with the maximum count value in a DataFrame.
- param **kwargs:
Additional arguments for
self.rebin()bins (
int): number of binssmooth (
bool): whether to smooth the PHS
self.smooth()only ifsmooth == Truerenormalize (
bool): Whether to renormalize the smoothed spectrum.smoothing_method (
str): The mehtod to implement for smoothing.arguments for the chosen
utils.smoothing.
- returns:
DataFrame with ‘channel’ and ‘value’ columns.
- rtype:
pd.DataFrame
Note
First channel finding is handled by _get_fst_ch().
- Return type:
DataFrame
- get_R(**kwargs)[source]
nerea.PulseHeightSpectrum.get_R()
Filters data in channels above the channel of the spectrum maximum and returns the first row with value <= than the maximum.
- param **kwargs:
Additional arguments for
self.rebin()bins (
int): number of binssmooth (
bool): whether to smooth the PHS
self.smooth()only ifsmooth == Truerenormalize (
bool): Whether to renormalize the smoothed spectrum.smoothing_method (
str): The mehtod to implement for smoothing.arguments for the chosen
utils.smoothing.
self.get_max()fst_ch (
int | str): channel to start max search or max search method.
- returns:
DataFrame with ‘channel’ and ‘value’ columns.
- rtype:
pd.DataFrame
- Return type:
DataFrame
- discriminators(llds=[0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6], **kwargs)[source]
nerea.PulseHeightSpectrum.discriminators()
Calculates the discrimination levels to process.
- param **llds**:
Low level discriminators to consider. Iteger -> interpreted as absolute channel Float -> interpreted as fractiosn of R Default is 10 uniformly spaced from 0.15 to 0.65.
- type **llds**:
Iterable[int | float], optional- param **kwargs:
Additional arguments for
self.rebin()bins (
int): number of binssmooth (
bool): whether to smooth the PHS
self.smooth()only ifsmooth == Truerenormalize (
bool): Whether to renormalize the smoothed spectrum.smoothing_method (
str): The mehtod to implement for smoothing.arguments for the chosen
utils.smoothing.
self.get_max()fst_ch (
int | str): channel to start max search or max search method.
- rtype:
np.array
- Parameters:
llds (Iterable[int | float])
- Return type:
array
- integrate(llds=[0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6], r=True, raw_integral=True, **kwargs)[source]
nerea.PulseHeightSpectrum.integrate()
Calculates the integral of data based on specified channels (as a function of R) and returns a DataFrame with channel, value, and uncertainty columns.
- param **llds**:
low level discriminator(s) to integrate from. Defaults to 10 llds between [0.15, 0.6].
- type **llds**:
Iterable[int|float] | int, optional- param **r**:
Defines whether the discriminators are absolute or fractions of the R channel. Default is
True.- type **r**:
bool, optional- param **raw_integral**:
Defines whether to integrate the raw data or the smoothed ones. Default is
False.- type **raw_integral**:
bool, optional- param **kwargs:
- param Additional arguments for:
- param -
self.rebin(): bins (
int): number of binssmooth (
bool): whether to smooth the PHS
- param -
self.smooth()only ifsmooth == True: renormalize (
bool): Whether to renormalize the smoothed spectrum.smoothing_method (
str): The mehtod to implement for smoothing.arguments for the chosen
nerea.functions.smoothing.
- param -
self.get_max(): fst_ch (
int | str): channel to start max search or max search method.
- returns:
DataFrame with
'channel','value', and'uncertainty'columns.- rtype:
pd.DataFrame
Notes
lldsare handled byself.discriminators
- Parameters:
llds (Iterable[int | float])
r (bool)
raw_integral (bool)
- Return type:
DataFrame
- calibrate(k, composition, monitor, one_group_xs, visual=False, savefig='', **kwargs)[source]
nerea.PulseHeightSpectrum.calibrate()
Computes the fission chamber effective mass from the pulse height spectrum.
- param **k**:
the facility calibration factor as in “Miniature fission chambers calibration in pulse mode: interlaboratory comparison at the SCK CEN BR1 and CEA CALIBAN reactors”. Has columns for its value and uncertainty.
- type **k**:
pd.DataFrame,- param **composition**:
the fission chamber composition relative to the total. key is the nuclide string identifier (e.g., ‘U235’), and value is its atomic abundance relative to the total. Has columns for its value and uncertainty.
- type **composition**:
nerea.Xs- param **one_group_xs**:
the one group cross sections of the fission chamber components. key is the nuclide string identifier (e.g., ‘U235’), and value is its one group cross section. Has columns for its value and uncertainty.
- type **one_group_xs**:
dict[str, float]- param **monitor**:
the counts of the monitor fission chamber used during calibration.
- type **monitor**:
nerea.ReactionRate- param **kwargs:
- param Additional arguments for:
- param -
self.rebin(): bins (
int): number of binssmooth (
bool): whether to smooth the PHS
- param -
self.smooth()only ifsmooth == True: renormalize (
bool): Whether to renormalize the smoothed spectrum.smoothing_method (
str): The mehtod to implement for smoothing.arguments for the chosen
utils.smoothing.
- param -
self.get_max(): fst_ch (
int | str): channel to start max search or max search method.
- param -
self.integrate(): llds (
Iterable[int | float]): Low level discriminators.r (
bool): Whether thelldsare fractions of the R channel.
- rtype:
nerea.EffectiveMass
- Parameters:
- Return type:
- plot(ax=None, c='k', **kwargs)[source]
nerea.PulseHeightSpectrum.plot()
Plots the pulse height spectrum data.
- param ax:
Axes wehere to plot. Default is None.
- type ax:
plt.Axes, optional- param c:
plot color. Default is ‘k’.
- type c:
str, optional- param **kwargs:
- param Additional arguments for:
- param -
self.rebin(): bins (
int): number of binssmooth (
bool): whether to smooth the PHS
- param -
self.smooth()only ifsmooth == True: renormalize (
bool): Whether to renormalize the smoothed spectrum.smoothing_method (
str): The mehtod to implement for smoothing.arguments for the chosen
utils.smoothing.
- param -
self.get_max(): fst_ch (
int | str): channel to start max search or max search method.
- param -
self.integrate(): llds (
Iterable[int | float]): Low level discriminators.r (
bool): Whether thelldsare fractions of the R channel.
- rtype:
plt.Axes
- Parameters:
ax (Axes)
c (str)
- Return type:
Axes
- classmethod from_TKA(file, **kwargs)[source]
nerea.PulseHeightSpectrum.from_TKA()
Reads data from a TKA file to create a PulseHeightSpectrum instance.
- param **file**:
TKA file path.
- type **file**:
str- param **kwargs:
Keyword arguments for class initialization.
start_time (
datetime.datetime) the PHS acquisition start date and time.campaign_id (
str) expereimental campaign identifier.experiment_id (
str) experiment identifier.detector_id (
str) detector identifier.deposit_id (
str) ionization chamber deposit identifier.location_id (
str) expereimental location identifier.measurement_id (
str) acquisition identifier.live_time (
int) the PHS acquisition life time.real_time (
int) the PHS acquisition real time.live_time_uncertainty: (
float, optional) life time uncertainty. Default is 0.0.real_time_uncertainty: (
float, optional) real time uncertainty. Default is 0.0.
- rtype:
nerea.PulseHeightSpectrum
- Parameters:
file (str)
- Return type:
Self
- classmethod from_formatted_TKA(file, **kwargs)[source]
nerea.PulseHeightSpectrum.from_formatted_TKA()
Reads data from a formatted TKA file and extracts metadata from the file name to create a PulseHeightSpectrum instance. The filename is expected to be formatted as: {Campaign}_{Experiment}_{Detector}_{Deposit}_{Location}_{Measurement}.TKA Requires a text file with the same name with time information.
- param **file**:
TKA file path.
- type **file**:
str- param **kwargs:
Keyword arguments for class initialization - live_time_uncertainty: (
float, optional) life time uncertainty. Default is 0.0. - real_time_uncertainty: (float, optional) real time uncertainty. Default is 0.0. Other nerea.PulseHeightSpectrum initialization kwargs can be overwritten.- rtype:
nerea.PulseHeightSpectrum
Examples
>>> ffs = PulseHeightSpectrum.from_formatted_TKA( f'{Campaign}_{Experiment}_{Detector}_{Deposit}_{Location}_{Measurement}.TKA')
- Parameters:
file (str)
- Return type:
Self
- classmethod from_CNF(file, **kwargs)[source]
nerea.PulseHeightSpectrum.from_CNF()
Reads data from a CNF file to create a PulseHeightSpectrum instance.
- param **file**:
CNF file path.
- type **file**:
str- param **kwargs:
Keyword arguments for class initialization.
campaign_id (
str) expereimental campaign identifier.experiment_id (
str) experiment identifier.detector_id (
str) detector identifier.deposit_id (
str) ionization chamber deposit identifier.location_id (
str) expereimental location identifier.measurement_id (
str) acquisition identifier.live_time_uncertainty: (
float, optional) life time uncertainty. Default is 0.0.real_time_uncertainty: (
float, optional) real time uncertainty. Default is 0.0.
- rtype:
nerea.PulseHeightSpectrum
Notes
start_time, live_time, real_time are read from the file.
- Parameters:
file (str)
- Return type:
Self
- classmethod from_formatted_CNF(file, **kwargs)[source]
nerea.PulseHeightSpectrum.from_formatted_CNF()
Reads data from a formatted CNF file and extracts metadata from the file name to create a PulseHeightSpectrum instance. The filename is expected to be formatted as: {Campaign}_{Experiment}_{Detector}_{Deposit}_{Location}_{Measurement}.CNF Requires a text file with the same name with time information.
- param **file**:
CNF file path.
- type **file**:
str- param **kwargs:
Keyword arguments for class initialization - live_time_uncertainty: (
float, optional) life time uncertainty. Default is 0.0. - real_time_uncertainty: (float, optional) real time uncertainty. Default is 0.0. Other nerea.PulseHeightSpectrum initialization kwargs can be overwritten.- rtype:
nerea.PulseHeightSpectrum
Examples
>>> ffs = PulseHeightSpectrum.from_formatted_CNF( f'{Campaign}_{Experiment}_{Detector}_{Deposit}_{Location}_{Measurement}.CNF')
- Parameters:
file (str)
- Return type:
Self
- Parameters:
start_time (datetime)
data (DataFrame)
campaign_id (str)
experiment_id (str)
detector_id (str)
deposit_id (str)
location_id (str)
measurement_id (str)
live_time (int)
real_time (int)
live_time_uncertainty (float)
real_time_uncertainty (float)
_PulseHeightSpectrum__smoothing_verbose_printed (bool)
_PulseHeightSpectrum__rebin_verbose_printed (bool)
_PulseHeightSpectrum__max_verbose_printed (bool)
_PulseHeightSpectrum__r_verbose_printed (bool)
- class nerea.pulse_height_spectrum.PulseHeightSpectra(spectra, _enable_checks=True)[source]
Bases:
objectnerea.PulseHeightSpectraClass storing and processing pulse height spectrum (PHS) data. Inherits from nerea.Experimental over several acquisitions.
This class works under the assumption that no measurement time was lost in the process of measuring the pulse height spectra.
That is that the self.data will be the channel-wise sum of the values of the listed pulse height spectra, while the start time of the measurement will be the minimum start time and life and real times will be the sum of the respective times in the listed pulse height spectra.
- \*\*spectra**
the listed spectra included in the analysis.
- Type:
Iterable[`nerea.PulseHeightSpectrum`]
- _enable_checks
flag enabling consistency checks. Default is True.
- Type:
bool, optoinal
- spectra: Iterable[PulseHeightSpectrum]
- property best: PulseHeightSpectrum
nerea.PulseHeightSpectra.best()
Returns the pulse height spectrum with the highest sum value.
- returns:
Pulse height spectrum with the highest integral count.
- rtype:
nerea.PulseHeightSpectrum
- classmethod from_formatted_TKA(files, **kwargs)[source]
nerea.PulseHeightSpectra.from_formatted_TKA()
Reads a list of files to create a PulseHeightSpectra object. Each filename is expected to be formatted as: {Campaign}_{Experiment}_{Detector}_{Deposit}_{Location}_{Measurement}.TKA Each file requires a text file with the same name with time information.
- param **files**:
List of file paths.
- type **files**:
Iterable[str]- param **kwargs:
Keyword arguments for class initialization - live_time_uncertainty: (
float, optional) life time uncertainty. Default is 0.0. - real_time_uncertainty: (float, optional) real time uncertainty. Default is 0.0. Other nerea.PulseHeightSpectrum initialization kwargs can be overwritten. The same is passed to all instances.- rtype:
nerea.PulseHeightSpectra
- Parameters:
files (Iterable[str])
- Return type:
Self
- Parameters:
spectra (Iterable[PulseHeightSpectrum])
_enable_checks (bool)
nerea.utils module
- nerea.utils.integral_v_u(s)[source]
nerea.utils.integral_v_u()
Compute the integral (sum) of a series and its associated uncertainty.
- param **s**:
The series of values to sum.
- type **s**:
pd.Series- returns:
The sum value and uncertainty.
- rtype:
tuple[float, float]
Examples
>>> import numpy as np >>> from nerea.utils import integral_v_u >>> s = np.array([1, 2, 3, 4]) >>> v, u = integral_v_u(s) >>> print(f"Sum: {v}, Uncertainty: {u}") Sum: 10, Uncertainty: 3.1622776601683794
- Parameters:
s (Series)
- Return type:
tuple[float, float]
- nerea.utils.time_integral_v_u(s)[source]
nerea.utils.integral_v_u()
Compute the time integral (c.dot(dt)) of a series and its associated uncertainty.
- param **s**:
The series of values to inegrate. Has
Timeandvaluecolumns.- type **s**:
pd.DataFrame- returns:
The integral value and uncertainty.
- rtype:
tuple[float, float]
Notes
sis assumed to be steps-post and the data are treated accordingly,hence
sshould end 1 time step after the desired end of integration. To allow calculation of time differences, s should start 1 time spep before the desired start time.
- Parameters:
s (DataFrame)
- Return type:
tuple[float, float]
- nerea.utils.ratio_uncertainty(n, un, d, ud)[source]
nerea.utils.ratio_uncertainty()
Compute the uncertainty of a ratio given the values and uncertainties of the numerator and denominator.
- param **n**:
The value of the numerator.
- type **n**:
float- param **un**:
The absolute uncertainty of the numerator.
- type **un**:
float- param **d**:
The value of the denominator.
- type **d**:
float- param **ud**:
The absolute uncertainty of the denominator.
- type **ud**:
float- returns:
The absolute uncertainty of the ratio.
- rtype:
float
Examples
>>> from nerea.utils import ratio_uncertainty >>> n, un = 10, 0.5 >>> d, ud = 5, 0.2 >>> u_ratio = ratio_uncertainty(n, un, d, ud) >>> print(f"Uncertainty of the ratio: {u_ratio}") Uncertainty of the ratio: 0.1118033988749895
- Return type:
tuple[float, float]
- nerea.utils.ratio_v_u(n, d)[source]
nerea.utils.ratio_v_u()
Compute the value and uncertainty of a ratio given objects with value and uncertainty attributes.
- param **n**:
An object with
'value'and'uncertainty'attributes representing the numerator.- type **n**:
pd.DataFrame- param **d**:
An object with
'value'and'uncertainty'attributes representing the denominator.- type **d**:
pd.DataFrame- returns:
The integral value and uncertainty.
- rtype:
tuple[float, float]
Examples
>>> class Measurement: ... def __init__(self, value, uncertainty): ... self.value = value ... self.uncertainty = uncertainty ... >>> from nerea.utils import ratio_v_u >>> n = Measurement(10, 0.5) >>> d = Measurement(5, 0.2) >>> v, u = ratio_v_u(n, d) >>> print(f"Ratio: {v}, Uncertainty: {u}") Ratio: 2.0, Uncertainty: 0.1118033988749895
- Parameters:
n (DataFrame)
d (DataFrame)
- Return type:
tuple[float, float]
- nerea.utils.product_v_u(factors)[source]
nerea.utils.product_v_u()
Computes the product of a number of values and propagates their uncertainty to the result.
- param **factors**:
the factors to multiply. Each dataframe should come with
'value'and'uncertainty [%]'columns.- type **factors**:
Iterable[pd.DataFrame]- returns:
The integral value and uncertainty.
- rtype:
tuple[float, float]
- Parameters:
factors (Iterable[DataFrame])
- Return type:
tuple[float, float]
- nerea.utils.dot_product_v_u(a, b)[source]
nerea.utils.dot_product_v_u()
Calculates value and uncertainty of the dot product of two vectors.
- param **a**:
First vector: a data frame with
'value'and'uncertainty'columns.- type **a**:
pd.DataFrame- param **b**:
Second vector: a data frame with
'value'and'uncertainty'columns.- type **b**:
pd.DataFrame- returns:
The integral value and uncertainty.
- rtype:
tuple[float, float]
- Parameters:
a (DataFrame)
b (DataFrame)
- Return type:
tuple[float, float]