f4enix.input.d1suned.IrradiationFile#

class f4enix.input.d1suned.IrradiationFile(nsc: int, irr_schedules: list[Irradiation], header: str | None = None, formatting: list[int] | None = None, name: str = 'irrad')#

Bases: object

Object representing an irradiation D1S-UNED file.

It is built as a container of single irradiation object

Parameters:
  • nsc (int) – number of irradiation schedule.

  • irr_schedules (list of Irradiation object) – contains all irradiation objects.

  • header (str, optional) – Header of the file. The default is None.

  • formatting (list of int, optional) – fwf values for the output columns. The default (None) is [11, 14, 13, 9].

  • name (str, optional) – name of the file. The default is ‘irrad’.

Variables:
  • nsc (int) – number of irradiation schedule.

  • irr_schedules (list of Irradiation object) – contains all irradiation objects.

  • header (str, optional) – Header of the file. The default is None.

  • formatting (list of int, optional) – fwf values for the output columns. The default is [11, 14, 13, 9].

  • name (str, optional) – name of the file. The default is ‘irrad’.

Examples

Some usage examples

>>> # parse an existing file
... irrad_file = IrradiationFile.from_text('irr_test')
... # get the list of irradiation schedules
... irrad_file.irr_schedules
[['24051', '2.896e-07', '5.982e+00', '5.697e+00', 'Cr51'],
 ['25054', '2.570e-08', '5.881e+00', '1.829e+00', 'Mn54'],
 ['26055', '8.031e-09', '4.487e+00', '6.364e-01', 'Fe55']]
>>> # auxiliary method to retrieve a specific irradiation
... print(irrad_file.get_irrad('24051'))
Daughter: 24051
lambda [1/s]: 2.896e-07
times: ['5.982e+00', '5.697e+00']
comment: Cr51
>>> # auxiliary method to get all daughters
... print(irrad_file.get_daughters())
['24051', '25054', '26055']
Return type:

None.

Methods

__init__(nsc, irr_schedules[, header, ...])

Object representing an irradiation D1S-UNED file.

add_irradiation_times(times_dict)

Add irradiation times to all daughters in the irradiation schedules.

from_irradiation_schedules(daughter_list, ...)

Create the irradiation files computing the time correction factors according to the irradiation scenarios provided.

from_text(filepath)

Initialize an IrradiationFile object directly parsing and existing irradiation file

get_daughters()

Get a list of all daughters among all irradiation files

get_irrad(daughter)

Return the irradiation correspondent to the daughter

get_scaling_factors_cooling_time(...)

Given a cooling time, compute the scaling factors to be applied to dose tallies binned in daughter nuclides.

get_scaling_factors_new_scenario(...)

Given a new irradiation scenario and the reference irradiation file, compute the scaling factors to be applied to dose tallies binned in daughter nuclides.

remove_irradiation_time(index)

Remove a time correction factor from all daughters by index.

remove_schedules_below_threshold([threshold, k])

Remove all irradiation schedules where the k-th irradiation time is below the threshold.

select_daughters_irradiation_file(daughters)

Updates a D1S irradiation file selecting a subset of daughters from a list

to_df()

Convert the irradiation schedules to a pandas DataFrame.

write(path)

Write the D1S irradiation file

Attributes

nsc

Get the number of irradiation schedules.

add_irradiation_times(times_dict: dict[str, list[str]]) None#

Add irradiation times to all daughters in the irradiation schedules.

This method updates the time correction factors for each daughter in the irradiation schedules by appending the new times provided in the times_dict. It ensures that all daughters have the same number of time correction factors after the update. If the lengths of the time correction factors are inconsistent, an error is raised.

Parameters:

times_dict (dict[str, list[str]]) – A dictionary where keys are daughter ZAIDs (strings) and values are lists of time correction factors to be added.

Raises:

ValueError – If the lengths of the times lists are not equal after adding.

classmethod from_irradiation_schedules(daughter_list: list[Nuclide], irr_scenarios: list[IrradiationScenario], scale_IRS: dict[str, list[float]] | None = None, norm: float = 1) IrradiationFile#

Create the irradiation files computing the time correction factors according to the irradiation scenarios provided. Supports the use of the IRS card.

