radis.lbl.broadening module

Summary

A class to handle all broadening related functions (and unload factory.py)

BroadenFactory is inherited by SpectrumFactory eventually

Routine Listing

Most methods are written in inherited class with the following inheritance scheme:

DatabankLoader > BaseFactory > BroadenFactory > BandFactory > SpectrumFactory

digraph inheritanceb7d785f131 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "BandFactory" [URL="radis.lbl.bands.html#radis.lbl.bands.BandFactory",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="See Also"]; "BroadenFactory" -> "BandFactory" [arrowsize=0.5,style="setlinewidth(0.5)"]; "BaseFactory" [URL="radis.lbl.base.html#radis.lbl.base.BaseFactory",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top"]; "DatabankLoader" -> "BaseFactory" [arrowsize=0.5,style="setlinewidth(0.5)"]; "BroadenFactory" [URL="#radis.lbl.broadening.BroadenFactory",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="A class that holds all broadening methods."]; "BaseFactory" -> "BroadenFactory" [arrowsize=0.5,style="setlinewidth(0.5)"]; "DatabankLoader" [URL="radis.lbl.loader.html#radis.lbl.loader.DatabankLoader",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip=".. inheritance-diagram:: radis.lbl.factory.SpectrumFactory"]; "SpectrumFactory" [URL="radis.lbl.factory.html#radis.lbl.factory.SpectrumFactory",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="A class to put together all functions related to loading CDSD / HITRAN"]; "BandFactory" -> "SpectrumFactory" [arrowsize=0.5,style="setlinewidth(0.5)"]; }

PUBLIC FUNCTIONS - BROADENING

PRIVATE METHODS - BROADENING (all computational-heavy functions: calculates all lines broadening, convolve them, apply them on all calculated range)

  • radis.lbl.broadening.whiting()

  • radis.lbl.broadening._whiting_jit() : precompiled version

  • radis.lbl.broadening.BroadenFactory._calc_broadening_HWHM()

  • radis.lbl.broadening.BroadenFactory._add_voigt_broadening_HWHM()

  • radis.lbl.broadening.BroadenFactory._voigt_broadening()

  • radis.lbl.broadening.BroadenFactory._calc_lineshape()

  • radis.lbl.broadening.BroadenFactory._calc_lineshape_LDM()

  • radis.lbl.broadening.BroadenFactory._apply_lineshape()

  • radis.lbl.broadening.BroadenFactory._apply_lineshape_LDM()

  • radis.lbl.broadening.BroadenFactory._calc_broadening()

  • radis.lbl.broadening.BroadenFactory._calc_broadening_noneq()

  • radis.lbl.broadening.BroadenFactory._find_weak_lines()

  • radis.lbl.broadening.BroadenFactory.calculate_pseudo_continuum()

  • radis.lbl.broadening.BroadenFactory._add_pseudo_continuum()

Notes

Formula in docstrings generated with py2tex()

from pytexit import py2tex
py2tex('...')

class BroadenFactory[source]

Bases: BaseFactory

A class that holds all broadening methods.

Eventually inherited by SpectrumFactory

digraph inheritanceb7d785f131 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "BandFactory" [URL="radis.lbl.bands.html#radis.lbl.bands.BandFactory",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="See Also"]; "BroadenFactory" -> "BandFactory" [arrowsize=0.5,style="setlinewidth(0.5)"]; "BaseFactory" [URL="radis.lbl.base.html#radis.lbl.base.BaseFactory",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top"]; "DatabankLoader" -> "BaseFactory" [arrowsize=0.5,style="setlinewidth(0.5)"]; "BroadenFactory" [URL="#radis.lbl.broadening.BroadenFactory",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="A class that holds all broadening methods."]; "BaseFactory" -> "BroadenFactory" [arrowsize=0.5,style="setlinewidth(0.5)"]; "DatabankLoader" [URL="radis.lbl.loader.html#radis.lbl.loader.DatabankLoader",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip=".. inheritance-diagram:: radis.lbl.factory.SpectrumFactory"]; "SpectrumFactory" [URL="radis.lbl.factory.html#radis.lbl.factory.SpectrumFactory",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="A class to put together all functions related to loading CDSD / HITRAN"]; "BandFactory" -> "SpectrumFactory" [arrowsize=0.5,style="setlinewidth(0.5)"]; }

See also

SpectrumFactory

NwG[source]
NwL[source]
SpecDatabase[source]
autoretrievedatabase[source]
autoupdatedatabase[source]
calculate_pseudo_continuum(noneq=False)[source]

Find weak lines, add them in pseudo-continuum (note that pseudo- continuum by RADIS definition is actually more a sum of low-resolution lines)

Parameters:

noneq (bool) – if True, also returns the emisscoeff pseudo continuum (for noneq cases). Default False

Returns:

  • k_continuum (numpy array (1/(#.cm-2))) – abscoeff semi-continuum on wavenumber space

  • j_continuum (numpy array) – only returned if noneq=True : emisscoeff semi-continuum on wavenumber space

  • Also – self.df1 is updated, lines are removed local variables self._Nlines_in_continuum and self._Nlines_calculated are created

Notes

continuum can be exported in Spectrum is using the self.export_continuum boolean. This is not available as a User input but can be edited manually in the Factory.

The Weak line characterization [1]_ is only based on abscoeff. For strong nonequilibrium cases there may be lines considered as weak in terms of absorption but not weak in emission, or the other way around. It should be negligible, though, so a dual conditioning (looking at both abscoeff and emisscoeff) was not implemented. See radis.lbl.broadening._find_weak_lines() if you want to change that

Reference

cond_units[source]
database[source]
dataframe_engine[source]
dataframe_type[source]
df0[source]

initial line database after loading. If for any reason, you want to manipulate the line database manually (for instance, keeping only lines emitting by a particular level), you need to access the df0 attribute of SpectrumFactory.

Warning

never overwrite the df0 attribute, else some metadata may be lost in the process. Only use inplace operations. If reducing the number of lines, add a df0.reset_index()

For instance:

from radis import SpectrumFactory
sf = SpectrumFactory(
    wavenum_min= 2150.4,
    wavenum_max=2151.4,
    pressure=1,
    isotope=1)
sf.load_databank('HITRAN-CO-TEST')
sf.df0.drop(sf.df0[sf.df0.vu!=1].index, inplace=True)   # keep lines emitted by v'=1 only
sf.eq_spectrum(Tgas=3000, name='vu=1').plot()

df0 contains the lines as they are loaded from the database. df1 is generated during the spectrum calculation, after the line database reduction steps, population calculation, and scaling of intensity and broadening parameters with the calculated conditions.

See also

df1

Type:

pd.DataFrame

df1[source]

line database, scaled with populations + linestrength cutoff Never edit manually. See all comments about df0

See also

df0

Type:

pd.DataFrame

input[source]
input_wunit[source]
interactive_params[source]
levels[source]
levelspath[source]
min_width[source]
misc[source]

Miscellaneous parameters (MiscParams) params that cannot change the output of calculations (ex: number of CPU, etc.)

molparam[source]

contains information about molar mass; isotopic abundance.

See MolParams

Type:

MolParam

params[source]

Parameters they may change the output of calculations (ex: threshold, cutoff, broadening methods, etc.)

Type:

Computational parameters

parsum_calc[source]

store all partition function calculators, per isotope

Type:

dict

parsum_tab[source]

store all partition function tabulators, per isotope

Type:

dict

plot_broadening(i=0, pressure_atm=None, mole_fraction=None, Tgas=None)[source]

Recalculate and plot broadening for line of index i.

Used mainly for testing.

Parameters:
  • i (int) – line index

  • pressure_atm (atm) – if None, defaults to model pressure

  • mole_fraction ([0-1]) – if None, defaults to model mole fraction

  • Tgas (K) – if None, defaults to model translational temperature

Examples

from radis import SpectrumFactory
sf=SpectrumFactory(...)
sf.eq_spectrum(...)
sf.plot_broadening(i=500)   # plot line number 500
profiler[source]
reftracker[source]
save_memory[source]

if True, tries to save RAM memory (but may take a little for time, saving stuff to files instead of RAM for instance)

Type:

bool

truncation[source]
units[source]
use_cython[source]
verbose[source]

increase verbose level. 0, 1, 2 supported at the moment

Type:

bool, or int

warnings[source]

Default warnings for SpectrumFactory. See default_warning_status

Type:

dict

wavenumber[source]
wavenumber_calc[source]
wbroad_centered[source]
woutrange[source]
doppler_broadening_HWHM(wav, molar_mass, Tgas)[source]

Computes Gaussian (Doppler) broadening HWHM over all lines with [1]_, [2]_

\[\frac{w}{c} \sqrt{\frac{2N_a k_b T_{gas} \ln 2}{M}}\]

with k and c in CGS

Parameters:
  • wav (array like (nm / cm-1)) – transition waverange [length N = number of lines]

  • molar_mass (array like (g/mol)) – molar mass for isotope of given transition, in g/mol [length N]

  • Tgas (float (K)) – (translational) gas temperature

Returns:

array – gaussian HWHM for all lines

Return type:

(nm / cm-1) [shape N]

References

\[f_{G} = \frac{1}{\alpha} \sqrt{\frac{\ln 2}{\pi}} exp\left(- \ln 2 \left(\frac{w - w_0}{\alpha}\right)^2 \right)\]

with α the full-width half maximum (HWHM) calculated in cm-1, nm or Hz:

Here we work in cm-1 with the CGS nomenclature (molar mass M in g/mol)

Notes

equation generated from the Python formula with py2tex()

gaussian_FT(w_centered, hwhm)[source]

Fourier Transform of a Gaussian lineshape.

\[\operatorname{exp}\left(\frac{-\left({\left(2\pi w_{centered} hwhm\right)}^2\right)}{4\ln2}\right)\]
Parameters:
  • w_centered (2D array [one per line: shape W x N]) – waverange (nm / cm-1) (centered on 0)

  • hwhm (array [shape N = number of lines]) – Half-width at half-maximum (HWHM) of Gaussian

Returns:

  • numpy array or vaex expression.

  • Depends upon the type of hwhm parameter, if it of vaex expression type then,returned value is vaex expression

gaussian_lineshape(w_centered, hwhm)[source]

Computes Doppler (Gaussian) lineshape over all lines with [1]_, [2]_

\[\frac{1}{\alpha_g} \sqrt{\frac{\ln 2}{\pi}} \operatorname{exp}\left(-\ln 2 {\left(\frac{w_{centered}}{\alpha_g}\right)}^2\right)\]

with \(\alpha_g\) half-width at half maximum (HWHM)

Parameters:
  • w_centered (2D array [one per line: shape W x N]) – waverange (nm / cm-1) (centered on 0, size W = broadening width size)

  • hwhm (array [shape N = number of lines]) – Half-width at half-maximum (HWHM) of Gaussian

  • Tgas (K) – (translational) gas temperature

Returns:

array – line profile

Return type:

[shape N x W]

References

Both give the same results.

Notes

formula generated from the Python equation with py2tex()

lorentzian_FT(w_centered, gamma_lb)[source]

Fourier Transform of a Lorentzian lineshape.

\[\operatorname{exp}\left(-2\pi w_{centered} \gamma_{lb}\right)\]
Parameters:
  • w_centered (2D array [one per line: shape W x N]) – waverange (nm / cm-1) (centered on 0)

  • gamma_lb (array (cm-1) [length N]) – half-width half maximum coefficient (HWHM) for pressure broadening calculation

Return type:

array

lorentzian_lineshape(w_centered, gamma_lb)[source]

Computes collisional broadening over all lines [1]_

\[\frac{1}{\pi} \frac{\gamma_{lb}}{\gamma_{lb}^2+w_{centered}^2}\]
Parameters:
  • w_centered (2D array [one per line: shape W x N]) – waverange (nm / cm-1) (centered on 0)

  • gamma_lb (array (cm-1) [length N]) – half-width half maximum coefficient (HWHM) for pressure broadening calculation

Returns:

array – line profile

Return type:

[shape N x W]

References

Notes

formula generated from the Python equation with py2tex()

olivero_1977(wg, wl)[source]

Calculate approximate Voigt FWHM with [Olivero-1977].

also in NEQAIR 96 manual Eqn. (D2) Note that formula is given in wavelength (nm) [doesnt change anything] and uses full width half maximum (FWHM) of Gaussian and Lorentzian profiles.

For use with the Whiting formula of voigt_lineshape().

Parameters:
  • wg (numpy array) – Gaussian profile FWHM

  • wl (numpy array) – Lorentzian profile FWHM

Returns:

gamma_voigt – Voigt FWHM

Return type:

numpy array

References

[Olivero-1977] uses FWHM.

\[ \begin{align}\begin{aligned}s_d=\frac{w_l-w_g}{w_l+w_g}\\w_v=\left(1-0.18121\left(1-{s_d}^2\right)-\left(0.023665\operatorname{exp}\left(0.6s_d\right)+0.00418\operatorname{exp}\left(-1.9s_d\right)\right) sin\left(\pi s_d\right)\right) \left(w_l+w_g\right)\end{aligned}\end{align} \]
pressure_broadening_HWHM(airbrd, selbrd, Tdpair, Tdpsel, pressure_atm, mole_fraction, Tgas, Tref, diluent, diluent_broadening_coeff)[source]

Calculates collisional broadening HWHM over all lines by scaling tabulated HWHM for new pressure and mole fractions conditions [1]_

Note that collisional broadening is computed with a different coefficient for air broadening and self broadening. In the case of non-air mixtures, then the results should be used with caution, or better, the air broadening coefficient be replaced with the gas broadening coefficient

Parameters:
  • airbrd (array like [length N]) – half-width half max coefficient (HWHM ) for collisional broadening with air

  • selbrd (array like [length N]) – half-width half max coefficient (HWHM ) for resonant (self) broadening with air

  • Tdpair (array like [length N]) – temperature dependance coefficient for collisional broadening with air

  • Tdpsel (array like, optional [length N]) – temperature dependance coefficient for resonant (self) broadening. If None, use Tdpair.

  • pressure_atm (float [atm]) – pressure in atmosphere (warning, not bar!)

  • mole_fraction (float [0-1]) – mole fraction

  • Tgas (float [K]) – (translational) gas temperature

  • Tref (float [K]) – reference temperature at which tabulated HWHM pressure broadening coefficients were tabulated

  • diluent (dictionary) – contains diluent and their mole fraction

  • diluent_broadening_coeff (dictionary) – contains all non air diluents broadening coefficients

Returns:

Depends on the engine used . Vaex Expression are memory efficient Lorentzian half-width at half-maximum (HWHM) for each line profile

Return type:

pandas Series or Vaex Expression [shape N]

References

For self (resonant) and air broadening :

\[\gamma_{lb}={\left(\frac{T_{ref}}{T_{gas}}\right)}^{n_{air}} \gamma_{air} P \left(1-x\right)+{\left(\frac{T_{ref}}{T_{gas}}\right)}^{n_{self}} \gamma_{self} P x\]

With \(n_{air}, n_{self}\) the temperature dependance coefficients Tdpair, Tdpsel ; \(\gamma_{air}, \gamma_{self}\) the air and resonant HWHM broadening tabulated at \(T_{ref}\), \(x\) the mole_fraction.

For multiple diluents with respective mole fractions `x_{air}`, `x_i` , `x_j`, etc. :

\[\gamma_{lb}={\left(\frac{T_{ref}}{T_{gas}}\right)}^{n_{air}} \gamma_{air} P x_{air} +{\left(\frac{T_{ref}}{T_{gas}}\right)}^{n_{self}} \gamma_{self} P x + {\left(\frac{T_{ref}}{T_{gas}}\right)}^{n_{i}} \gamma_{i} P x_{i} + {\left(\frac{T_{ref}}{T_{gas}}\right)}^{n_{i}} \gamma_{j} P x_{j} + ...\]
project_lines_on_grid(df, wavenumber, wstep, dataframe_type='pandas')[source]

Quickly sums all lines on wavespace grid as rectangles of HWHM corresponding to hwhm_voigt and a spectral absorption coefficient value so that linestrength is conserved.

i.e. profiles are approximated as a rectangle of width \(\alpha \cdot FWHM_{Voigt}\), and with the same linestrength.

Parameters:
  • df (pandas Dataframe) – Contains shiftwav (wavenumbers) and S (linestrengths) and hwhm_voigt (Voigt HWHM) size N (number of lines)

  • wavenumber (np.array) – spectral grid. Size W. Expected to be regular

  • wstep (float (cm-1)) – wavenumber step

Returns:

  • k_rough_spectrum (np.array) – spectral absorption coefficient for the waverange wavenumber, calculated by assuming a rectangular profile for each line. Size W

  • S_density_on_grid – average spectral linestrength intensity of each line (abscoeff ~k), assuming rectangular profile. size N

  • line2grid_projection – closest index of the center of each line in df on the spectral grid wavenumber. Size N

project_lines_on_grid_noneq(df, wavenumber, wstep, dataframe_type='pandas')[source]

Quickly sums all lines on wavespace grid as rectangles of HWHM corresponding to hwhm_voigt and a spectral absorption coefficient value so that linestrength is conserved.

i.e. profiles are approximated as a rectangle of width \(\alpha \cdot FWHM_{Voigt}\), and with the same linestrength.

Parameters:
  • df (pandas Dataframe) – Contains shiftwav (wavenumbers) and S (linestrengths) and hwhm_voigt (Voigt HWHM) size N (number of lines)

  • wavenumber (np.array) – spectral grid. Size W. Expected to be regular

  • wstep (float (cm-1)) – wavenumber step

  • quantity (‘S’ or ‘Ei’) – use ‘S’ for Linestrength, ‘Ei’ for emission integral. Default ‘S’

Returns:

  • k_rough_spectrum (np.array) – spectral absorption coefficient for the waverange wavenumber, calculated by assuming a rectangular profile for each line. Size W

  • j_rough_spectrum (np.array) – spectral emission coefficient for the waverange wavenumber, calculated by assuming a rectangular profile for each line. Size W

  • S_density_on_grid – average spectral linestrength intensity of each line (abscoeff ~k), assuming rectangular profile. size N

  • Ei_density_on_grid – average spectral emission intensity of each line (emisscoeff ~j), assuming rectangular profile. size N

  • line2grid_projection – closest index of the center of each line in df on the spectral grid wavenumber. Size N

Notes

Similar to project_lines_on_grid() except that we also calculate the approximate emission intensity (noneq > it cannot be recomputed from the linestrength).

voigt_FT(w_lineshape_ft, hwhmG, hwhmL)[source]

Fourier Transform of a Voigt lineshape

Parameters:
  • w_centered (2D array [one per line: shape W x N]) – waverange (nm / cm-1) (centered on 0)

  • hwhmG (array [shape N = number of lines]) – Half-width at half-maximum (HWHM) of Gaussian

  • hwhmL (array (cm-1) [length N]) – Half-width at half-maximum (HWHM) of Lorentzian

voigt_broadening_HWHM(airbrd, selbrd, Tdpair, Tdpsel, wav, molar_mass, pressure_atm, mole_fraction, Tgas, Tref, diluent, diluent_broadening_coeff)[source]

Calculate Voigt profile half-width at half-maximum (HWHM) from the Gaussian and Collisional broadening with the empirical formula of [Olivero-1977]

Gaussian broadening is calculated with [2]_, Collisional broadening with [3]_

Exact for a pure Gaussian and pure Lorentzian

Parameters:
  • Line parameters [length N]

  • airbrd (np.array [length N] (cm-1/atm)) – air broadening half-width half maximum (HWHM)

  • selbrd (np.array [length N] (cm-1/atm)) – self broadening half-width half maximum (HWHM)

  • Tdpair (np.array [length N]) – temperature dependance of collisional broadening by air

  • Tdpsel (np.array [length N]) – temperature dependance of collisional self-broadening

  • wav (np.array [length N] (cm-1)) – transition wavenumber

  • molar_mass (np.array [length N] (g/mol)) – molar mass for isotope of given transition

  • Environment parameters

  • pressure_atm (float [atm]) – pressure

  • mole_fraction (float [0-1]) – mole fraction

  • Tgas (K) – (translational) gas temperature

  • Tref (K) – reference temperature at which tabulated HWHM pressure broadening coefficients were tabulated

Returns:

gamma_voigt, gamma_lb, gamma_db – Voigt, Lorentz, and Gaussian HWHM

Return type:

numpy array

References

Notes: [Olivero-1977] uses FWHM.

[Olivero-1977] (1,2,3,4,5)

Olivero 1977 “Empirical fits to the Voigt line width: A brief review” Also found in NEQAIR96 Manual.

voigt_lineshape(w_centered, hwhm_lorentz, hwhm_voigt, jit=True)[source]

Calculates Voigt lineshape using the approximation of the Voigt profile of [NEQAIR-1996], [Whiting-1968] that maintains a good accuracy in the far wings. Exact for a pure Gaussian and pure Lorentzian.

Parameters:
  • w_centered (2D array [one per line: shape W x N]) – waverange (nm / cm-1) (centered on 0)

  • hwhm_lorentz (array (cm-1) [length N]) – half-width half maximum coefficient (HWHM) for Lorentzian broadening

  • hwhm_voigt (array (cm-1) [length N]) – half-width half maximum coefficient (HWHM) for Voigt broadening, calculated by voigt_broadening_HWHM()

Other Parameters:

jit (boolean) – if True, use just in time compiler. Usually faster when > 10k lines. Default True.

Returns:

lineshape – line profile

Return type:

pandas Series [shape N x W]

References

whiting1968(w_centered, wl, wv)[source]

A pseudo-voigt analytical approximation.

\[\Phi(w)=\left(1-\frac{w_l}{w_v}\right) \operatorname{exp}\left(-2.772{\left(\frac{w}{w_v}\right)}^{2.25}\right)+\frac{1\frac{w_l}{w_v}}{1+4{\left(\frac{w}{w_v}\right)}^{2.25}}+0.016\left(1-\frac{w_l}{w_v}\right) \frac{w_l}{w_v} \left(\operatorname{exp}\left(-0.4w_{wv,225}\right)-\frac{10}{10+{\left(\frac{w}{w_v}\right)}^{2.25}}\right)\]
Parameters:
  • w_centered (2D array) – broadening spectral range for all lines

  • wl (array) – Lorentzian FWHM

  • wv (array) – Voigt FWHM

References

Used in the expression of [Olivero-1977]

Notes

Performances:

using @jit yield a performance increase from 8.9s down to 5.1s on a 50k lines, 250k wavegrid case (performances.py)

See also

olivero_1977()