sandy.core.lpc module
Outline
Summary
This module contains all classes and functions specific for the cross section class Xs that acts as a container for energy-dependent tabulated cross section values.
Examples
Routines
- class sandy.core.lpc.Lpc(df, **kwargs)
 Bases:
objectObject for energy dependent tabulated Legendre polynomial coefficients that describe angular distributions.
- Attributes:
 datapandas.DataFrameDataframe of energy-dependent tabulated cross sections.
Methods
custom_perturbation(mat, mt, p, pert)Apply a custom perturbation (energy dependent) to a given Legendre polynomial coefficient.
reshape(eg[, selected_mat, selected_mt])Linearly interpolate Legendre polynomial coefficients over new grid structure.
to_endf6(endf6)Update angular distributions in Endf6 instance with those available in a Lpc instance.
from_endf6(endf6)Extract legendre polynomial coefficients from Endf6 instance.
to_tpd([cosines])Convert Lpc instance to Tpd instance.
- custom_perturbation(mat, mt, p, pert)
 Apply a custom perturbation (energy dependent) to a given Legendre polynomial coefficient.
- Parameters:
 - matint
 MAT material number
- mtint
 MT reaction number
- pint
 order of the Legendre polynomial coefficient
- pertsandy.Pert
 tabulated perturbations
- Returns:
 - Lpc
 lpc instance with given series polynomial coefficient perturbed
Examples
>>> tape = sandy.get_endf6_file("jeff_33",'xs',922350) >>> LPC = sandy.Lpc.from_endf6(tape) >>> mat= 9228 >>> mt= 2 >>> p = 1 >>> pert= sandy.Pert([1, 1.05], index=[1.00000e+03, 5.00000e+03]) >>> pert = LPC.custom_perturbation(mat, mt, p, pert)._filters({'MAT': mat, 'MT':2}).data.loc[:,1].iloc[0:5] >>> data = LPC._filters({'MAT': mat, 'MT':2}).data.loc[:,1].iloc[0:5] >>> (pert/data).fillna(0) MAT MT E 9228 2 1.00000e-05 0.00000e+00 1.00000e+03 1.00000e+00 2.00000e+03 1.05000e+00 5.00000e+03 1.05000e+00 1.00000e+04 1.00000e+00 Name: 1, dtype: float64
- property data
 Dataframe of energy-dependent tabulated cross sections.
- Returns:
 - pandas.DataFrame
 tabulated xs
- Attributes:
 - indexpandas.Index
 energy grid in eV
- columnspandas.MultiIndex
 MAT/MT indices
- valuesnumpy.array
 cross sections in barns
- filter_by(key, value)
 Apply condition to source data and return filtered results.
- Parameters:
 - `key`str
 any label present in the index 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 Lpc object.
Examples
>>> tape = sandy.get_endf6_file("jeff_33",'xs',[922350, 922380]) >>> LPC = sandy.Lpc.from_endf6(tape) >>> comp = LPC.filter_by('MAT', 9228).data.index.get_level_values(0) == 9228 >>> assert comp.all() == True
>>> comp = LPC.filter_by('MT', 2).data.index.get_level_values(1) == 2 >>> assert comp.all() == True
>>> comp = LPC.filter_by('E', 1e-05).data.index.get_level_values(2) == 1e-05 >>> assert comp.all() == True
- classmethod from_endf6(endf6)
 Extract legendre polynomial coefficients from Endf6 instance.
- Parameters:
 - `endf6`sandy.Endf6
 Endf6 instance
- Returns:
 - Lpc
 Legendre polynomial coefficient data
- Raises:
 - sandy.Error
 if requested LPC were not found
Warning
- logging.warn
 skip section if coefficiets request an interpolation scheme over energy that is not lin-lin.
- reshape(eg, selected_mat=None, selected_mt=None)
 Linearly interpolate Legendre polynomial coefficients over new grid structure.
- Parameters:
 - egarray-like object
 new energy grid
- selected_matint, optional, default is None
 MAT number for which the reshape will apply (all MAT by default)
- selected_mtint, optional, default is None
 MT number for which the reshape will apply (all MT by default)
- Returns:
 - Lpc
 Legendre polynomial coefficients instance over new grid
Warning
The new Legendre polynomial coefficients are tabulated over the union between the old and the given energy grid
Examples
>>> tape = sandy.get_endf6_file("jeff_33",'xs',922350) >>> LPC = sandy.Lpc.from_endf6(tape) >>> eg = np.array([1, 2]) >>> LPC.reshape(eg).data.reset_index()[['E', 1, 2]].head() P E 1 2 0 1.00000e-05 0.00000e+00 0.00000e+00 1 1.00000e+00 1.13380e-06 2.53239e-09 2 2.00000e+00 2.26761e-06 5.06481e-09 3 1.00000e+03 1.13381e-03 2.53242e-06 4 2.00000e+03 2.93552e-03 1.59183e-05
- to_endf6(endf6)
 Update angular distributions in Endf6 instance with those available in a Lpc instance.
- Parameters:
 - `endf6`sandy.Endf6
 Endf6 instance
- Returns:
 - sandy.Endf6
 Endf6 instance with updated angular distributions
Warning
Warning
only lpc with (MAT,MT) combinations that are originally present in the Endf6 instance are modififed, the others are discarded. The reason behind this is that to reconstruct a endf6 section we need info that is not available in the Lpc instance itself.
- to_tpd(cosines=array([-1., -0.98, -0.96, -0.94, -0.92, -0.9, -0.88, -0.86, -0.84, -0.82, -0.8, -0.78, -0.76, -0.74, -0.72, -0.7, -0.68, -0.66, -0.64, -0.62, -0.6, -0.58, -0.56, -0.54, -0.52, -0.5, -0.48, -0.46, -0.44, -0.42, -0.4, -0.38, -0.36, -0.34, -0.32, -0.3, -0.28, -0.26, -0.24, -0.22, -0.2, -0.18, -0.16, -0.14, -0.12, -0.1, -0.08, -0.06, -0.04, -0.02, 0., 0.02, 0.04, 0.06, 0.08, 0.1, 0.12, 0.14, 0.16, 0.18, 0.2, 0.22, 0.24, 0.26, 0.28, 0.3, 0.32, 0.34, 0.36, 0.38, 0.4, 0.42, 0.44, 0.46, 0.48, 0.5, 0.52, 0.54, 0.56, 0.58, 0.6, 0.62, 0.64, 0.66, 0.68, 0.7, 0.72, 0.74, 0.76, 0.78, 0.8, 0.82, 0.84, 0.86, 0.88, 0.9, 0.92, 0.94, 0.96, 0.98, 1.]))
 Convert Lpc instance to Tpd instance.
- sandy.core.lpc.lpc_to_tpd(coeff, cosines)
 Convert polynomial coefficients into cosine-tabulated distribution.
- Parameters:
 - coeffarray-like object
 Legendre prolynomial coefficients starting from P0 up to any order
- cosinesarray-like object
 Cosines values over which to tabulate the distribution
- Returns:
 - pandas.Series
 tabulated distribution