radis.phys.units moduleĀ¶
- Unit(st, *args, **kwargs)[source]Ā¶
Radis evaluation of an unit, using
Unit
Changes compare to Astropy standards:
āĀµmā is accepted and converted to āumā
ā/moleculeā or ā/molecā are removed, but do not raise an error
we do not raise a warning if multiple slashes, e.g. āmW/cm2/sr/nmā
Examples
from radis.phys.units import Unit as u a = 200 * u("mW/cm2/sr/nm") a += 0.1 * u("W/cm2/sr/nm")
- conv2(quantity, fromunit, tounit)[source]Ā¶
Converts
quantity
from unitfromunit
to unittounit
- Parameters:
quantity (array) ā quantity to convert
fromunit (str) ā input unit
tounit (str) ā output unit
Note
The output is still non dimensional. We donāt transform
quantity
into a dimensioned array because this may create a performance drop in computationally-expensive task. Instead, we assume we know for sure the units in which some of our quantities will be created, and just want to let the users choose another output unit
- convert_emi2cm(j_nm, wavenum, Iunit0, Iunit)[source]Ā¶
Convert spectral emission density in wavelength base (typically ~mW/cm3/sr/nm) to spectral emission density in wavenumber base (~mW/cm3/sr/cm-1)
- Parameters:
j_nm (array) ā spectral emission density in Iunit0 unit (~ per wavelength) )
wavenum (array (cm-1)) ā wavenumber
Iunit0 (str) ā unit (~ per wavelength) to convert from
Iunit (str) ā unit (~ per wavenumber) to convert to
Notes
Implementation:
We use the variable substitution:
dĪ»/dĪ½ = - 1/Ī½**2 [in SI] dĪ»/dĪ½ = - 10^7 / Ī½**2 [nm -> cm-1]
We want LĪ½.dĪ½ = LĪ».dĪ» so LĪ½ = - LĪ» * 1e7 / Ī½^2
Example
Validation:
w_nm, j_nm = s.get('emisscoeff', 'nm', 'mW/cm2/sr/nm') w_cm, j_cm = s.get('emisscoeff', 'cm', 'mW/cm2/sr/cm-1') print(trapz(y_nm, x_nm)) print(trapz(y_cm, x_cm))
Both integrals are to be the same
- convert_emi2nm(j_cm, wavenum, Iunit0, Iunit)[source]Ā¶
Convert spectral emission density in wavenumber base (typically ~mW/cm3/sr/cm-1) to spectral radiance in wavelength base (~mW/cm3/sr/nm)
- Parameters:
j_cm (array) ā spectral emission density in Iunit0 unit (~ per wavenumber)
wavenum (array (cm-1)) ā wavenumber
Iunit0 (str) ā unit (~ per wavenumber) to convert from
Iunit (str) ā unit (~ per wavelength) to convert to
Notes
Implementation:
We use the variable substitution:
dĪ»/dĪ½ = - 1/Ī½**2 [in SI] dĪ»/dĪ½ = - 10^7 / Ī½**2 [nm -> cm-1]
We want LĪ½.dĪ½ = LĪ».dĪ» so LĪ» = - LĪ½ * 1e-7 * Ī½^2
- convert_rad2cm(l_nm, wavenum, Iunit0, Iunit, per_nm_is_like='mW/sr/cm2/nm', per_cm_is_like='mW/sr/cm2/cm-1')[source]Ā¶
Convert spectral radiance in wavelength base (~1/nm) to spectral radiance in wavenumber base (~1/cm-1)
- Parameters:
l_nm (array) ā spectral radiance in yunit0 unit (~ per wavelength)
wavenum (array (cm-1)) ā wavenumber
Iunit0 (str) ā unit (~ per wavelength) to convert from
Iunit (str) ā unit (~ per wavenumber) to convert to
Notes
Implementation:
- We use the variable substitution:
dĪ»/dĪ½ = - 1/Ī½**2 [in SI] dĪ»/dĪ½ = - 10^7 / Ī½**2 [nm -> cm-1]
We want LĪ½.dĪ½ = LĪ».dĪ» so LĪ½ = - LĪ» * 1e7 / Ī½^2
Example
Validation:
x_nm, y_nm = s.get('radiance_noslit', 'nm', 'mW/cm2/sr/nm') x_cm, y_cm = s.get('radiance_noslit', 'cm', 'mW/cm2/sr/cm-1') print(trapz(y_nm, x_nm)) print(trapz(y_cm, x_cm))
Both integrals are to be the same
- convert_rad2nm(l_cm, wavenum, Iunit0, Iunit, per_nm_is_like='mW/sr/cm2/nm', per_cm_is_like='mW/sr/cm2/cm-1')[source]Ā¶
Convert spectral radiance in wavenumber base (~1/cm-1) to spectral radiance in wavelength base (~1/nm)
- Parameters:
l_cm (array) ā spectral radiance in yunit0 unit (~ per wavenumber)
wavenum (array (cm-1)) ā wavenumber
Iunit0 (str) ā unit (~ per wavenumber) to convert from
Iunit (str) ā unit (~ per wavelength) to convert to
Notes
Implementation:
We use a variable substitution:
dĪ»/dĪ½ = - 1/Ī½**2 [in SI] dĪ»/dĪ½ = - 10^7 / Ī½**2 [nm -> cm-1]
We want LĪ½.dĪ½ = LĪ».dĪ» so LĪ» = - LĪ½ * 1e-7 * Ī½^2
- convert_universal(I, from_unit, to_unit, wavenum, per_nm_is_like='mW/cm2/sr/nm', per_cm_is_like='mW/cm2/sr/cm-1')[source]Ā¶
Return variable var in whatever unit, and converts to to_unit Also deal with cases where var is in ~1/nm (per_nm_is_like) or ~1/cm-1 (per_cm_is_like)
- Parameters:
var (str) ā variable to get. Usually āradianceā or āradiance_noslitā
to_unit (str) ā unit to convert variable to
wavenum (array (cm-1)) ā wavenumber is needed in case we convert from ~1/nm to ~1/cm-1 (requires a change of variable in the integral)