radis.test.lbl.test_factory module

Created on Mon Nov 20 09:59:55 2017

@author: erwan

Examples

Run all tests:

pytest       (in command line, in project folder)

Run only fast tests (i.e: tests that have a ‘fast’ label):

pytest -m fast

test_all_spectrum_using_wstep_auto(verbose=True, plot=False, *args, **kwargs)[source]

Checks all methods to calculate Spectrum works with “auto” mode

test_media_line_shift(plot=False, verbose=True, warnings=True, *args, **kwargs)[source]

See wavelength difference in air and vacuum

test_pathlength_units_conversion(input_pathlength, expected_pathlength_cm, verbose=True, *args, **kwargs)[source]
test_power_integral(verbose=True, warnings=True, *args, **kwargs)[source]

Test direct calculation of power integral from Einstein coefficients matches integration of broadened spectrum in the optically thin case

We compare:

Test passes if error < 0.5%

test_pressure_units_conversion(input_pressure, expected_pressure_bar, verbose=True, *args, **kwargs)[source]
test_spec_generation(plot=True, verbose=2, warnings=True, update_reference_spectrum=False, *args, **kwargs)[source]

Test spectrum generation Can be used as a base to generate spectra in your codes

Non-regression test: compare with past version (see conditions below)

Compare results from a reference case to results calculated on 30/12/2017 This is not a validation case (30/12/2017 results are not a physically validated case), but it makes sure results dont change over time

Conditions (30/12/2017):

Physical Conditions
----------------------------------------
   Tgas                 300 K
   Trot                 300 K
   Tvib                 300 K
   pressure             1.01325 bar
   isotope              1,2
   mole_fraction        1
   molecule             CO2
   path_length          1 cm
   wavelength_max       4400.0 nm
   wavelength_min       4150.0 nm
   wavenum_max          2409.6385542168673 cm-1
   wavenum_min          2272.7272727272725 cm-1
Computation Parameters
----------------------------------------
   Tref                 296 K
   broadening_max_width  10 cm-1
   cutoff               1e-25 cm-1/(#.cm-2)
   db_assumed_sorted    True
   db_use_cached        True
   dbformat             cdsd
   dbpath               # USER-DEPENDANT: CDSD-HITEMP
   fillmissinglevelswithzero  False
   levelsfmt            cdsd
   levelspath           # USER-DEPENDANT: CDSD-4000
   medium               vacuum
   parfuncfmt           cdsd
   parfuncpath          # USER-DEPENDANT: CDSD-4000
   rot_distribution     boltzmann
   self_absorption      True
   vib_distribution     boltzmann
   wavenum_max_calc     2414.6385542168673 cm-1
   wavenum_min_calc     2267.7272727272725 cm-1
   waveunit             cm-1
   wstep                0.01 cm-1
----------------------------------------

Notes

Performance test. How long it took to calculate this Spectrum? Test with cutoff 1e-25, broadening_max_width=10

  • 0.9.15: >>> 33s

  • 0.9.16*: (replaced groupby().apply() with iteration over indexes) >>> 32s

    [but large impact expected on big files]

  • 0.9.16*: (upgraded cache files to h5) >>> 25s

  • 0.9.16*: (also added h5 cache file for levels) >>> 21s

  • 0.9.16*: (with Whiting slit voigt function) >>> 5.8s

Test with cutoff 1e-27, broadening_max_width=50 : (“Spectrum calculated in … “, including database loading time)

  • 0.9.16*: (same code as last) >>> 12.5s including 7.6s of broadening

  • 0.9.16**: (with pseudo_continuum_threshold=0.01) >>> 7.8s including 2.3s of broadening

  • 0.9.18 (normal code, no pseudo continuum). >>> ?

  • 0.9.21 (normal code) >>> 13.7s, including 8.7s of broadening

    (with pseudo_continuum_threshold=0.01) >>> 4.3s, including 2.6s of broadening

  • 0.9.21* >>> 14.0s (added the manual lineshape normalization instead of

    Whitings’s polynomial)

  • 0.9.22 (normal code) >>> 11.3s (without energy level lookup, for eq. calculations)

    (with pseudo_continuum_threshold=0.01) >>> 5.9s

  • 0.9.23 (normal code) >>> 7.2s (added jit in Voigt broadening)
    >>> 7.1s   (chunksize = None)  (and much faster for more lines)
    

    (with pseudo_continuum_threshold=0.01) >>> 4.9s

RADIS:

  • 0.9.19 (normal code) >>> 6.3 s

  • 0.9.20 (normal code) >>> 6.3 s

    (with pseudo_continuum_threshold=0.01) >>> ??? (with LDM) >>> 2.3 s

  • 0.9.26 (normal code) >>> 7.6 s

    (with pseudo_continuum_threshold=0.01) >>> 2.73s (with LDM) >>> 0.25 s

test_temperature_units_conversion(input_temperature, expected_temperature_K, verbose=True, *args, **kwargs)[source]
test_vaex_and_pandas_spectrum()[source]

Compares spectrum calculated using vaex and pandas are same. CONVOLUTED_QUANTITIES and dataframe df is compared to ensure the spectrum is same.

Here are things that we ensure are same for both vaex and pandas that -Spectra calculated with Vaex & Pandas are the same -Spectra calculated with Vaex & Pandas using Database cutoff are the same Added in https://github.com/radis/radis/pull/580

test_vaex_and_pandas_spectrum_noneq()[source]

Compares the Spectrum calculated under non-equilibrium conditions . Comparison is made between CONVOLUTED_QUANTITIES and dataframe df.

Here are things that we ensure are same for both vaex and pandas that -Spectra calculated with Vaex & Pandas are the same -Spectra calculated with Vaex & Pandas using Database cutoff are the same Added in https://github.com/radis/radis/pull/580

test_wavelength_units_conversion(input_wavelengths, expected_wavelengths_nm, verbose=True, *args, **kwargs)[source]
test_wavenumber_units_conversion(input_wavenumbers, expected_wavenumbers_cm1, verbose=True, *args, **kwargs)[source]
test_wstep_auto_method_sf(verbose=True, plot=False, *args, **kwargs)[source]

Test to check that on computing several spectrum from the same Spectrum Factory object we get the different wstep for each case using auto method