radis.spectrum.rescale module

Functions to update Spectrum objects with new spectral quantities that can be derived from existing ones, or rescale path_length or mole_fraction, or add overpopulations.

Most of these are binded as methods to the Spectrum class, but stored here to unload the spectrum.py file

Equations derived from the code using pytexit


get_reachable(spec)[source]

Get the list of all quantities that can be derived from current available quantities, based on given spec conditions.

Parameters

spec (Spectrum) – a Spectrum object

Returns

reachable – list of quantities that can be calculated from available information

Return type

list

Notes

Algorithm:

for all quantities, starting from the last:
    for all possible ways to compute them
        if valid, add quantity to reachable list, and restart
        else, continue
get_recompute(spec, wanted, no_change=False, true_path_length=None)[source]

Get the list of all quantities that need to be recomputed to get the wanted quantities based on given spec conditions (does not recompute yet!)

Parameters
  • spec (Spectrum) – a Spectrum object

  • wanted (list) – list of quantities to recompute

Other Parameters
  • no_change (boolean) – if True, signals that we are somehow rescaling without changing path length nor mole fractions, i.e, all quantities can be recomputed from themselves…

  • true_path_length (boolean) – know whether the path length is given to build the equivalence graph tree. If None, path_length is looked up in the Spectrum condition. Default None

Returns

recompute – list of quantities needed

Return type

list

Notes

Algorithm:

for all quantities:
    for all possible ways to compute them
        if valid, add quantity to reachable list, and restart
        else, continue
get_redundant(spec)[source]

Returns a dictionary of all spectral quantities in spectrum and whether they are redundant.

Examples

redundant = get_redundant(spec)
>>> {'abscoeff': False, 'emisscoeff': True, 'absorbance': True, 'radiance_noslit': False,
     'transmittance_noslit': True}
non_rescalable_keys = ['abscoeff_continuum', 'emisscoeff_continuum'][source]

variables that cannot be rescaled (or not implemented):

Type

str

ordered_keys = ['abscoeff', 'emisscoeff', 'absorbance', 'radiance_noslit', 'transmittance_noslit', 'emissivity', 'emissivity_noslit', 'radiance', 'transmittance', 'xsection'][source]

List of all spectral variables sorted by priority during recomputation (ex: first get abscoeff, then try to calculate emisscoeff, etc.)

Type

list

rescale_abscoeff(spec, rescaled, initial, old_mole_fraction, new_mole_fraction, old_path_length_cm, wunit, units, extra, true_path_length, assume_equilibrium)[source]
Parameters
  • spec (Spectrum)

  • old_path_length (float) – path length in cm

References

Scale absorption coefficient : .. math:

k_2=k_1 \frac{x_2}{x_1}

Or recompute from the absorbance: .. math:

k_2=\frac{A_1}{L_1} \cdot \frac{x_2}{x_1}

Note

scaling mole fractions is not strictly valid because the lineshape changes slightly if resonant and non-resonant broadening coefficients are different

Or from the transmittance : .. math:

k_2=\frac{-\ln(T_1)}{L_1} \cdot \frac{x_2}{x_1}

Or from the cross-sections :

\[\k_2 =\sigma_1 * \frac{x p}{k_b T} \cdot \frac{x_2}{x_1}\]
rescale_absorbance(spec, rescaled, initial, old_mole_fraction, new_mole_fraction, old_path_length_cm, new_path_length_cm, waveunit, rescaled_units, extra, true_path_length)[source]

spec: Spectrum

Rescale the absorbance:

\[A_2=A_1\]

rac{x_2}{x_1} rac{L_2}{L_1}

Note

scaling path length is always valid ; scaling mole fractions is not strictly valid because the lineshape changes slightly if resonant and non-resonant broadening coefficients are different

Or compute from the absorption coefficient :

\[A_2=k_2 L_2\]

Or from the transmittance :

\[A_2=-\ln(T1)\]

rac{x_2}{x_1} rac{L_2}{L_1}

rescale_emisscoeff(spec, rescaled, initial, old_mole_fraction, new_mole_fraction, old_path_length_cm, optically_thin, wunit, units, extra, true_path_length)[source]
Parameters

spec (Spectrum)

References

If optically thin, compute from the radiance :

\[j_2=\frac{I_1}{L_1} \cdot \frac{x_2}{x_1}\]

In the general case, compute from the radiance and the absorption coefficient :

\[j_2=\frac{k_1 I_1}{1-\operatorname{exp}\left(-k_1 L_1\right)} \cdot \frac{x_2}{x_1}\]

Note

scaling path length is always valid ; scaling mole fractions is not strictly valid because the lineshape changes slightly if resonant and non-resonant broadening coefficients are different

or from the radiance and the transmittance:

\[j_2=\frac{k_1 I_1}{1-T_1} \frac{x_2}{x_1}\]
rescale_emissivity_noslit(spec, rescaled, rescaled_units, extra, true_path_length)[source]
Parameters

spec (Spectrum)

References

Compute from the transmittance :

\[\epsilon_2 = 1 - \tau_2\]
rescale_mole_fraction(spec, new_mole_fraction, old_mole_fraction=None, inplace=False, ignore_warnings=False, force=False, verbose=True)[source]

Update spectrum with new molar fraction Convoluted values (with slit) are dropped in the process.

Parameters
  • spec (Spectrum)

  • new_mole_fraction (float) – new mole fraction

  • old_mole_fraction (float, or None) – if None, current mole fraction (conditions[‘mole_fraction’]) is used

