f4enix.core.spectra.Spectra#

class f4enix.core.spectra.Spectra(ebins: ndarray, spectra_values: ndarray, name: str | None = None)#

Bases: object

Class representing a neutron spectra. Values are expected as normalized to 1.

Parameters:
  • ebins (np.ndarray) – N energy bins including first and last

  • spectra_values (np.ndarray) – N-1 spectra values, one for each energy bin (in eV)

  • name (str, None) – Name of the spectra. “Unnamed_Spectra” is set if None.

Variables:
  • ebins (np.ndarray) – N energy bins including first and last

  • spectra_values (np.ndarray) – N-1 spectra values, one for each energy bin

  • name (str) – Name of the spectra.

Raises:
  • ValueError – If the spectra values are not normalized to 1

  • ValueError – If the spectra values length does not match the energy bins length minus 1

Methods

__init__(ebins, spectra_values[, name])

Class representing a neutron spectra.

from_fispact(ebins, file)

Read a "fluxes" fispact file and get a Spectra object.

get_by_lethargy()

Get converted spectra values by unit lethargy.

plot([lethargy, add_spectra])

Plot the spectra.

print_collapse_inp(outdir[, tungsten])

Print a fispact collapse input file to perform XS collapse with this spectra.

print_condensed_inp(outdir)

Print a fispact condense input file to perform XS condensing with this spectra.

to_arb_flux_file(outdir)

print the spectra to a fispact "arb_flux" format to be used in a spectra conversion

to_fispact_fluxes(outdir[, format])

Save the spectra to a file in fispact "fluxes" format.

classmethod from_fispact(ebins: ndarray, file: Path | str | PathLike) Spectra#

Read a “fluxes” fispact file and get a Spectra object. Wall load must always be present (even if it will be ignored by F4Enix). A name also needs to be provided. This reduces possible wrong binning errors by the user.

Parameters:
  • ebins (np.ndarray) – ebins have to be externally provided. It is recommended to use the ones available at f4enix.core.egroups

  • file (PathLike) – Path to the fispact fluxes file to read.

Returns:

Spectra object read from the file.

Return type:

Spectra

get_by_lethargy() ndarray#

Get converted spectra values by unit lethargy.

plot(lethargy: bool = False, add_spectra: list[Spectra] | None = None) tuple[Figure, Axes]#

Plot the spectra.

Parameters:
  • lethargy (bool, optional) – If True, plot the spectra by unit lethargy. Default is False.

  • add_spectra (list[Spectra] | None, optional) – Additional spectra to plot for comparison. If None, only the current spectra is plotted. Default is None.

Returns:

The matplotlib Figure and Axes objects containing the plot.

Return type:

tuple[Figure, Axes]

print_collapse_inp(outdir: Path | str | PathLike, tungsten: bool = False) Path#

Print a fispact collapse input file to perform XS collapse with this spectra.

Parameters:
  • outdir (PathLike) – Path to the output directory.

  • tungsten (bool) – If True, the irradiation will happen on 1kg of tungsten as target material. self shielding will be included for the W186(n,g)W187.

Returns:

Path to the generated input file.

Return type:

Path

print_condensed_inp(outdir: Path | str | PathLike) Path#

Print a fispact condense input file to perform XS condensing with this spectra.

Parameters:

outdir (PathLike) – Path to the output directory.

Returns:

Path to the generated input file.

Return type:

Path

to_arb_flux_file(outdir: Path | str | PathLike) Path#

print the spectra to a fispact “arb_flux” format to be used in a spectra conversion

Parameters:

outdir (Path) – Path to the output directory.

Returns:

Path to the generated input file.

Return type:

Path

to_fispact_fluxes(outdir: Path | str | PathLike, format: str | None = None) None#

Save the spectra to a file in fispact “fluxes” format.

Parameters:
  • outdir (PathLike) – Path to the output directory.

  • format (str, None) – format for numbers. If None, default ‘.3e’ is used.