corrct.physics.units

Units and conversion.

Module Contents

Classes

ConversionMetric

Conversion factors between orders of magnitude of the metric units.

ConversionEnergy

Conversion factors between orders of magnitude of the energy units.

Functions

energy_to_wlength

Convert from energy to wavelength.

wlength_to_energy

Convert wavelength to energy.

API

class corrct.physics.units.ConversionMetric[source]

Conversion factors between orders of magnitude of the metric units.

str_to_order

None

order_to_str

None

static convert(from_unit: str, to_unit: str) float[source]

Convert numbers from the source unit to the destination unit.

Parameters

from_unit : str The source unit to_unit : str The destination unit

Returns

float The conversion factor

class corrct.physics.units.ConversionEnergy[source]

Conversion factors between orders of magnitude of the energy units.

str_to_order

None

order_to_str

None

static convert(from_unit: str, to_unit: str) float[source]

Convert numbers from the source unit to the destination unit.

Parameters

from_unit : str The source unit to_unit : str The destination unit

Returns

float The conversion factor

corrct.physics.units.energy_to_wlength(energy: Union[float, numpy.typing.NDArray], unit_wl: str = 'm', unit_en: str = 'keV') Union[float, numpy.typing.NDArray][source]

Convert from energy to wavelength.

Parameters

energy : float | NDArray The energy unit_wl : str, optional The chosen unit for the output wavelength. The default is “m” unit_en : str, optional The chosen unit for the input energy. The default is “keV”

Returns

float | NDArray The wavelength in the chosen unit

corrct.physics.units.wlength_to_energy(w_length: Union[float, numpy.typing.NDArray], unit_wl: str = 'm', unit_en: str = 'keV') Union[float, numpy.typing.NDArray][source]

Convert wavelength to energy.

Parameters

w_length : float | NDArray The wavelength in the chosen unit unit : str, optional The chosen unit for the input wavelength. The default is “m” unit_en : str, optional The chosen unit for the output energy. The default is “keV”

Returns

float | NDArray The energy in the chosen unit