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”

  • 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 unit fromunit to unit tounit

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 computationaly-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:

/ = - 1/ν**2        [in SI]
/ = - 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:

/ = - 1/ν**2        [in SI]
/ = - 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)[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)[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:

/ = - 1/ν**2        [in SI]
/ = - 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, spec=None, per_nm_is_like='mW/sr/cm2/nm', per_cm_is_like='mW/sr/cm2/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

Other Parameters

spec (Spectrum object) – needed to get wavenumber in case we need to do a change of variable within the integral

Notes

wavenumber is needed in case we convert from ~1/nm to ~1/cm-1 (requires a change of variable in the integral)

is_homogeneous(unit1, unit2)[source]

Tells if unit1 and unit2 are homogeneous, using the Astropy library.

Parameters

unit1, unit2 (str) – units