Beispiel #1
0
def comperr(Nnu, plotfig=False):

    nus = np.logspace(np.log10(1.e7 / 2700),
                      np.log10(1.e7 / 2100.),
                      Nnu,
                      dtype=np.float64)

    #    nus=np.logspace(np.log10(3000),np.log10(6000.0),Nnu,dtype=np.float64)
    mdbCO = moldb.MdbHit('/home/kawahara/exojax/data/CO/05_hit12.par', nus)

    Mmol = 28.010446441149536
    Tref = 296.0
    Tfix = 1000.0
    Pfix = 1.e-3  #

    #USE TIPS partition function
    Q296=np.array([107.25937215917970,224.38496958496091,112.61710362499998,\
                   660.22969049609367,236.14433662109374,1382.8672147421873])
    Q1000=np.array([382.19096582031250,802.30952197265628,402.80326733398437,\
                    2357.1041210937501,847.84866308593757,4928.7215078125000])
    qr = Q1000 / Q296

    qt = np.ones_like(mdbCO.isoid, dtype=np.float64)
    for idx, iso in enumerate(mdbCO.uniqiso):
        mask = mdbCO.isoid == iso
        qt[mask] = qr[idx]

    Sij = SijT(Tfix, mdbCO.logsij0, mdbCO.nu_lines, mdbCO.elower, qt)
    gammaL = gamma_hitran(Pfix, Tfix, Pfix, mdbCO.n_air, mdbCO.gamma_air,
                          mdbCO.gamma_self)
    #+ gamma_natural(A) #uncomment if you inclide a natural width
    sigmaD = doppler_sigma(mdbCO.nu_lines, Tfix, Mmol)

    cnu, indexnu, R, dq = initspec.init_modit(mdbCO.nu_lines, nus)
    nsigmaD = normalized_doppler_sigma(Tfix, Mmol, R)
    ngammaL = gammaL / (mdbCO.nu_lines / R)
    ngammaL_grid = set_ditgrid(ngammaL)

    xs_modit_lp = modit_xsvector(cnu, indexnu, R, dq, nsigmaD, ngammaL, Sij,
                                 nus, ngammaL_grid)
    wls_modit = 100000000 / nus

    #ref (direct)
    d = 10000
    ll = mdbCO.nu_lines
    xsv_lpf_lp = lpf_xsection(nus, ll, sigmaD, gammaL, Sij, memory_size=30)

    dif = xs_modit_lp / xsv_lpf_lp - 1.
    med = np.median(dif)
    iju = 22940.
    ijd = 26400.
    limu, limd = np.searchsorted(wls_modit[::-1], [iju, ijd])
    std = np.std(dif[::-1][limu:limd])

    return med, std, R, ijd, iju, wls_modit, xs_modit_lp, xsv_lpf_lp, dif
Beispiel #2
0
 def init_database(self):
     molpath = pathlib.Path(self.databasedir) / pathlib.Path(
         self.identifier)
     if self.database == 'HITRAN' or self.database == 'HITEMP':
         self.mdb = moldb.MdbHit(molpath,
                                 nurange=[self.nus[0], self.nus[-1]],
                                 crit=self.crit)
     elif self.database == 'ExoMol':
         print('broadf=', self.broadf)
         self.mdb = moldb.MdbExomol(molpath,
                                    nurange=[self.nus[0], self.nus[-1]],
                                    broadf=self.broadf,
                                    crit=self.crit)
     else:
         print('Select database from HITRAN, HITEMP, ExoMol.')
