arunavabasucom / radis-app

A web app for high-resolution infrared molecular spectra using RADIS
https://radis.app
GNU Lesser General Public License v3.0
11 stars 15 forks source link

bug computing NO #472

Closed erwanp closed 2 years ago

erwanp commented 2 years ago

12AD-6182BF80-3-54864C00

Returns a weird unsupported operand type(s) for /: 'float' and 'NoneType' error

erwanp commented 2 years ago

If I run it from Python

from radis import calc_spectrum
s = calc_spectrum(1899, 1900.5,         # cm-1
                  molecule='NO',
                  isotope='1',
                  pressure=1.01325,   # bar
                  Tgas=5380,           # K
                  mole_fraction=0.1,
                  path_length=0.1,      # cm
                  databank='hitran',  # or use 'hitemp'
                  )
s.apply_slit(0.5, 'nm')       # simulate an experimental slit
s.plot('radiance')

It fails but with a different and more explicit error :


  File "d:\github\radis\radis\lbl\base.py", line 2174, in Qref_Qgas_ratio
    Qref, Qgas = _calc_Q(molecule, iso, state)

  File "d:\github\radis\radis\lbl\base.py", line 2080, in _calc_Q
    raise err

  File "d:\github\radis\radis\lbl\base.py", line 2070, in _calc_Q
    Qgas = parsum.at(Tgas)

  File "d:\github\radis\radis\levels\partfunc.py", line 163, in at
    return self._at(T)

  File "d:\github\radis\radis\levels\partfunc.py", line 1215, in _at
    raise OutOfBoundError(

OutOfBoundError: Partition functions not computed in TIPS for molecule NO, isotope 1. Max range : TIPS2017: T(5380.0K) must be between 1.0K and 3500.0K.

(which is fine, and should be returned as-is to the user)

However the error seem to be different above.

suzil commented 2 years ago

@erwanp Here is the stack trace:

START RequestId: ce03ff71-8470-4442-acb5-e500df915bf4 Version: $LATEST
Payload {'species': [{'molecule': 'NO', 'mole_fraction': 0.001}], 'min_wavenumber_range': 1900, 'max_wavenumber_range': 2300, 'tgas': 5380, 'tvib': None, 'trot': None, 'pressure': 1, 'path_length': 4, 'simulate_slit': False, 'mode': 'absorbance'}
Using cache file: /tmp/.astropy/cache/astroquery/Hitran/tempfile_NO_1_1900.00_2300.00.h5
/var/task/radis/misc/warning.py:350: HighTemperatureWarning: HITRAN is valid for low temperatures (typically < 700 K). For higher temperatures you may need HITEMP or CDSD. See the 'databank=' parameter
warnings.warn(WarningType(message))
Calculating Equilibrium Spectrum
Physical Conditions
----------------------------------------
Tgas                 5380 K
Trot                 5380 K
Tvib                 5380 K
isotope              1
mole_fraction        0.001
molecule             NO
overpopulation       None
path_length          4 cm
pressure_mbar        1000.0 mbar
rot_distribution     boltzmann
self_absorption      True
state                X
vib_distribution     boltzmann
wavenum_max          2300.0000 cm-1
wavenum_min          1900.0000 cm-1
Computation Parameters
----------------------------------------
Tref                 296 K
add_at_used          None
broadening_method    voigt
cutoff               1e-27 cm-1/(#.cm-2)
dbformat             hitran
dbpath               fetched from hitran
dlm_log_pG           0.1375350788016573
dlm_log_pL           0.20180288881201608
export_rovib_fraction  True
folding_thresh       1e-06
hdf5_engine          pytables
include_neighbouring_lines  True
levelsfmt            None
neighbour_lines      0 cm-1
optimization         min-RMS
parfuncfmt           hapi
parfuncpath          None
parsum_mode          full summation
pseudo_continuum_threshold  0
truncation           50 cm-1
wavenum_max_calc     2300.0000 cm-1
wavenum_min_calc     1900.0000 cm-1
waveunit             cm-1
wstep                0.01 cm-1
zero_padding         -1
Information
----------------------------------------
chunksize            None
db_use_cached        True
export_lines         False
export_populations   None
load_energies        False
lvl_use_cached       True
total_lines          7093
warning_broadening_threshold  0.01
warning_linestrength_cutoff  0.01
----------------------------------------
Traceback (most recent call last):
File "/var/task/app.py", line 23, in lambda_handler
spectrum = radis.calc_spectrum(
File "/var/task/radis/lbl/calc.py", line 447, in calc_spectrum
_calc_spectrum(
File "/var/task/radis/lbl/calc.py", line 708, in _calc_spectrum
s = sf.eq_spectrum(
File "/var/task/radis/lbl/factory.py", line 743, in eq_spectrum
self.calc_linestrength_eq(Tgas)  # scales S0 to S (equivalent to S0 in code)
File "/var/task/radis/lbl/base.py", line 2178, in calc_linestrength_eq
* Qref_Qgas_ratio()
File "/var/task/radis/lbl/base.py", line 2164, in Qref_Qgas_ratio
Qref_Qgas = Qref / Qgas
TypeError: unsupported operand type(s) for /: 'float' and 'NoneType'
erwanp commented 2 years ago

I managed to reproduce the error on Radis-Lab with my test code above. Somehow the error handling is different on Windows & Linux.

Should be fixed soon.

erwanp commented 2 years ago

Error found : improper exception handling on the Radis side, revealed by devices using the latest HAPI.py version. Fixed in next RADIS version (--> the errors will still be triggered, but with a proper "Out of Range Temperature" message )

erwanp commented 2 years ago

Now crashes with proper message with RADIS 0.11.1

image