xpypact package

Subpackages

Submodules

xpypact.Fluxes module

xpypact.Inventory module

Helper class to load FISPACT inventory (output) from JSON file.

Implements list interface over time steps.

xpypact.Inventory.__copy__(self, /)

copy a struct

xpypact.Inventory.__delattr__(self, name, /)

Implement delattr(self, name).

xpypact.Inventory.__dir__(self, /)

Default dir() implementation.

xpypact.Inventory.__eq__(self, value, /)

Return self==value.

xpypact.Inventory.__format__(self, format_spec, /)

Default object formatter.

Return str(self) if format_spec is empty. Raise TypeError otherwise.

xpypact.Inventory.__ge__(self, value, /)

Return self>=value.

xpypact.Inventory.__getattribute__(self, name, /)

Return getattr(self, name).

xpypact.Inventory.__getstate__(self, /)

Helper for pickle.

xpypact.Inventory.__gt__(self, value, /)

Return self>value.

xpypact.Inventory.__hash__(self, /)

Return hash(self).

xpypact.Inventory.__init_subclass__()

This method is called when a class is subclassed.

The default implementation does nothing. It may be overridden to extend subclasses.

xpypact.Inventory.__le__(self, value, /)

Return self<=value.

xpypact.Inventory.__lt__(self, value, /)

Return self<value.

xpypact.Inventory.__ne__(self, value, /)

Return self!=value.

xpypact.Inventory.__new__(*args, **kwargs)

Create and return a new object. See help(type) for accurate signature.

xpypact.Inventory.__reduce__(self, /)

reduce a struct

xpypact.Inventory.__reduce_ex__(self, protocol, /)

Helper for pickle.

xpypact.Inventory.__replace__()

create a new struct with replacements

xpypact.Inventory.__repr__(self, /)

Return repr(self).

xpypact.Inventory.__rich_repr__(self, /)

rich repr

xpypact.Inventory.__setattr__(self, name, value, /)

Implement setattr(self, name, value).

xpypact.Inventory.__sizeof__(self, /)

Size of object in memory, in bytes.

xpypact.Inventory.__str__(self, /)

Return str(self).

xpypact.Inventory.__subclasshook__(object, /)

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

xpypact.Nuclide module

Nuclide properties from FISPACT JSON.

xpypact.Nuclide.__copy__(self, /)

copy a struct

xpypact.Nuclide.__delattr__(self, name, /)

Implement delattr(self, name).

xpypact.Nuclide.__dir__(self, /)

Default dir() implementation.

xpypact.Nuclide.__eq__(self, value, /)

Return self==value.

xpypact.Nuclide.__format__(self, format_spec, /)

Default object formatter.

Return str(self) if format_spec is empty. Raise TypeError otherwise.

xpypact.Nuclide.__ge__(self, value, /)

Return self>=value.

xpypact.Nuclide.__getattribute__(self, name, /)

Return getattr(self, name).

xpypact.Nuclide.__getstate__(self, /)

Helper for pickle.

xpypact.Nuclide.__gt__(self, value, /)

Return self>value.

xpypact.Nuclide.__hash__(self, /)

Return hash(self).

xpypact.Nuclide.__init_subclass__()

This method is called when a class is subclassed.

The default implementation does nothing. It may be overridden to extend subclasses.

xpypact.Nuclide.__le__(self, value, /)

Return self<=value.

xpypact.Nuclide.__lt__(self, value, /)

Return self<value.

xpypact.Nuclide.__ne__(self, value, /)

Return self!=value.

xpypact.Nuclide.__new__(*args, **kwargs)

Create and return a new object. See help(type) for accurate signature.

xpypact.Nuclide.__reduce__(self, /)

reduce a struct

xpypact.Nuclide.__reduce_ex__(self, protocol, /)

Helper for pickle.

xpypact.Nuclide.__replace__()

create a new struct with replacements

xpypact.Nuclide.__repr__(self, /)

Return repr(self).

xpypact.Nuclide.__rich_repr__(self, /)

rich repr

xpypact.Nuclide.__setattr__(self, name, value, /)

Implement setattr(self, name, value).

xpypact.Nuclide.__sizeof__(self, /)

Size of object in memory, in bytes.

xpypact.Nuclide.__str__(self, /)

Return str(self).

xpypact.Nuclide.__subclasshook__(object, /)

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

xpypact.RunData module

xpypact.TimeStep module

Time step attributes.

