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
- 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'][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, wunit, units, extra, true_path_length)[source]Â¶
- Parameters
spec (Spectrum)
old_path_length (float) â€“ path length in cm
- rescale_absorbance(spec, rescaled, initial, old_mole_fraction, new_mole_fraction, old_path_length, new_path_length, waveunit, units, extra, true_path_length)[source]Â¶
- Parameters
spec (Spectrum)
- rescale_emisscoeff(spec, rescaled, initial, old_mole_fraction, new_mole_fraction, old_path_length, optically_thin, wunit, units, extra, true_path_length)[source]Â¶
- Parameters
spec (Spectrum)
- rescale_emissivity_noslit(spec, rescaled, units, extra, true_path_length)[source]Â¶
- Parameters
spec (Spectrum)
- 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
spec (Spectrum)
new_path_length (float) â€“ new path length
old_path_length (float, 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. 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, new_path_length, optically_thin, waveunit, units, extra, true_path_length)[source]Â¶
- Parameters
spec (Spectrum)
- rescale_radiance_noslit(spec, rescaled, initial, old_mole_fraction, new_mole_fraction, old_path_length, new_path_length, optically_thin, waveunit, units, extra, true_path_length)[source]Â¶
- Parameters
spec (Spectrum)
- rescale_transmittance(spec, rescaled, initial, old_mole_fraction, new_mole_fraction, old_path_length, new_path_length, waveunit, units, extra)[source]Â¶
- Parameters
spec (Spectrum)
- rescale_transmittance_noslit(spec, rescaled, initial, old_mole_fraction, new_mole_fraction, old_path_length, new_path_length, waveunit, units, extra, true_path_length)[source]Â¶
- Parameters
spec (Spectrum)
- 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 in an optically thin configuration, else if abscoeff is also given
- 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 value in conditions (creates it if doesnt exist)
- Other Parameters
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
.