Beispiel #3
0
def ap(fobs, nusd, ws, we, Nx):
    mask = (ws < wavd[::-1]) * (wavd[::-1] < we)
    #additional mask
    mask = mask * ((22898.5 > wavd[::-1]) + (wavd[::-1] > 22899.5))

    fobsx = fobs[mask]
    nusdx = nusd[mask]
    wavdx = 1.e8 / nusdx[::-1]
    errx = err[mask]
    nus, wav, res = nugrid(ws - 5.0, we + 5.0, Nx, unit="AA")
    #loading molecular database
    #mdbCO=moldb.MdbExomol('.database/CO/12C-16O/Li2015',nus)
    mdbCO = moldb.MdbHit('05_HITEMP2019.par.bz2', nus)
    mdbCO.ExomolQT('.database/CO/12C-16O/Li2015')

    ##use HITEMP later
    mdbH2O = moldb.MdbExomol('H2O/1H2-16O/POKAZATEL', nus, crit=1.e-45)
    #    mdbH2O=moldb.MdbExomol('.database/H2O/1H2-16O/POKAZATEL',nus)

    print("resolution=", res)

    #LOADING CIA
    cdbH2H2 = contdb.CdbCIA('H2-H2_2011.cia', nus)
    cdbH2He = contdb.CdbCIA('H2-He_2011.cia', nus)

    ### REDUCING UNNECESSARY LINES
    #######################################################

    #1. CO
    Tarr = T0c * np.ones_like(Parr)
    qt = vmap(mdbCO.qr_interp)(Tarr)
    #    gammaL = gamma_hitran(Pfix,Tfix, Ppart, mdbCO.n_air, \
    #                          mdbCO.gamma_air, mdbCO.gamma_self) \
    gammaLMP = jit(vmap(gamma_hitran,(0,0,0,None,None,None)))\
        (Parr*0.99,Tarr,Parr*0.01,mdbCO.n_air,mdbCO.gamma_air,mdbCO.gamma_self)
    gammaLMN = gamma_natural(mdbCO.A)

    #(Nlayer, Nlines)+(None, Nlines)=(Nlayers, Nlines)
    gammaLM = gammaLMP + gammaLMN[None, :]

    SijM=jit(vmap(SijT,(0,None,None,None,0)))\
        (Tarr,mdbCO.logsij0,mdbCO.nu_lines,mdbCO.elower,qt)
    sigmaDM=jit(vmap(doppler_sigma,(None,0,None)))\
        (mdbCO.nu_lines,Tarr,molmassCO)

    mask_CO, maxcf, maxcia = mask_weakline(mdbCO, Parr, dParr, Tarr, SijM,
                                           gammaLM, sigmaDM,
                                           maxMMR_CO * ONEARR, molmassCO, mmw,
                                           g, vmrH2, cdbH2H2)
    mdbCO.masking(mask_CO)

    plot_maxpoint(mask_CO, Parr, maxcf, maxcia, mol="CO")
    plt.savefig("npz/maxpoint_CO.pdf", bbox_inches="tight", pad_inches=0.0)
    #2. H2O
    T0xarr = list(range(500, 1800, 100))
    for k, T0x in enumerate(T0xarr):
        Tarr = T0x * np.ones_like(Parr)

        qt = vmap(mdbH2O.qr_interp)(Tarr)
        gammaLMP = jit(vmap(gamma_exomol,(0,0,None,None)))\
            (Parr,Tarr,mdbH2O.n_Texp,mdbH2O.alpha_ref)
        gammaLMN = gamma_natural(mdbH2O.A)
        gammaLM = gammaLMP + gammaLMN[None, :]
        SijM=jit(vmap(SijT,(0,None,None,None,0)))\
            (Tarr,mdbH2O.logsij0,mdbH2O.nu_lines,mdbH2O.elower,qt)
        sigmaDM=jit(vmap(doppler_sigma,(None,0,None)))\
            (mdbH2O.nu_lines,Tarr,molmassH2O)

        mask_H2O_tmp, maxcf, maxcia = mask_weakline(mdbH2O, Parr, dParr, Tarr,
                                                    SijM, gammaLM, sigmaDM,
                                                    maxMMR_H2O * ONEARR,
                                                    molmassH2O, mmw, g, vmrH2,
                                                    cdbH2H2)
        if k == 0:
            mask_H2O = np.copy(mask_H2O_tmp)
        else:
            mask_H2O = mask_H2O + mask_H2O_tmp

        if T0x == 1700.0:
            plot_maxpoint(mask_H2O_tmp, Parr, maxcf, maxcia, mol="H2O")
            plt.savefig("maxpoint_H2O.pdf",
                        bbox_inches="tight",
                        pad_inches=0.0)

    mdbH2O.masking(mask_H2O)
    print("Final:", len(mask_H2O), "->", np.sum(mask_H2O))

    #nu matrix
    numatrix_CO = make_numatrix0(nus, mdbCO.nu_lines)
    numatrix_H2O = make_numatrix0(nus, mdbH2O.nu_lines)
    cdbH2H2 = contdb.CdbCIA('.database/H2-H2_2011.cia', nus)
    cdbH2He = contdb.CdbCIA('.database/H2-He_2011.cia', nus)

    return fobsx, nusdx, wavdx, errx, nus, wav, res, mdbCO, mdbH2O, numatrix_CO, numatrix_H2O, cdbH2H2, cdbH2He
Beispiel #4
0
from exojax.spec import xsection as lpf_xsection
from exojax.spec import initspec
from exojax.spec.modit import xsvector as modit_xsvector
from exojax.spec.lpf import xsvector as lpf_xsvector
from exojax.spec import make_numatrix0
import numpy as np
import tqdm
import jax.numpy as jnp
from jax import vmap
import seaborn as sns
import matplotlib.pyplot as plt

plt.style.use('bmh')

nus = np.logspace(np.log10(4000), np.log10(4500.0), 3000000, dtype=np.float64)
mdbCO = moldb.MdbHit('/home/kawahara/exojax/data/CO/05_hit12.par', nus)

Mmol = 28.010446441149536
Tref = 296.0
Tfix = 1000.0
Pfix = 1.e-3

# USE TIPS partition function
Q296 = np.array([
    107.25937215917970, 224.38496958496091, 112.61710362499998,
    660.22969049609367, 236.14433662109374, 1382.8672147421873
])
Q1000 = np.array([
    382.19096582031250, 802.30952197265628, 402.80326733398437,
    2357.1041210937501, 847.84866308593757, 4928.7215078125000
])
from exojax.spec import xsection
from exojax.spec.hitran import SijT, doppler_sigma, gamma_hitran, gamma_natural
from exojax.spec.exomol import gamma_exomol
from exojax.spec import moldb
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
import time
# Setting wavenumber bins and loading HITEMP database
wav = np.linspace(16370.0, 16390.0, 2000, dtype=np.float64)  # AA
nus = 1.e8/wav[::-1]  # cm-1
ts = time.time()
mdbCO_HITEMP = moldb.MdbHit(
    '/home/kawahara/exojax/data/CH4/06_HITEMP2020.par.bz2', nus, extract=True)
te = time.time()
print(te-ts, 'sec')