radis.spectrum.utils module

Functions and constants used in Spectrum object


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'][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'][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_mbar', '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'][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.

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() and radis.spectrum.compare.plot_diff()

Parameters
  • wunit ('default', 'nm', 'cm-1', 'nm_vac',) – wavelength air, wavenumber, or wavelength vacuum. If 'default', Spectrum get_waveunit() is used.

  • plot_medium (bool, 'vacuum_only') – if True and wunit are wavelengths, plot the propagation medium in the xaxis label ([air] or [vacuum]). If 'vacuum_only', plot only if wunit=='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

See typical output in https://github.com/radis/radis/pull/325

https://user-images.githubusercontent.com/16088743/128018032-6049be72-1881-46ac-9d7c-1ed89f9c4f42.png

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(label)[source]

Cosmetic changes on label, before plot.

Parameters

label (str)

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_mbar', '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'])[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.

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" of profiler

  • 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_DLM_lineshapes        0.012s
            DLM_Initialized_vectors          0.000s
            DLM_closest_matching_line        0.001s
            DLM_Distribute_lines             0.001s
            DLM_convolve                     0.060s █████
            others                           0.001s
        calc_other_spectral_quan         0.003s
        generate_spectrum_obj            0.000s
        others                           -0.016s
split_and_plot_by_parts(w, I, *args, **kwargs)[source]