Parameters:
  • daughter_list (list[Nuclide]) – list of nuclides to be included in the irradiation file.

  • irr_scenarios (list[IrradiationScenario]) – list of irradiation scenarios to be used to compute the time correction factors.

  • scale_IRS (dict[str, list[float]] | None, optional) – dictionary of scaling factors for IRS nuclides (“irsCo62m”), by default None. The corresponding nuclides must have the irs flag active or the factor will not be applied. Only one irradiation scenario can be used when using this option.

  • norm (float, optional) – normalization factor to be applied during the computation of the time correction factors, by default 1

Returns:

Irradiation file object.

Return type:

IrradiationFile

Raises:

ValueError – If scale_IRS is provided and more than one irradiation scenario is used.

classmethod from_text(filepath: PathLike | str) IrradiationFile#

Initialize an IrradiationFile object directly parsing and existing irradiation file

Parameters:
  • cls (TYPE) – DESCRIPTION.

  • filepath (os.PathLike | str) – path to the existing irradiation file.

Return type:

None.

get_daughters() list[Nuclide]#

Get a list of all daughters among all irradiation files

Returns:

list of daughters.

Return type:

list[Nuclide]

get_irrad(daughter: str) Irradiation | None#

Return the irradiation correspondent to the daughter

Parameters:

daughter (str) – (e.g. ‘24051’).

Returns:

Returns the irradiation corresponding to the daughter. If no irradiation is found returns None.

Return type:

Irradiation | None

get_scaling_factors_cooling_time(ref_scenario_num: int, cooling_time: tuple[float, TIME_UNITS]) DataFrame#

Given a cooling time, compute the scaling factors to be applied to dose tallies binned in daughter nuclides. It automatically computes the decay factors for the new cooling time and the scaling factors.

Parameters:
  • ref_scenario_num (int) – reference irradiation scenario number in the current irradiation file.

  • cooling_time (Pulse) – cooling time to be considered for rescaling of dose tallies.

Returns:

DataFrame containing the scaling factors for each daughter nuclide.

Return type:

pd.DataFrame

get_scaling_factors_new_scenario(ref_scenario_num: int, new_irradiation_scenario: IrradiationScenario, norm: float) DataFrame#

Given a new irradiation scenario and the reference irradiation file, compute the scaling factors to be applied to dose tallies binned in daughter nuclides. It automatically computes the new time correction factors for the new scenario and the scaling factors.

Parameters:
  • ref_scenario_num (int) – reference irradiation scenario number in the current irradiation file.

  • new_irradiation_scenario (IrradiationScenario) – new irradiation scenario to be considered for rescaling of dose tallies.

  • norm (float) – norm factor for the calculation of the new time correction factors.

Returns:

DataFrame containing the scaling factors for each daughter nuclide at all cooling times.

Return type:

pd.DataFrame

property nsc: int#

Get the number of irradiation schedules.

remove_irradiation_time(index: int) None#

Remove a time correction factor from all daughters by index.

Parameters:

index (int) – The index of the time correction factor to be removed.

Raises:

IndexError – If the provided index is out of range for any daughter’s times list.

remove_schedules_below_threshold(threshold: float = 1e-12, k: int = 1) bool#

Remove all irradiation schedules where the k-th irradiation time is below the threshold.

Parameters:
  • threshold (float, optional) – The threshold value for the irradiation time. Default is 1e-12.

  • k (int, optional) – The scenario number (1-based index) of the irradiation time to check. Default is 1.

Returns:

True if all selected daughters are present after filtering, False otherwise.

Return type:

bool

select_daughters_irradiation_file(daughters: list[str])#

Updates a D1S irradiation file selecting a subset of daughters from a list

Parameters:

daughters (list.) – daughter zaids to be selected

to_df() DataFrame#

Convert the irradiation schedules to a pandas DataFrame.

Returns:

A DataFrame with columns ‘Daughter’, ‘Lambda’, and time correction factors.

Return type:

pd.DataFrame

write(path: PathLike) None#

Write the D1S irradiation file

Parameters:

path (os.PathLike) – output path where to save the file (only directory). self.name will be used as output file name

Return type:

None.