radis / radis

🌱 A fast line-by-line code for high-resolution infrared molecular spectra
http://radis.github.io/
GNU Lesser General Public License v3.0
214 stars 126 forks source link

Error when levelsfmt not defined in Configuration File for NonEquilibrium calcul #80

Closed CorentinGrimaldi closed 3 years ago

CorentinGrimaldi commented 4 years ago

Context

~/.radis

[DB_ISSUE_80]
info = ... 
path =
        PATH/TO/cdsd_hitemp_07
format = cdsd-hitemp
parfuncfmt = hapi

Note that levelsfmt is not declared

Minimal code:

s = calc_spectrum(wavenum_min=2050, 
            wavenum_max=2100,
            Tgas=4500, 
            Trot=4499,
            Tvib=5001,
            pressure=1.01325,       # bar
            mole_fraction=1e-3,
            isotope='1,2,3,4',
            path_length=1,        # cm
            databank='DB_ISSUE_80',
            )

Expected Behavior

levelsfmt is not declared --> we could expect that it use the RADIS built-in spectroscopic constants by default.

Current Behavior

Crashes later with:

Traceback (most recent call last):
  File "<ipython-input-33-79986cf35618>", line 11, in <module>
    databank='DB_ISSUE_80',
  File "/home/corentin/radis/radis/lbl/calc.py", line 411, in calc_spectrum
    name=name,
  File "/home/corentin/radis/radis/lbl/factory.py", line 960, in non_eq_spectrum
    self._check_noneq_parameters(vib_distribution, singleTvibmode)
  File "/home/corentin/radis/radis/lbl/base.py", line 1535, in _check_noneq_parameters
    calc_Evib_harmonic_anharmonic=calc_Evib_harmonic_anharmonic
  File "/home/corentin/radis/radis/lbl/base.py", line 1619, in _calc_noneq_parameters
    df, calc_Evib_harmonic_anharmonic=calc_Evib_harmonic_anharmonic
  File "/home/corentin/radis/radis/lbl/base.py", line 394, in _add_EvibErot
    + "format: {0}".format(self.params.levelsfmt)
NotImplementedError: Impossible to calculate Evib Erot with given energy format: None

Possible Solution

If None, use default values (i.e. RADIS built-in spectroscopic constants) as levelsfmt = radis

erwanp commented 4 years ago

Similar to #78 for partfuncfmt instead of levelsfmt.

Agreed ?