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

digraph inheritanceb7d785f131 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "BandFactory" [URL="#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.html#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)"]; }

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: BroadenFactory

See also

SpectrumFactory

NwG[source]
NwL[source]
SpecDatabase[source]
autoretrievedatabase[source]
autoupdatedatabase[source]
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

eq_bands(Tgas, mole_fraction=None, diluent=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 strengths 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()

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

non_eq_bands(Tvib, Trot, Ttrans=None, mole_fraction=None, diluent=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

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

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]
add_bands(df, dbformat, lvlformat, dataframe_type='pandas', 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]