Other Parameters
  • inplace (boolean) – if True, modifies the Spectrum object directly. Else, returns a copy. Default False.

  • force (boolean) – if False, won’t allow rescaling to 0 (not to loose information). Default False

Returns

s_rescaled – a rescaled Spectrum. if inplace=True, then s has been rescaled already and s_rescaled is s

Return type

Spectrum

Notes

Implementation:

similar to rescale_path_length() but we have to scale abscoeff & emisscoeff Note that this is valid only for small changes in mole fractions. Then, the change in line broadening becomes significant

rescale_path_length(spec, new_path_length, old_path_length=None, inplace=False, force=False)[source]

Rescale spectrum to new path length. Starts from absorption coefficient and emission coefficient, and solves the RTE again for the new path length Convoluted values (with slit) are dropped in the process.

Parameters
  • spec (Spectrum)

  • new_path_length (float (cm) or Quantity) – new path length

  • old_path_length (float (cm) or Quantity, or None) – if None, current path length (conditions[‘path_length’]) is used

Other Parameters
  • inplace (boolean) – if True, modifies the Spectrum object directly. Else, returns a copy. Default False.

  • force (boolean) – if False, won’t allow rescaling to 0 (not to loose information). Default False

Returns

s_rescaled – a rescaled Spectrum. if inplace=True, then s has been rescaled already and s_rescaled is s

Return type

Spectrum

Notes

Implementation:

To deal with all the input cases, we first make a list of what has to be recomputed, and what has to be recalculated

rescale_radiance(spec, rescaled, initial, old_mole_fraction, new_mole_fraction, old_path_length_cm, new_path_length_cm, optically_thin, waveunit, rescaled_units, extra, true_path_length)[source]
Parameters

spec (Spectrum)

rescale_radiance_noslit(spec, rescaled, initial, old_mole_fraction, new_mole_fraction, old_path_length_cm, new_path_length_cm, optically_thin, waveunit, rescaled_units, extra, true_path_length)[source]
Parameters

spec (Spectrum)

References

If optically thin, calculate from the emission coefficient :

\[I_2=j_2 L_2\]

or scale the existing radiance :

\[I_2=\frac{\frac{I_1 x_2}{x_1} L_2}{L_1}\]

Note

scaling path length is always valid ; scaling mole fractions is not strictly valid because the lineshape changes slightly if resonant and non-resonant broadening coefficients are different

If not optically thin, recompute from the transmittance and absorption coefficient (analytical output of the 1D-homogenous column emission without scattering) :

\[I_2=\frac{j_2 \left(1-T_2\right)}{k_2}\]

or from the emission coefficient and absorption coefficient:

\[I_2=\frac{j_2 \left(1-\operatorname{exp}\left(-k_2 L_2\right)\right)}{k_2}\]
rescale_transmittance(spec, rescaled, initial, old_mole_fraction, new_mole_fraction, old_path_length_cm, new_path_length_cm, waveunit, units, extra)[source]
Parameters

spec (Spectrum)

rescale_transmittance_noslit(spec, rescaled, initial, old_mole_fraction, new_mole_fraction, old_path_length_cm, new_path_length_cm, waveunit, units, extra, true_path_length)[source]
Parameters

spec (Spectrum)

References

Compute from the absorbance :

\[\tau_2=\operatorname{exp}\left(-A_2\right)\]

Or from the absorption coefficient and the new path length :

\[\tau_2=\operatorname{exp}\left(-k_2 L_2\right)\]

Or from the previous transmittance :

\[\tau_2=\operatorname{exp}\left(\ln(T_1) \frac{x_2}{x_1} \frac{L_2}{L_1}\right)\]

Note

scaling path length is always valid ; scaling mole fractions is not strictly valid because the lineshape changes slightly if resonant and non-resonant broadening coefficients are different

rescale_xsection(spec, rescaled, initial, old_mole_fraction, new_mole_fraction, old_path_length_cm, new_path_length_cm, waveunit, rescaled_units, extra, true_path_length)[source]

Rescale cross-sections

Parameters
  • spec (Spectrum)

  • old_path_length (float) – path length in cm

References

Either scale the cross-section directly :

\[\sigma_2=\sigma_1\]

(by definition, cross-sections are unchanged)

or recompute from scaled absorption coefficient:

\[\sigma_2=k_2 \frac{k_b T}{x p}\]

With p the total pressure and x the species mole fraction.

See also

rescale_abscoeff

update(spec, quantity='all', optically_thin='default', assume_equilibrium='default', verbose=True)[source]

Calculate missing quantities that can be derived from the current quantities and conditions.

e.g: if path_length and emisscoeff are given, radiance_noslit can be recalculated if abscoeff is also given, or without abscoeff in an optically thin configuration, else

Parameters
  • spec (Spectrum)

  • quantity (str, 'same', 'all', or list of str) – name of the spectral quantity to recompute. If 'same', only the quantities in the Spectrum are recomputed. If 'all', then all quantities that can be derived are recomputed. Default 'all'. See CONVOLUTED_QUANTITIES and NON_CONVOLUTED_QUANTITIES

  • optically_thin (True, False, or 'default') – determines whether to calculate radiance with or without self-absorption. If 'default', the value is determined from the 'self_absorption' key in Spectrum.conditions. If not given, False is taken. Default 'default' Also updates the 'self_absorption' key in conditions (creates it if doesnt exist)

  • assume_equilibrium (boolean) – if True, only absorption coefficient abscoeff is recomputed and all values are derived from a calculation under equilibrium, using Kirchoff’s Law. If default, use the value stored in Spectrum conditions[thermal_equilibrium], else use False.