Utility API

pyNDUS.utils.normalize_energy_unit(unit)[source]

Return the canonical label for an energy unit.

Parameters:

unit (str) – Energy unit label. Supported values are "eV" and "MeV", case-insensitively.

Returns:

Canonical unit label, either "eV" or "MeV".

Return type:

str

Raises:

ValueError – If the unit is not supported.

class pyNDUS.utils.EnergyGrid(values, unit='eV')[source]

Energy group boundaries with explicit unit metadata.

Parameters:
  • values (iterable) – One-dimensional energy group boundaries.

  • unit (str, optional) – Energy unit for values. Supported values are "eV" and "MeV".

values: Iterable
unit: str = 'eV'
to(unit)[source]

Return energy boundaries converted to the requested unit.

Parameters:

unit (str) – Target energy unit. Supported values are "eV" and "MeV".

Returns:

Converted energy boundaries.

Return type:

numpy.ndarray

property ev

Energy group boundaries in eV.

Returns:

Energy group boundaries converted to eV.

Return type:

numpy.ndarray

property mev

Energy group boundaries in MeV.

Returns:

Energy group boundaries converted to MeV.

Return type:

numpy.ndarray

pyNDUS.utils.zais2zaid(zaid)[source]

Convert an isotope label to the integer ZAID format used by pyNDUS.

Parameters:

zaid (str) – Isotope label in "<element>-<mass>" form, for example "U-235".

Returns:

Integer ZAID identifier.

Return type:

int

pyNDUS.utils.zaid2zais(zaid)[source]

Convert an integer ZAID identifier to an isotope label.

Parameters:

zaid (int or str) – Integer ZAID identifier, or its string representation.

Returns:

Isotope label in "<element>-<mass>" form.

Return type:

str

pyNDUS.utils.AStoZ()[source]

Return a mapping from atomic symbol to atomic number.

Returns:

periodictable – Keys are atomic symbols and values are atomic numbers.

Return type:

dict

pyNDUS.utils.ZtoAS(Z)[source]

Return the atomic symbol for an atomic number.

Parameters:

Z (int or str) – Atomic number.

Returns:

Atomic symbol.

Return type:

str

pyNDUS.utils.np2unp(v, rsd)[source]

Convert nominal values and relative standard deviations to uncertain values.

Parameters:
  • v (numpy.ndarray) – Array of nominal values.

  • rsd (numpy.ndarray) – Array of relative standard deviations. The absolute standard deviation is computed as rsd * abs(v).

Returns:

Array of uncertainties values with the same shape as v.

Return type:

numpy.ndarray

pyNDUS.utils.uncformat(data, std, fmtn=':.2u%S', fmts=None)[source]

Format nominal values and standard deviations for printing.

Parameters:
  • data (array-like) – Nominal values, or uncertain values when std is None.

  • std (array-like or None) – Standard deviations associated with data.

  • fmtn (str, optional) – Format specification passed to uncertainties.ufloat.

  • fmts (str, optional) – Legacy argument retained for API compatibility. It is currently unused.

Returns:

Formatted strings with nominal values and standard deviations.

Return type:

list[str]