radis.lbl.bands module

Module that contains BandFactory, a class that features vibrational band-specific functions, in particular the eq_bands() and non_eq_bands() methods that return all vibrational bands in a spectrum.

All of these are eventually integrated in SpectrumFactory which inherits from BandFactory

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

DatabankLoader > BaseFactory > BroadenFactory > BandFactory > SpectrumFactory

Inheritance diagram of radis.lbl.factory.SpectrumFactory

Routine Listing

PUBLIC METHODS

PRIVATE METHODS

  • _add_bands

  • _broaden_lines_bands

  • _broaden_lines_noneq_bands

  • _calc_broadening_bands

  • _calc_broadening_noneq_bands


class BandFactory[source]

Bases: radis.lbl.broadening.BroadenFactory

See also

SpectrumFactory

eq_bands(Tgas, mole_fraction=None, path_length=None, pressure=None, levels='all', drop_lines=True)[source]

Return all vibrational bands as a list of spectra for a spectrum calculated under equilibrium.

By default, drop_lines is set to True so line_survey cannot be done on spectra. See drop_lines for more information

Parameters
  • Tgas (float) – Gas temperature (K)

  • mole_fraction (float) – database species mole fraction. If None, Factory mole fraction is used.

  • path_length (float) – slab size (cm). If None, Factory mole fraction is used.

  • pressure (float) – pressure (bar). If None, the default Factory pressure is used.

Other Parameters
  • levels ('all', int, list of str) – calculate only bands that feature certain levels. If 'all', all bands are returned. If N (int), return bands for the first N levels (sorted by energy). If list of str, return for all levels in the list. The remaining levels are also calculated and returned merged together in the 'others' key. Default 'all'

  • drop_lines (boolean) – if False remove the line database from each bands. Helps save a lot of space, but line survey cannot be performed anymore. Default True.

Returns

  • bands (list of Spectrum objects)

  • Use .get(something) to get something among [‘radiance’, ‘radiance_noslit’, – ‘absorbance’, etc…]

  • Or directly .plot(something) to plot it

Notes

Process:

  • Calculate line strenghts correcting the CDSD reference one.

  • Then call the main routine that sums over all lines

get_band(band)[source]

Public function to get a particular vibrational band.

get_band_list()[source]

Return all vibrational bands.

get_bands_weight(showfirst=None, sortby='Ei')[source]

Show all bands by emission weight (fraction of total emission integral)

Replace sortby with ‘S’ or ‘int’ to get different weights

Note: this function works with .df1 (scaled lines) instead of .df0 (reference lines) as we may want the weight for different temperatures. .df1 is updated after *eq_spectrum or non_eq_spectrum is called

See also

get_bands()

non_eq_bands(Tvib, Trot, Ttrans=None, mole_fraction=None, path_length=None, pressure=None, vib_distribution='boltzmann', rot_distribution='boltzmann', levels='all', return_lines=None)[source]

Calculate vibrational bands in non-equilibrium case. Calculates absorption with broadened linestrength and emission with broadened Einstein coefficient.

Parameters
  • Tvib (float) – vibrational temperature [K] can be a tuple of float for the special case of more-than-diatomic molecules (e.g: CO2)

  • Trot (float) – rotational temperature [K]

  • Ttrans (float) – translational temperature [K]. If None, translational temperature is taken as rotational temperature (valid at 1 atm for times above ~ 2ns which is the RT characteristic time)

  • mole_fraction (float) – database species mole fraction. If None, Factory mole fraction is used.

  • path_length (float) – slab size (cm). If None, Factory mole fraction is used.

  • pressure (float) – pressure (bar). If None, the default Factory pressure is used.

Other Parameters
  • levels ('all', int, list of str) – calculate only bands that feature certain levels. If 'all', all bands are returned. If N (int), return bands for the first N levels (sorted by energy). If list of str, return for all levels in the list. The remaining levels are also calculated and returned merged together in the 'others' key. Default 'all'

  • return_lines (boolean) – if True returns each band with its line database. Can produce big spectra! Default True DEPRECATED. Now use export_lines attribute in Factory

Returns

  • Returns Spectrum object

  • Use .get(something) to get something among [‘radiance’, ‘radiance_noslit’,

  • ’absorbance’, etc…]

  • Or directly .plot(something) to plot it

add_bands(df, dbformat, lvlformat, verbose=True)[source]

Assign all transitions to a vibrational band:

Add ‘band’, ‘viblvl_l’ and ‘viblvl_u’ attributes for each line to allow parsing the lines by band with:

df0.groupby('band')
Parameters
  • df (pandas Dataframe) – Line (transitions) database

  • dbformat (one of KNOWN_DBFORMAT : 'cdsd`, 'hitemp') – format of Line database

  • lvlformat (‘cdsd`, ‘hitemp’) – format of

Returns

input Dataframe is updated inplace

Return type

None

Examples

Add transitions in a Dataframe based on CDSD (p, c, j, n) format:

add_bands(df, 'cdsd-4000')

Notes

Performance with test case (CDSD CO2 2380-2400 cm-1):

  • Initial: with .apply() 8.08 s ± 95.2 ms

  • with groupby(): 9s worse!!

  • using simple (and more readable) astype(str) statements: 523 ms ± 19.6 ms

docstring_parameter(*sub)[source]