radis.spectrum.utils module¶
Functions and constants used in Spectrum
object
- CONFIG_PARAMS = ['GRIDPOINTS_PER_LINEWIDTH_WARN_THRESHOLD', 'GRIDPOINTS_PER_LINEWIDTH_ERROR_THRESHOLD', 'SPARSE_WAVERANGE', 'DEFAULT_DOWNLOAD_PATH'][source]¶
these parameters are read from radis.config and stored in the Spectrum objects. Should be added here only the parameters that may have an impact on the computation, for instance the one defining the ‘auto’ thresholds
- Type:
list
- CONVOLUTED_QUANTITIES = ['radiance', 'transmittance', 'emissivity'][source]¶
name of spectral quantities after convolution with slit function
- Type:
list
- INFORMATIVE_PARAMS = ['db_use_cached', 'lvl_use_cached', 'chunksize', 'calculation_time', 'total_lines', 'lines_calculated', 'lines_cutoff', 'lines_in_continuum', 'Nprocs', 'warning_broadening_threshold', 'warning_linestrength_cutoff', 'load_energies', 'export_lines', 'export_populations', 'levelsfmt', 'wavenum_max_calc', 'wavenum_min_calc', 'dxG', 'dxL', 'export_rovib_fraction', 'parfuncpath'][source]¶
Informative parameters. Parameters that should be saved in the Spectrum objects, but ignored when comparing two spectra. Should be written here only these parameters that cannot affect the physical result. In particular, all parameters relative to performance should be added here.
Notes
units for these parameters are stored in Spectrum.cond_units and are defined by the generating class (ex: SpectrumFactory)
- Type:
list
- NON_CONVOLUTED_QUANTITIES = ['radiance_noslit', 'transmittance_noslit', 'emisscoeff', 'emisscoeff_continuum', 'absorbance', 'abscoeff', 'abscoeff_continuum', 'emissivity_noslit', 'xsection'][source]¶
name of spectral quantities not convolved with slit function
See the description of spectral arrays
- Type:
list
- PHYSICAL_PARAMS = ['molecule', 'wavenum_max', 'wavenum_min', 'mole_fraction', 'isotope', 'state', 'path_length', 'medium', 'self_absorption', 'slit_function_base', 'pressure', 'wavelength_min', 'wavelength_max', 'Telec', 'Tvib', 'Trot', 'Tgas', 'vib_distribution', 'rot_distribution', 'overpopulation', 'thermal_equilibrium'][source]¶
physical conditions under which the Spectrum was calculated/measured. When printing an object, these parameters are shown below “Physical Conditions” If a parameter is not in this list, it is either in “Computation Parameters” (non-physical parameters that can have an influence on the Spectrum, e.g, cutoffs and thresholds) or in “Informative Params” (descriptive parameters that have absolutely no impact on the spectrum, e.g, number of lines calculated or calculation time)
- Type:
list
- SPECTRAL_QUANTITIES = ['radiance', 'transmittance', 'emissivity', 'radiance_noslit', 'transmittance_noslit', 'emisscoeff', 'emisscoeff_continuum', 'absorbance', 'abscoeff', 'abscoeff_continuum', 'emissivity_noslit', 'xsection'][source]¶
all spectral quantities defined in a
Spectrum
object.See the description of spectral arrays
- Type:
list
- WAVESPACE = ['nm', 'nm_vac', 'cm-1'][source]¶
wavespace: -
'nm'
: wavelength (in air) -'nm_vac'
: wavelength (in vacuum) -'cm-1'
: wavenumber- Type:
list
- cast_waveunit(unit, force_match=True)[source]¶
Standardize unit formats, return either “nm”, “nm_vac” or “cm-1”.
- dict_to_tree(pro, name)[source]¶
- Parameters:
pro (dict) –
of the form:
{"value":float, # keyword 'value' is expected "some_key":float "some_key2":float, "some_key3":dict # nested dict of the same form "some_key4":dict}
name (str)
- Returns:
dict – Tree = {“name”: str,
”value”:float, “children”:[list of Tree]}
- Return type:
of the form
See also
Used
,generate_perf_profile()
- format_xlabel(wunit, plot_medium)[source]¶
Used by
radis.spectrum.spectrum.Spectrum.plot()
andradis.spectrum.compare.plot_diff()
- Parameters:
wunit (
'default'
,'nm'
,'cm-1'
,'nm_vac'
,) – wavelength air, wavenumber, or wavelength vacuum. If'default'
, Spectrumget_waveunit()
is used.plot_medium (bool,
'vacuum_only'
) – ifTrue
andwunit
are wavelengths, plot the propagation medium in the xaxis label ([air]
or[vacuum]
). If'vacuum_only'
, plot only ifwunit=='nm_vac'
. Default'vacuum_only'
(prevents from inadvertently plotting spectra with different propagation medium on the same graph).
- generate_perf_profile(profiler)[source]¶
Visual/interactive performance profile
Requires
tuna
to be installed.See typical output in https://github.com/radis/radis/pull/325
Note
You can also profile with
tuna
directly:python -m cProfile -o program.prof your_radis_script.py tuna your_radis_script.py
- Parameters:
profiler (dict) –
- of the form::
- {“value”:float, # keyword ‘value’ is expected
“some_key”:float “some_key2”:float, “some_key3”:dict # nested dict of the same form “some_key4”:dict}
See also
generate_perf_profile()
- make_up_unit(Iunit, var)[source]¶
Additional cosmetic changes for units on label, before plot.
- Parameters:
Iunit (str) – input unit
var (str) – spectral variable. Ex:
transmittance
- print_conditions(conditions, units, phys_param_list=['molecule', 'wavenum_max', 'wavenum_min', 'mole_fraction', 'isotope', 'state', 'path_length', 'medium', 'self_absorption', 'slit_function_base', 'pressure', 'wavelength_min', 'wavelength_max', 'Telec', 'Tvib', 'Trot', 'Tgas', 'vib_distribution', 'rot_distribution', 'overpopulation', 'thermal_equilibrium'], info_param_list=['db_use_cached', 'lvl_use_cached', 'chunksize', 'calculation_time', 'total_lines', 'lines_calculated', 'lines_cutoff', 'lines_in_continuum', 'Nprocs', 'warning_broadening_threshold', 'warning_linestrength_cutoff', 'load_energies', 'export_lines', 'export_populations', 'levelsfmt', 'wavenum_max_calc', 'wavenum_min_calc', 'dxG', 'dxL', 'export_rovib_fraction', 'parfuncpath'], config_param_list=['GRIDPOINTS_PER_LINEWIDTH_WARN_THRESHOLD', 'GRIDPOINTS_PER_LINEWIDTH_ERROR_THRESHOLD', 'SPARSE_WAVERANGE', 'DEFAULT_DOWNLOAD_PATH'], verbose=2)[source]¶
Print all Spectrum calculation parameters.
- Parameters:
phys_param_list (list) – These parameters are shown below “Physical Conditions” rather than “Computation Parameters. See
PHYSICAL_PARAMS
for more information.info_param_list (list) – These parameters are shown below “Information” rather than “Computation Parameters. See
INFORMATIVE_PARAMS
for more information.config_param_list (list) – These parameters are read from radis.config file. See
CONFIG_PARAMS
for more information.verbose (int) – if
1
orTrue
, only physical and computational parameters are shown. If2
, all parameters (including config & informative) are shown. Default2
.
See also
- print_perf_profile(profiler, total_time=None, number_format='{:.3f}', precision=16, first_line='profiler :')[source]¶
Prints Profiler output dictionary in a structured manner.
- Parameters:
profiler (dict) –
- of the form::
- {“value”:float, # keyword ‘value’ is expected
“some_key”:float “some_key2”:float, “some_key3”:dict # nested dict of the same form “some_key4”:dict}
- Other Parameters:
total_time (float) – total calculation time. If
None
, take the key"value"
ofprofiler
precision (int, optional) – total number of blocks. Default 16.
Example
Spectrum.print_perf_profile() # output >> spectrum_calculation 0.189s ████████████████ check_line_databank 0.000s check_non_eq_param 0.042s ███ fetch_energy_5 0.015s █ calc_weight_trans 0.008s reinitialize 0.002s copy_database 0.000s memory_usage_warning 0.002s reset_population 0.000s calc_noneq_population 0.041s ███ part_function 0.035s ██ population 0.006s scaled_non_eq_linestrength 0.005s map_part_func 0.001s corrected_population_se 0.003s calc_emission_integral 0.006s applied_linestrength_cutoff 0.002s calc_lineshift 0.001s calc_hwhm 0.007s generate_wavenumber_arrays 0.001s calc_line_broadening 0.074s ██████ precompute_LDM_lineshapes 0.012s LDM_Initialized_vectors 0.000s LDM_closest_matching_line 0.001s LDM_Distribute_lines 0.001s LDM_convolve 0.060s █████ others 0.001s calc_other_spectral_quan 0.003s generate_spectrum_obj 0.000s others -0.016s
See also