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
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
- 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 ofSpectrumFactory
.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_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()
- 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! DefaultTrue
DEPRECATED. Now use export_lines attribute in Factory
- Returns:
Returns
Spectrum
objectUse .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
- 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 databaselvlformat (‘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