Exemple #1
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
Exemple #2
0
def ap(fobs, nusd, ws, we, Nx):
    mask = (ws < wavd[::-1]) * (wavd[::-1] < we)
    #additional mask to remove a strong telluric
    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)
    mdbH2O = moldb.MdbExomol('.database/H2O/1H2-16O/POKAZATEL',
                             nus,
                             crit=1.e-46)
    #LOADING CIA
    cdbH2H2 = contdb.CdbCIA('.database/H2-H2_2011.cia', nus)
    cdbH2He = contdb.CdbCIA('.database/H2-He_2011.cia', nus)

    #REDUCING UNNECESSARY LINES
    #1. CO
    Tarr = T0c * np.ones_like(Parr)
    qt = vmap(mdbCO.qr_interp)(Tarr)
    gammaLMP = jit(vmap(gamma_exomol,(0,0,None,None)))\
        (Parr,Tarr,mdbCO.n_Texp,mdbCO.alpha_ref)
    gammaLMN = gamma_natural(mdbCO.A)
    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,
                                           margin=2)
    mdbCO.masking(mask_CO)

    #plot_maxpoint(mask_CO,Parr,maxcf,maxcia,mol="CO")
    #plt.savefig("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,
                                                    margin=2)
        if k == 0:
            mask_H2O = np.copy(mask_H2O_tmp)
        else:
            mask_H2O = mask_H2O + mask_H2O_tmp

        if k == len(T0xarr) - 1:
            print("H2O ")
            plot_maxpoint(mask_H2O_tmp, Parr, maxcf, maxcia, mol="H2O")
            plt.savefig("maxpoint_H2O.pdf",
                        bbox_inches="tight",
                        pad_inches=0.0)
            print("H2O saved")

    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)

    return fobsx, nusdx, wavdx, errx, nus, wav, res, mdbCO, mdbH2O, numatrix_CO, numatrix_H2O, cdbH2H2, cdbH2He
Exemple #3
0
mmrH2 = 0.74
molmassH2 = molinfo.molmass('H2')
vmrH2 = (mmrH2 * mmw / molmassH2)  # VMR

Mp = 33.2  # fixing mass...

# Loading the molecular database of CO and the CIA
# In[8]:

mdbCO = moldb.MdbExomol('.database/CO/12C-16O/Li2015', nus, crit=1.e-46)
cdbH2H2 = contdb.CdbCIA('.database/H2-H2_2011.cia', nus)

# We have only 39 CO lines.
# Again, numatrix should be precomputed prior to HMC-NUTS.

numatrix_CO = make_numatrix0(nus, mdbCO.nu_lines)

# Or you can use initspec.init_lpf instead.
numatrix_CO = initspec.init_lpf(mdbCO.nu_lines, nus)

# reference pressure for a T-P model
Pref = 1.0  # bar
ONEARR = np.ones_like(Parr)
ONEWAV = jnp.ones_like(nflux)

# In[14]:

smalla = 1.0
smalldiag = smalla**2 * jnp.identity(NP)

# Now we write the model, which is used in HMC-NUTS.