sandy.pfns module
This module contains all classes and functions dedicated to handling PFNS data and, more in general, any tabulated energy distribution provided in MF5 sections.
- class sandy.pfns.Edistr(df, **kwargs)
Bases:
object
Object to store tabulate energy distributions.
- Attributes:
data
pandas.DataFrameDataframe of energy distribution data with the following columns:
Methods
add_energy_point
(mat, mt, k, enew)Add outgoing energy distribution at one additional incident energy by interpolation.
add_energy_points
(mat, mt, k, elist)Add outgoing energy distributions at additional incident energies by interpolation.
custom_perturbation
(pert, mat, mt, k, ...)Given a peruration object (fractions), a MAT number, a MT number, a subsection number, a lower and an upper incoming energy bound, apply the perturbation to the outgoing energy distributions for all incident energies comprised within the given boundaries.
filter_by
(key, value)Apply condition to source data and return filtered results.
from_endf6
(endf6)Extract energy distributions from Endf6 instance.
Calculate the integral of each energy distribution.
get_table
(mat, mt, k)Pivot dataframe of tabulated energy spectra.
Renormalize each outgoing energy distribution to 1.
- add_energy_point(mat, mt, k, enew)
Add outgoing energy distribution at one additional incident energy by interpolation.
- Parameters:
- matint
MAT number.
- mtint
MT number.
- kint
subsection.
- enewfloat
energy point in eV
- Returns:
- sandy.Edistr
energy distribution with an additional additional incoming energy.
Examples
>>> orig = Edistr(minimal_edistrtest) >>> new = orig.add_energy_point(9437, 18, 0, 1.5) >>> new MAT MT K EIN EOUT VALUE 0 9437 18 0 1.00000e+00 1.00000e-05 4.00000e-01 1 9437 18 0 1.00000e+00 2.00000e+07 6.00000e-01 2 9437 18 0 1.50000e+00 1.00000e-05 2.00000e-01 3 9437 18 0 1.50000e+00 1.00000e-04 3.00000e-01 4 9437 18 0 1.50000e+00 1.00000e+00 5.50000e-01 5 9437 18 0 1.50000e+00 1.00000e+07 3.00000e-01 6 9437 18 0 1.50000e+00 2.00000e+07 3.00000e-01 7 9437 18 0 2.00000e+00 1.00000e-04 2.00000e-01 8 9437 18 0 2.00000e+00 1.00000e+00 7.00000e-01 9 9437 18 0 2.00000e+00 1.00000e+07 1.00000e-01
>>> new.get_table(9437, 18, 0) EOUT 1.00000e-05 1.00000e-04 1.00000e+00 1.00000e+07 2.00000e+07 EIN 1.00000e+00 4.00000e-01 4.00000e-01 4.00000e-01 5.00000e-01 6.00000e-01 1.50000e+00 2.00000e-01 3.00000e-01 5.50000e-01 3.00000e-01 3.00000e-01 2.00000e+00 0.00000e+00 2.00000e-01 7.00000e-01 1.00000e-01 0.00000e+00
If energy point is already present >>> copy = orig.add_energy_point(9437, 18, 0, 1) >>> pd.testing.assert_frame_equal(orig.data, copy.data)
- add_energy_points(mat, mt, k, elist)
Add outgoing energy distributions at additional incident energies by interpolation.
- Parameters:
- matint
MAT number.
- mtint
MT number.
- kint
subsection.
- elistiterable of float
energy points in eV
- Returns:
- newsandy.Edistr
energy distribution with an additional additional incoming energies.
Examples
>>> orig = Edistr(minimal_edistrtest) >>> new = orig.add_energy_points(9437, 18, 0, [1, 1.5, 1.7]) >>> new MAT MT K EIN EOUT VALUE 0 9437 18 0 1.00000e+00 1.00000e-05 4.00000e-01 1 9437 18 0 1.00000e+00 2.00000e+07 6.00000e-01 2 9437 18 0 1.50000e+00 1.00000e-05 2.00000e-01 3 9437 18 0 1.50000e+00 1.00000e-04 3.00000e-01 4 9437 18 0 1.50000e+00 1.00000e+00 5.50000e-01 5 9437 18 0 1.50000e+00 1.00000e+07 3.00000e-01 6 9437 18 0 1.50000e+00 2.00000e+07 3.00000e-01 7 9437 18 0 1.70000e+00 1.00000e-05 1.20000e-01 8 9437 18 0 1.70000e+00 1.00000e-04 2.60000e-01 9 9437 18 0 1.70000e+00 1.00000e+00 6.10000e-01 10 9437 18 0 1.70000e+00 1.00000e+07 2.20000e-01 11 9437 18 0 1.70000e+00 2.00000e+07 1.80000e-01 12 9437 18 0 2.00000e+00 1.00000e-04 2.00000e-01 13 9437 18 0 2.00000e+00 1.00000e+00 7.00000e-01 14 9437 18 0 2.00000e+00 1.00000e+07 1.00000e-01
- custom_perturbation(pert, mat, mt, k, ein_low, ein_high)
Given a peruration object (fractions), a MAT number, a MT number, a subsection number, a lower and an upper incoming energy bound, apply the perturbation to the outgoing energy distributions for all incident energies comprised within the given boundaries.
- Parameters:
- pertsandy.Pert
perturbation object.
- matint
MAT number.
- mtint
MT number.
- kint
subsection.
- ein_lowTYPE
lower energy boundary in eV.
- ein_highTYPE
upper energy boundary in eV.
- Returns:
- sandy.Edistr
perturbed distributions.
Notes
Note
the output distributions are not renormalized.
Note
The energy grid of the perturbation object refers to the outgoing energy distribution.
Note
If the perturbation exceeds 100%, it is truncated.
Examples
>>> orig = Edistr(minimal_edistrtest) >>> pert = sandy.Pert([1.3], index=[1e-3]) >>> orig.custom_perturbation(pert, 9437, 18, 0, 1.5, 2.5) MAT MT K EIN EOUT VALUE 0 9437 18 0 1.00000e+00 1.00000e-05 4.00000e-01 1 9437 18 0 1.00000e+00 2.00000e+07 6.00000e-01 2 9437 18 0 2.00000e+00 1.00000e-04 2.60000e-01 3 9437 18 0 2.00000e+00 1.00000e+00 7.00000e-01 4 9437 18 0 2.00000e+00 1.00000e+07 1.00000e-01
- property data
Dataframe of energy distribution data with the following columns:
MAT : MAT number
MT : MT number
K : subsection number
EIN : incoming energy
EOUT : outgoing energy
VALUE : tabulated value of the distribution
- Returns:
- pandas.DataFrame
tabulated energy distribution
Notes
Note
tabulated values are assumed to be interpolated linearly
Examples
>>> Edistr(minimal_edistrtest) MAT MT K EIN EOUT VALUE 0 9437 18 0 1.00000e+00 1.00000e-05 4.00000e-01 1 9437 18 0 1.00000e+00 2.00000e+07 6.00000e-01 2 9437 18 0 2.00000e+00 1.00000e-04 2.00000e-01 3 9437 18 0 2.00000e+00 1.00000e+00 7.00000e-01 4 9437 18 0 2.00000e+00 1.00000e+07 1.00000e-01
- filter_by(key, value)
Apply condition to source data and return filtered results.
- Parameters:
- `key`str
any label present in the columns of data
- `value`int or float
value used as filtering condition
- Returns:
- sandy.Edistr
filtered dataframe of energy distributions
- Raises:
- sandy.Error
if applied filter returned empty dataframe
Notes
Note
The primary function of this method is to make sure that the filtered dataframe is still returned as a Edistr object.
Examples
>>> Edistr(minimal_edistrtest).filter_by("EIN", 2) MAT MT K EIN EOUT VALUE 0 9437 18 0 2.00000e+00 1.00000e-04 2.00000e-01 1 9437 18 0 2.00000e+00 1.00000e+00 7.00000e-01 2 9437 18 0 2.00000e+00 1.00000e+07 1.00000e-01
- classmethod from_endf6(endf6)
Extract energy distributions from Endf6 instance.
- Parameters:
- endf6sandy.Endf6
object containing the ENDF-6 text
- Returns:
- sandy.Edistr
object with tabulated energy distributions
- get_integrals()
Calculate the integral of each energy distribution.
- Returns:
- pandas.DataFrame
dataframe of integrals
Examples
>>> Edistr(minimal_edistrtest).get_integrals() MAT MT K EIN INTEGRAL 0 9437 18 0 1.00000e+00 1.00000e+07 1 9437 18 0 2.00000e+00 4.00000e+06
- get_table(mat, mt, k)
Pivot dataframe of tabulated energy spectra.
- Parameters:
- matint
MAT number to filter data
- mtint
MT number to filter data
- kint
subsection number to filter data
- Returns:
- pandas.DataFrame
tabulated energy spectra with incident energies as index and outgoing energies as columns.
Examples
>>> Edistr(minimal_edistrtest).get_table(9437, 18, 0) EOUT 1.00000e-05 1.00000e-04 1.00000e+00 1.00000e+07 2.00000e+07 EIN 1.00000e+00 4.00000e-01 4.00000e-01 4.00000e-01 5.00000e-01 6.00000e-01 2.00000e+00 0.00000e+00 2.00000e-01 7.00000e-01 1.00000e-01 0.00000e+00
- normalize()
Renormalize each outgoing energy distribution to 1.
- Returns:
- sandy.Edistr
renormalized energy distributions
Examples
>>> new = Edistr(minimal_edistrtest).normalize() >>> new MAT MT K EIN EOUT VALUE 0 9437 18 0 1.00000e+00 1.00000e-05 4.00000e-08 1 9437 18 0 1.00000e+00 2.00000e+07 6.00000e-08 2 9437 18 0 2.00000e+00 1.00000e-04 5.00000e-08 3 9437 18 0 2.00000e+00 1.00000e+00 1.75000e-07 4 9437 18 0 2.00000e+00 1.00000e+07 2.50000e-08
>>> new.get_integrals() MAT MT K EIN INTEGRAL 0 9437 18 0 1.00000e+00 1.00000e+00 1 9437 18 0 2.00000e+00 1.00000e+00