HajimeKawahara / exojax

🐈 Automatic differentiable spectrum modeling of exoplanets/brown dwarfs using JAX, compatible with NumPyro and JAXopt
http://secondearths.sakura.ne.jp/exojax/
MIT License
45 stars 14 forks source link

Negative self.n_air for HITRAN/HITEMP #327

Closed ykawashima closed 1 year ago

ykawashima commented 1 year ago

It seems that some HITRAN/HITEMP database (e.g., HITRAN/HITEMP H2O) contains negative self.n_air values. Should they indeed be positive as written here? Thank you.

erwanp commented 1 year ago

They should be, it's for sure a glitch during the generation of the database. I'd either discard all lines or take the n_self value (if given), and report to the HITRAN team

ykawashima commented 1 year ago

Thank you very much for your comment! I understand. Then, I will discard those lines.

HajimeKawahara commented 1 year ago

@erwanp Do you know why the temperature exponent (n_air) should be positive?

erwanp commented 1 year ago

My bad, the gamma_air should obviously be positive but n_air shouldn't. I'll have a second look

HajimeKawahara commented 1 year ago

I see, thanks. So, this issue should be tagged as "bug".

HajimeKawahara commented 1 year ago

Just note: slight deviation between PreMODIT and MODIT (only for HiTEMP not ExoMol) originates from this bug?

HajimeKawahara commented 1 year ago

Maybe I encountered this error. When using HITRAN and MODIT for CO.

   opa = OpaModit(mdb=mdb, nu_grid=nu_grid, Tarr_list=Tarr, Parr=np.zeros_like(art.pressure), Pself_ref = art.pressure)
  File "/home/kawahara/exojax/src/exojax/spec/opacalc.py", line 266, in __init__
    self.setdgm(Tarr_list, Parr, Pself_ref=Pself_ref)
  File "/home/kawahara/exojax/src/exojax/spec/opacalc.py", line 352, in setdgm
    dgm_ngammaL = precompute_modit_ditgrid_matrix(
  File "/home/kawahara/exojax/src/exojax/spec/set_ditgrid.py", line 145, in precompute_modit_ditgrid_matrix
    grid = np.logspace(lxmin, lxmax, Ng)
  File "<__array_function__ internals>", line 5, in logspace
  File "/home/kawahara/anaconda3/lib/python3.8/site-packages/numpy/core/function_base.py", line 275, in logspace
    y = linspace(start, stop, num=num, endpoint=endpoint, axis=axis)
  File "<__array_function__ internals>", line 5, in linspace
  File "/home/kawahara/anaconda3/lib/python3.8/site-packages/numpy/core/function_base.py", line 122, in linspace
    raise ValueError("Number of samples, %s, must be non-negative." % num)
ValueError: Number of samples, -9223372036854775806, must be non-negative.
HajimeKawahara commented 1 year ago
""" ISSUE 327"""
from jax.config import config
import numpy as np
from exojax.utils.grids import wavenumber_grid
from exojax.spec.opacalc import OpaModit
from exojax.spec.atmrt import ArtTransPure
from exojax.spec.api import MdbHitran

config.update("jax_enable_x64", True)

def hitran_co_modit():
    Nx = 300000
    nu_grid, wav, res = wavenumber_grid(22900.0,
                                        26000.0,
                                        Nx,
                                        unit="AA",
                                        xsmode="modit")
    art = ArtTransPure(nu_grid,
                       pressure_top=1.e-15,
                       pressure_btm=1.e1,
                       nlayer=100)
    Tarr = 500.0 * np.ones_like(art.pressure)
    #mdb = api.MdbExomol('.database/CO/12C-16O/Li2015',nu_grid,inherit_dataframe=False,gpu_transfer=False)
    mdb = MdbHitran('CO', art.nu_grid, gpu_transfer=True, isotope=1)

    opa = OpaModit(mdb=mdb,
                   nu_grid=nu_grid,
                   Tarr_list=Tarr,
                   Parr=np.zeros_like(art.pressure),
                   Pself_ref=art.pressure)  #unknown error

if __name__ == "__main__":
    hitran_co_modit()