All names must be the same as in a FISPACT JSON file.

xpypact.TimeStep.__copy__(self, /)

copy a struct

xpypact.TimeStep.__delattr__(self, name, /)

Implement delattr(self, name).

xpypact.TimeStep.__dir__(self, /)

Default dir() implementation.

xpypact.TimeStep.__eq__(self, value, /)

Return self==value.

xpypact.TimeStep.__format__(self, format_spec, /)

Default object formatter.

Return str(self) if format_spec is empty. Raise TypeError otherwise.

xpypact.TimeStep.__ge__(self, value, /)

Return self>=value.

xpypact.TimeStep.__getattribute__(self, name, /)

Return getattr(self, name).

xpypact.TimeStep.__getstate__(self, /)

Helper for pickle.

xpypact.TimeStep.__gt__(self, value, /)

Return self>value.

xpypact.TimeStep.__hash__(self, /)

Return hash(self).

xpypact.TimeStep.__init_subclass__()

This method is called when a class is subclassed.

The default implementation does nothing. It may be overridden to extend subclasses.

xpypact.TimeStep.__le__(self, value, /)

Return self<=value.

xpypact.TimeStep.__lt__(self, value, /)

Return self<value.

xpypact.TimeStep.__ne__(self, value, /)

Return self!=value.

xpypact.TimeStep.__new__(*args, **kwargs)

Create and return a new object. See help(type) for accurate signature.

xpypact.TimeStep.__reduce__(self, /)

reduce a struct

xpypact.TimeStep.__reduce_ex__(self, protocol, /)

Helper for pickle.

xpypact.TimeStep.__replace__()

create a new struct with replacements

xpypact.TimeStep.__repr__(self, /)

Return repr(self).

xpypact.TimeStep.__rich_repr__(self, /)

rich repr

xpypact.TimeStep.__setattr__(self, name, value, /)

Implement setattr(self, name, value).

xpypact.TimeStep.__sizeof__(self, /)

Size of object in memory, in bytes.

xpypact.TimeStep.__str__(self, /)

Return str(self).

xpypact.TimeStep.__subclasshook__(object, /)

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

xpypact.data_arrays module

Module contents

The xpypact package.

Wraps FISPACT workflow. Transforms FISPACT output to Polars and duckdb datasets.

class xpypact.DoseRate[source]

Bases: Struct

Dose rate attributes.

Don’t scale by mass, for point source mass is always 1g, for contact dose mass is meaningless.

Attrs:

type: “Plain source” for contact dose or “Point source” distance: specified for “point source”, meters mass: mass for point source, always 1g

__post_init__()[source]

Correct wrong value coming from FISPACT.

Return type:

None

distance: float
dose: float
mass: float
type: str
class xpypact.FullDataCollector[source]

Bases: Struct

Class to collect inventory over multiple inventories method.

Note

we assume that all the gamma boundaries are the same over all JSON files to be appended.

class Result[source]

Bases: Struct

Finished collected data.

The only function of this class is to save the collected data to parquet files.

gbins: DataFrame | None
nuclide: DataFrame
rundata: DataFrame
save_to_parquets(out, *, override=False)[source]

Save collectd data as parquet files.

Parameters:
  • out (Path) – directory where to save

  • override (bool) – override existing files, default - raise exception

Raises:

FileExistError – if destination file exists and override is not specified.

Return type:

None

time_step_times: DataFrame
timestep: DataFrame
timestep_gamma: DataFrame | None
timestep_nuclide: DataFrame
append(inventory, material_id, case_id)[source]

Append inventory to this collector.

Parameters:
  • inventory (Inventory) – what to append

  • material_id (int) – identified #1 to distinguish multiple inventories

  • case_id (int) – identifier #2 …

Return type:

FullDataCollector

Returns:

self - for chaining

gbins_boundaries: ndarray[tuple[Any, ...], dtype[float64]] | None
get_gbins()[source]

Retrieve gbins.

Returns:

g [0..N], boundary[g]

Return type:

Polars table with gbins

get_nuclides_as_df()[source]

Retrieve collected nuclides.

Return type:

DataFrame

Returns:

table of collected nuclides

get_result()[source]

Finish and present collected data.

Return type:

Result

get_timestep_gamma_as_spectrum()[source]

Convert gamma values MeV/s -> photon/s.

In FISPACT JSON gamma emission is presented in MeV/s, but we need intensities in photon/s to represent gamma source.

Return type:

