abinslib.util

Utility functions, not specific to one calculation type.

Functions

is_none(→ bool)

Backport from python 3.14 operator.is_none.

get_version(→ str)

Get package version or return 'DEVELOPMENT' if not installed.

calculate_indirect_q2(→ euphonic.Quantity)

Calculate Q^2 value for given energy transfer in indirect geometry.

apply_weights(→ euphonic.spectra.Spectrum1DCollection)

Apply weights to Spectrum Collection data, based on atom symbol and mass.

iter_atom_info(→ collections.abc.Iterator[_AtomInfo])

Yield a series of atom metadata from structure data.

Module Contents

abinslib.util.is_none(a: object) bool[source]

Backport from python 3.14 operator.is_none.

abinslib.util.get_version() str[source]

Get package version or return ‘DEVELOPMENT’ if not installed.

abinslib.util.calculate_indirect_q2(energy_transfer: euphonic.Quantity, angle: float, final_energy: euphonic.Quantity) euphonic.Quantity[source]

Calculate Q^2 value for given energy transfer in indirect geometry.

By the cosine law Q^2 = k_f^2 + k_i^2 - 2 k_f k_i cos(theta)

Parameters:
  • energy_transfer – neutron energy change. (Positive values correspond to transfer to sample.)

  • angle – scattering angle in radians

  • final_energy – energy of detected neutrons (i.e. after monochromator)

Returns:

array of scalar Q^2 corresponding to input energy_transfer

abinslib.util.apply_weights(spectra: euphonic.spectra.Spectrum1DCollection, isotope_data: euphonic.isotopes.IsotopeData = sears_1992, key: str = 'scattering_cross_section') euphonic.spectra.Spectrum1DCollection[source]

Apply weights to Spectrum Collection data, based on atom symbol and mass.

Initially this only supports Spectrum1DCollection, but support for Spectrum2DCollection will be added as needed.

Parameters:
  • spectra – unweighted data including ‘atom_symbol’ and ‘mass’ metadata

  • isotope_data – neutron dataset with symbol/mass lookup capability

  • key – key for get_array() lookups in isotope_data

Returns:

new set of weighted spectra

abinslib.util.iter_atom_info(structure: euphonic.isotopes.Structure) collections.abc.Iterator[_AtomInfo][source]

Yield a series of atom metadata from structure data.