radis.los.slabs moduleÂ¶
SummaryÂ¶
Classes to deal with multi-slabs configurations:
MergeSlabs()
for several species at the same spatial positionSerialSlabs()
to add several spectra along the line-of-path
One Slab is just a Spectrum
object
.. rubric:: Examples
See more examples in the RADIS line-of-sight module â€”â€”â€”â€”â€”â€”â€”â€”â€”â€”â€”â€”â€”â€”â€”â€”â€”â€”â€”â€”â€”â€”â€”â€”â€”â€”-
- MergeSlabs(*slabs, **kwargs) radis.spectrum.spectrum.Spectrum [source]Â¶
Combines several slabs into one. Useful to calculate multi-gas slabs. Linear absorption coefficient is calculated as the sum of all linear absorption coefficients, and the RTE is recalculated to get the total radiance. You can also simply use:
s1//s2
Merged spectrum
1+2
is calculated with Eqn (4.3) of the [RADIS-2018] article, generalized to N slabs :\[ \begin{align}\begin{aligned}j_{\lambda, 1+2} = j_{\lambda, 1} + j_{\lambda, 2}\\k_{\lambda, 1+2} = k_{\lambda, 1} + k_{\lambda, 2}\end{aligned}\end{align} \]where
\[j_{\lambda}, k_{\lambda}\]are the emission coefficient and absorption coefficient of the two slabs
1
and2
. Emission and absorption coefficients are calculated if not given in the initial slabs (if possible).- Parameters
slabs (list of Spectra, each representing a slab) â€“
path_length
must be given in Spectrum conditions, and equal for all spectra.line-of-sight:
slabs [0] \==== light [1] -> )=== observer [n] /====
- Other Parameters
kwargs input
resample (
'never'
,'intersect'
,'full'
) â€“ what to do when spectra have different wavespaces:If
'never'
, raises an errorIf
'intersect'
, uses the intersection of all ranges, and resample spectra on the most resolved wavespace.If
'full'
, uses the overlap of all ranges, resample spectra on the most resolved wavespace, and fill missing data with 0 emission and 0 absorption
Default
'never'
out (
'transparent'
,'nan'
,'error'
) â€“ what to do if resampling is out of bounds:'transparent'
: fills with transparent medium.'nan'
: fills with nan.'error'
: raises an error.
Default
'nan'
optically_thin (boolean) â€“ if
True
, merge slabs in optically thin mode. DefaultFalse
verbose (boolean) â€“ if
True
, print messages and warnings. DefaultFalse
modify_inputs (False) â€“ if
True
, slabs are modified directly when they are resampled. This avoids making a copy so is slightly faster. DefaultFalse
.
- Returns
Spectrum â€“ observed at the output. Conditions and units are transported too, unless there is a mismatch then conditions are dropped (and units mismatch raises an error because it doesnt make sense)
- Return type
object representing total emission and total transmittance as
Examples
Merge two spectra calculated with different species (physically correct only if broadening coefficients dont change much):
from radis import calc_spectrum, MergeSlabs s1 = calc_spectrum(...) s2 = calc_spectrum(...) s3 = MergeSlabs(s1, s2)
The last line is equivalent to:
s3 = s1//s2
Load a spectrum precalculated on several partial spectral ranges, for a same molecule (i.e, partial spectra are optically thin on the rest of the spectral range):
from radis import load_spec, MergeSlabs spectra = [] for f in ['spec1.spec', 'spec2.spec', ...]: spectra.append(load_spec(f)) s = MergeSlabs(*spectra, resample='full', out='transparent') s.update() # Generate missing spectral quantities s.plot()
- SerialSlabs(*slabs: radis.spectrum.spectrum.Spectrum, **kwargs: dict) radis.spectrum.spectrum.Spectrum [source]Â¶
Adds several slabs along the line-of-sight. If adding two slabs only, you can also use:
s1>s2
Serial spectrum
1>2
is calculated with Eqn (4.2) of the [RADIS-2018] article, generalized to N slabs :\[ \begin{align}\begin{aligned}I_{\lambda, 1>2} = I_{\lambda, 1} \tau_{\lambda, 2} + I_{\lambda, 2}\\\tau_{\lambda, 1+2} = \tau_{\lambda, 1} \cdot \tau_{\lambda, 2}\end{aligned}\end{align} \]where
\[I_{\lambda}, \tau_{\lambda}\]are the radiance and transmittance of the two slabs
1
and2
. Radiance and transmittance are calculated if not given in the initial slabs (if possible).- Parameters
slabs (list of Spectra, each representing a slab) â€“
line-of-sight:
slabs [0] [1] ............... [n] : : : \==== light * -> * -> * -> )=== observer /====
resample_wavespace (
'never'
,'intersect'
,'full'
) â€“ what to do when spectra have different wavespaces:If
'never'
, raises an errorIf
'intersect'
, uses the intersection of all ranges, and resample spectra on the most resolved wavespace.If
'full
â€™, uses the overlap of all ranges, resample spectra on the most resolved wavespace, and fill missing data with 0 emission and 0 absorption
Default
'never'
out (
'transparent'
,'nan'
,'error'
) â€“ what to do if resampling is out of bounds:'transparent'
: fills with transparent medium.'nan'
: fills with nan.'error'
: raises an error.
Default
'nan'
- Other Parameters
verbose (bool) â€“ if
True
, more blabla. DefaultFalse
modify_inputs (False) â€“ if
True
, slabs wavelengths/wavenumbers are modified directly when they are resampled. This avoids making a copy so it is slightly faster. DefaultFalse
.Note
for large number of slabs (in radiative transfer calculations) you surely want to use this option !
- Returns
Spectrum â€“ observed at the output (slab[n+1]). Conditions and units are transported too, unless there is a mismatch then conditions are dropped (and units mismatch raises an error because it doesnt make sense)
- Return type
object representing total emission and total transmittance as
Examples
Add s1 and s2 along the line of sight: s1 â€“> s2:
s1 = calc_spectrum(...) s2 = calc_spectrum(...) s3 = SerialSlabs(s1, s2)
The last line is equivalent to:
s3 = s1>s2
- resample_slabs(waveunit, resample_wavespace, out_of_bounds='nan', modify_inputs=False, *slabs)[source]Â¶
Resample slabs on the same wavespace: if the range are differents, depending on the mode we may fill with optically thin media, or raise an error
- Parameters
waveunit (
'nm'
,'cm-1'
) â€“ which wavespace weâ€™re working inresample_wavespace (â€˜neverâ€™, â€˜intersectâ€™, â€˜fullâ€™) â€“ what to do when spectra have different wavespaces:
If â€˜neverâ€™, raises an error
If â€˜intersectâ€™, uses the intersection of all ranges, and resample spectra on the most resolved wavespace.
If â€˜fullâ€™, uses the overlap of all ranges, resample spectra on the most resolved wavespace, and fill missing data with 0 emission and 0 absorption
Default â€˜neverâ€™
out_of_bounds (â€˜transparentâ€™, â€˜nanâ€™, â€˜errorâ€™) â€“ what to do if resampling is out of bounds:
â€˜transparentâ€™: fills with transparent medium.
â€˜nanâ€™: fills with nan.
â€˜errorâ€™: raises an error.
Default
'nan'
*slabs (list of Spectrum objects)
- Other Parameters
modify_inputs (False) â€“ if
True
, slabs are modified directly when they are resampled. This avoids making a copy so is slightly faster. DefaultFalse
.- Returns
slabs â€“ resampled copies of inputs Spectra. All now have the same wavespace
- Return type
list of Spectrum objects