abinslib.util¶
Utility functions, not specific to one calculation type.
Functions¶
|
Backport from python 3.14 operator.is_none. |
|
Get package version or return 'DEVELOPMENT' if not installed. |
|
Calculate Q^2 value for given energy transfer in indirect geometry. |
|
Apply weights to Spectrum Collection data, based on atom symbol and mass. |
|
Yield a series of atom metadata from structure data. |
Module Contents¶
- 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