DataFrame | None

Returns:

time_step_gamma with rates in photon/s

lock = <unlocked _thread.RLock object owner=0 count=0>
nuclides: set[NuclideInfo]
rundata: DataFrame
timestep_gamma: DataFrame
timestep_nuclides: DataFrame
timesteps: DataFrame
class xpypact.GammaSpectrum[source]

Bases: Struct

Data on gamma emission.

Attrs:
boundaries:

Energy boundaries, MeV

intensities:

Gamma emission intensity.

boundaries: list[float]
property intensities: list[float]

Synonym for too abstract ‘values’ field.

values: list[float]
class xpypact.Inventory[source]

Bases: Struct

Helper class to load FISPACT inventory (output) from JSON file.

Implements list interface over time steps.

Parameters:
__getitem__(item)[source]

List interface delegated to the time steps.

Parameters:

item (int) – an item index or slice

Return type:

TimeStep

Returns:

Selected item or items.

__iter__()[source]

Iterate over time steps.

Return type:

Iterator[TimeStep]

Returns:

Iterator over the time steps.

__len__()[source]

Length, delegated to time steps.

Returns:

length of the time steps list.

Return type:

int

__post_init__()[source]

Define time steps durations and elapsed time.

Raises:

InventoryNonMonotonicTimesError – if time sequences in JSON are not in order

Return type:

None

extract_nuclides()[source]

Extract.

Return type:

set[NuclideInfo]

Returns:

Set of nuclides present in this inventory.

extract_times()[source]

Create vector of elapsed time for all the time steps in the inventory.

Return type:

NDArrayFloat

Returns:

Vector with elapsed times.

inventory_data: list[TimeStep]
iterate_time_step_gamma()[source]

Scan the time steps and gamma spectrum.

Return type:

Iterator[tuple[int, int, float]]

Returns:

Iterator over all the gamma bins presented in the Inventory.

iterate_time_step_nuclides()[source]

Scan the time steps and nuclides in these steps.

Return type:

Iterator[tuple[int, int, float, float, float, float, float, float, float, float, float, float, float, float, float]]

Returns:

Iterator over all the nuclides collected in the Inventory.

property meta_info: RunDataCorrected

Create corrected Inventory header.

Returns:

with common data for the inventory.

Return type:

RunDataCorrected

run_data: RunData
class xpypact.Nuclide[source]

Bases: Struct

Nuclide properties from FISPACT JSON.

Parameters:
__post_init__()[source]

Make the values consistent in data from old FISPACT.

Return type:

None

property a: int

Synonym to mass number, isotope, A.

Returns:

A, mass number

activity: float
alpha_activity: float
alpha_heat: float
atoms: float
beta_activity: float
beta_heat: float
dose: float
element: str
gamma_activity: float
gamma_heat: float
grams: float
half_life: float
heat: float
property info: NuclideInfo

Extract a nuclide specific information.

Returns:

element, a, state, zai, half_life

ingestion: float
inhalation: float
isotope: int
state: str
zai: int
class xpypact.NuclideInfo[source]

Bases: _NuclideID

Basic information on a nuclide.

This is extracted as a separate database entity to improve normalization.

element: str
half_life: float
isotope: int
state: str
class xpypact.RunDataCorrected[source]

Bases: Struct

Common data for an FISPACT inventory.

Note

Correction - dose_rate_type and dose_rate_distance are duplicated the FISPACT time steps. This information is extracted to this header.

dose_rate_distance: float
dose_rate_type: str
flux_name: str
run_name: str
timestamp: str
class xpypact.TimeStep[source]

Bases: Struct

Time step attributes.

All names must be the same as in a FISPACT JSON file.

Parameters:
__post_init__()[source]

Correct data missed in FISPACT-4.

Return type:

None

alpha_activity: float
alpha_heat: float
beta_activity: float
beta_heat: float
cooling_time: float
dose_rate: DoseRate
duration: float
elapsed_time: float
flux: float
gamma_activity: float
gamma_heat: float
gamma_spectrum: GammaSpectrum | None
ingestion_dose: float
inhalation_dose: float
irradiation_time: float
property is_cooling: bool

Is the time step for cooling?

Returns:

Is the irradiation flux zero?

nuclides: list[Nuclide]
property nuclides_mass: float

Synonym for total mass.

Returns:

Total mass of the nuclides in kg.

number: int
total_activity: float
total_atoms: float
total_heat: float
total_mass: float