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
objectwanted (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. DefaultNone
- 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\]See also
- 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. DefaultFalse
.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
, thens
has been rescaled already ands_rescaled
iss
- Return type
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
- Other Parameters
inplace (boolean) â€“ if
True
, modifies the Spectrum object directly. Else, returns a copy. DefaultFalse
.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
, thens
has been rescaled already ands_rescaled
iss
- Return type
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 andx
the species mole fraction.See also
- 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
andemisscoeff
are given,radiance_noslit
can be recalculated ifabscoeff
is also given, or withoutabscoeff
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'
. SeeCONVOLUTED_QUANTITIES
andNON_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 coefficientabscoeff
is recomputed and all values are derived from a calculation under equilibrium, using Kirchoffâ€™s Law. Ifdefault
, use the value stored in Spectrum conditions[thermal_equilibrium
], else useFalse
.