uvex_transients.utils.phot_utils.hz_per_unit#
- uvex_transients.utils.phot_utils.hz_per_unit(unit: str | UnitBase, *, is_wavelength: bool) float[source]#
Return the coefficient converting a bare number in
unitto a frequency in Hz.Resolved once, up front – not on every element of every model evaluation – so that letting a model’s spectral axis be expressed in an arbitrary (self-consistent) unit costs one extra multiply or divide per evaluation, not a
Quantityconversion in the hot loop.- Parameters:
- Returns:
If
is_wavelengthisFalse, \(\nu_\mathrm{Hz} = \mathrm{coefficient} \times x\); ifTrue, \(\nu_\mathrm{Hz} = \mathrm{coefficient} / x\) (frequency is inversely, not linearly, related to wavelength). Either way, this is that coefficient.- Return type:
- Raises:
ValueError – If
unitis not a wavelength/frequency unit matchingis_wavelength.
Examples
>>> hz_per_unit(u.THz, is_wavelength=False) 1000000000000.0