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 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'][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. 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) – 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. 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, 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'. 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 value in conditions (creates it if doesnt exist)

Other Parameters

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.