Esempio n. 1
0
    def obyo(y, tag, nusdx, nus, mdbCO, mdbH2O, cdbH2H2, cdbH2He):
        #CO
        SijM_CO, ngammaLM_CO, nsigmaDl_CO = exomol(mdbCO, Tarr, Parr, R_CO,
                                                   molmassCO)
        xsm_CO = xsmatrix(cnu_CO, indexnu_CO, R_CO, pmarray_CO, nsigmaDl_CO,
                          ngammaLM_CO, SijM_CO, nus, dgm_ngammaL_CO)
        dtaumCO = dtauM(dParr, jnp.abs(xsm_CO), MMR_CO * ONEARR, molmassCO, g)

        #H2O
        SijM_H2O, ngammaLM_H2O, nsigmaDl_H2O = exomol(mdbH2O, Tarr, Parr,
                                                      R_H2O, molmassH2O)
        xsm_H2O = xsmatrix(cnu_H2O, indexnu_H2O, R_H2O, pmarray_H2O,
                           nsigmaDl_H2O, ngammaLM_H2O, SijM_H2O, nus,
                           dgm_ngammaL_H2O)
        dtaumH2O = dtauM(dParr, jnp.abs(xsm_H2O), MMR_H2O * ONEARR, molmassH2O,
                         g)

        #CIA
        dtaucH2H2=dtauCIA(nus,Tarr,Parr,dParr,vmrH2,vmrH2,\
                          mmw,g,cdbH2H2.nucia,cdbH2H2.tcia,cdbH2H2.logac)
        dtaucH2He=dtauCIA(nus,Tarr,Parr,dParr,vmrH2,vmrHe,\
                          mmw,g,cdbH2He.nucia,cdbH2He.tcia,cdbH2He.logac)

        dtau = dtaumCO + dtaumH2O + dtaucH2H2 + dtaucH2He
        sourcef = planck.piBarr(Tarr, nus)

        Ftoa = Fref / Rp**2
        F0 = rtrun(dtau, sourcef) / baseline / Ftoa

        Frot = response.rigidrot(nus, F0, vsini, u1, u2)
        mu = response.ipgauss_sampling(nusdx, nus, Frot, beta, RV)

        errall = jnp.sqrt(e1**2 + sigma**2)
        numpyro.sample(tag, dist.Normal(mu, errall), obs=y)
Esempio n. 2
0
def model_c(nu1, y1, e1):
    Rp = sample('Rp', dist.Uniform(0.5, 1.5))
    Mp = sample('Mp', dist.Normal(33.5, 0.3))
    RV = sample('RV', dist.Uniform(26.0, 30.0))
    MMR_CO = sample('MMR_CO', dist.Uniform(0.0, maxMMR_CO))
    MMR_H2O = sample('MMR_H2O', dist.Uniform(0.0, maxMMR_H2O))
    T0 = sample('T0', dist.Uniform(1000.0, 1700.0))
    alpha = sample('alpha', dist.Uniform(0.05, 0.15))
    vsini = sample('vsini', dist.Uniform(10.0, 20.0))

    # Kipping Limb Darkening Prior
    q1 = sample('q1', dist.Uniform(0.0, 1.0))
    q2 = sample('q2', dist.Uniform(0.0, 1.0))
    u1, u2 = ld_kipping(q1, q2)

    #GP
    logtau = sample('logtau', dist.Uniform(-1.5, 0.5))  #tau=1 <=> 5A
    tau = 10**(logtau)
    loga = sample('loga', dist.Uniform(-4.0, -2.0))
    a = 10**(loga)

    #gravity
    g = getjov_gravity(Rp, Mp)

    #T-P model//
    Tarr = T0 * (Parr / Pref)**alpha

    #CO
    SijM_CO, gammaLM_CO, sigmaDM_CO = exomol(mdbCO, Tarr, Parr, molmassCO)
    xsm_CO = xsmatrix(numatrix_CO, sigmaDM_CO, gammaLM_CO, SijM_CO)
    dtaumCO = dtauM(dParr, xsm_CO, MMR_CO * ONEARR, molmassCO, g)

    #H2O
    SijM_H2O, gammaLM_H2O, sigmaDM_H2O = exomol(mdbH2O, Tarr, Parr, molmassH2O)
    xsm_H2O = xsmatrix(numatrix_H2O, sigmaDM_H2O, gammaLM_H2O, SijM_H2O)
    dtaumH2O = dtauM(dParr, xsm_H2O, MMR_H2O * ONEARR, molmassH2O, g)

    #CIA
    dtaucH2H2=dtauCIA(nus,Tarr,Parr,dParr,vmrH2,vmrH2,\
                      mmw,g,cdbH2H2.nucia,cdbH2H2.tcia,cdbH2H2.logac)
    dtaucH2He=dtauCIA(nus,Tarr,Parr,dParr,vmrH2,vmrHe,\
                      mmw,g,cdbH2He.nucia,cdbH2He.tcia,cdbH2He.logac)

    dtau = dtaumCO + dtaumH2O + dtaucH2H2 + dtaucH2He
    sourcef = planck.piBarr(Tarr, nus)
    Ftoa = Fref / Rp**2
    F0 = rtrun(dtau, sourcef) / baseline / Ftoa

    Frot = response.rigidrot(nus, F0, vsini, u1, u2)
    mu = response.ipgauss_sampling(nu1, nus, Frot, beta, RV)
    cov = gpkernel_RBF(nu1, tau, a, e1)
    sample("y1",
           dist.MultivariateNormal(loc=mu, covariance_matrix=cov),
           obs=y1)
Esempio n. 3
0
    def obyo(y, tag, nusd, nus, numatrix_CO, numatrix_H2O, mdbCO, mdbH2O,
             cdbH2H2, cdbH2He):
        #CO
        SijM_CO=jit(vmap(SijT,(0,None,None,None,0)))\
            (Tarr,mdbCO.logsij0,mdbCO.dev_nu_lines,mdbCO.elower,qt_CO)

        gammaLMP_CO = 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_CO = gamma_natural(mdbCO.A)
        gammaLM_CO = gammaLMP_CO + gammaLMN_CO[None, :]
        sigmaDM_CO=jit(vmap(doppler_sigma,(None,0,None)))\
            (mdbCO.dev_nu_lines,Tarr,molmassCO)
        xsm_CO = xsmatrix(numatrix_CO, sigmaDM_CO, gammaLM_CO, SijM_CO)
        dtaumCO = dtauM(dParr, xsm_CO, MMR_CO * ONEARR, molmassCO, g)

        #H2O
        SijM_H2O=jit(vmap(SijT,(0,None,None,None,0)))\
            (Tarr,mdbH2O.logsij0,mdbH2O.dev_nu_lines,mdbH2O.elower,qt_H2O)
        gammaLMP_H2O = jit(vmap(gamma_exomol,(0,0,None,None)))\
            (Parr,Tarr,mdbH2O.n_Texp,mdbH2O.alpha_ref)
        gammaLMN_H2O = gamma_natural(mdbH2O.A)
        gammaLM_H2O = gammaLMP_H2O + gammaLMN_H2O[None, :]
        sigmaDM_H2O=jit(vmap(doppler_sigma,(None,0,None)))\
            (mdbH2O.dev_nu_lines,Tarr,molmassH2O)
        xsm_H2O = xsmatrix(numatrix_H2O, sigmaDM_H2O, gammaLM_H2O, SijM_H2O)
        dtaumH2O = dtauM(dParr, xsm_H2O, MMR_H2O * ONEARR, molmassH2O, g)
        #CIA
        dtaucH2H2=dtauCIA(nus,Tarr,Parr,dParr,vmrH2,vmrH2,\
                          mmw,g,cdbH2H2.nucia,cdbH2H2.tcia,cdbH2H2.logac)
        dtaucH2He=dtauCIA(nus,Tarr,Parr,dParr,vmrH2,vmrHe,\
                          mmw,g,cdbH2He.nucia,cdbH2He.tcia,cdbH2He.logac)

        dtau = dtaumCO + dtaumH2O + dtaucH2H2 + dtaucH2He
        sourcef = planck.piBarr(Tarr, nus)

        Ftoa = Fref / (Rp**2)
        F0 = rtrun(dtau, sourcef) / baseline / Ftoa

        Frot = response.rigidrot(nus, F0, vsini, u1, u2)
        mu = response.ipgauss_sampling(nusd, nus, Frot, beta, RV)

        #errall=jnp.sqrt(e1**2+sigma**2)
        errall = e1
        cov = modelcov(nusd, tau, a, errall)
        #cov = modelcov(nusd,tau,a,e1)
        #numpyro.sample(tag, dist.Normal(mu, e1), obs=y)
        numpyro.sample(tag,
                       dist.MultivariateNormal(loc=mu, covariance_matrix=cov),
                       obs=y)
Esempio n. 4
0
    def obyo(y, tag, nusd, nus, numatrix_CO, mdbCO, cdbH2H2):
        # CO
        SijM_CO = jit(vmap(SijT,
                           (0, None, None, None, 0)))(Tarr, mdbCO.logsij0,
                                                      mdbCO.dev_nu_lines,
                                                      mdbCO.elower, qt_CO)
        gammaLMP_CO = jit(vmap(gamma_exomol,
                               (0, 0, None, None)))(Parr, Tarr, mdbCO.n_Texp,
                                                    mdbCO.alpha_ref)
        gammaLMN_CO = gamma_natural(mdbCO.A)
        gammaLM_CO = gammaLMP_CO + gammaLMN_CO[None, :]

        sigmaDM_CO = jit(vmap(doppler_sigma,
                              (None, 0, None)))(mdbCO.dev_nu_lines, Tarr,
                                                molmassCO)
        xsm_CO = xsmatrix(numatrix_CO, sigmaDM_CO, gammaLM_CO, SijM_CO)
        dtaumCO = dtauM(dParr, xsm_CO, MMR_CO * ONEARR, molmassCO, g)
        # CIA
        dtaucH2H2 = dtauCIA(nus, Tarr, Parr, dParr, vmrH2, vmrH2, mmw, g,
                            cdbH2H2.nucia, cdbH2H2.tcia, cdbH2H2.logac)
        dtau = dtaumCO + dtaucH2H2
        sourcef = planck.piBarr(Tarr, nus)
        F0 = rtrun(dtau, sourcef) / norm

        Frot = response.rigidrot(nus, F0, vsini, u1, u2)
        mu = response.ipgauss_sampling(nusd, nus, Frot, beta, RV)
        numpyro.sample(tag, dist.Normal(mu, sigmain), obs=y)
Esempio n. 5
0
    def obyo(y, tag, nusd, nus, numatrix_CO, numatrix_H2O, mdbCO, mdbH2O,
             cdbH2H2, cdbH2He):
        #CO
        SijM_CO=jit(vmap(SijT,(0,None,None,None,0)))\
            (Tarr,mdbCO.logsij0,mdbCO.dev_nu_lines,mdbCO.elower,qt_CO)
        gammaLMP_CO = jit(vmap(gamma_exomol,(0,0,None,None)))\
            (Parr,Tarr,mdbCO.n_Texp,mdbCO.alpha_ref)
        gammaLMN_CO = gamma_natural(mdbCO.A)
        gammaLM_CO = gammaLMP_CO + gammaLMN_CO[None, :]
        sigmaDM_CO=jit(vmap(doppler_sigma,(None,0,None)))\
            (mdbCO.dev_nu_lines,Tarr,molmassCO)
        xsm_CO = xsmatrix(numatrix_CO, sigmaDM_CO, gammaLM_CO, SijM_CO)
        dtaumCO = dtauM(dParr, xsm_CO, MMR_CO * ONEARR, molmassCO, g)
        #H2O
        SijM_H2O=jit(vmap(SijT,(0,None,None,None,0)))\
            (Tarr,mdbH2O.logsij0,mdbH2O.dev_nu_lines,mdbH2O.elower,qt_H2O)
        gammaLMP_H2O = jit(vmap(gamma_exomol,(0,0,None,None)))\
            (Parr,Tarr,mdbH2O.n_Texp,mdbH2O.alpha_ref)
        gammaLMN_H2O = gamma_natural(mdbH2O.A)
        gammaLM_H2O = gammaLMP_H2O + gammaLMN_H2O[None, :]
        sigmaDM_H2O=jit(vmap(doppler_sigma,(None,0,None)))\
            (mdbH2O.dev_nu_lines,Tarr,molmassH2O)
        xsm_H2O = xsmatrix(numatrix_H2O, sigmaDM_H2O, gammaLM_H2O, SijM_H2O)
        dtaumH2O = dtauM(dParr, xsm_H2O, MMR_H2O * ONEARR, molmassH2O, g)
        #CIA
        dtaucH2H2=dtauCIA(nus,Tarr,Parr,dParr,vmrH2,vmrH2,\
                          mmw,g,cdbH2H2.nucia,cdbH2H2.tcia,cdbH2H2.logac)
        dtaucH2He=dtauCIA(nus,Tarr,Parr,dParr,vmrH2,vmrHe,\
                          mmw,g,cdbH2He.nucia,cdbH2He.tcia,cdbH2He.logac)

        dtau = dtaumCO + dtaumH2O + dtaucH2H2 + dtaucH2He
        sourcef = planck.piBarr(Tarr, nus)

        Ftoa = Fref / Rp**2
        F0 = rtrun(dtau, sourcef) / baseline / Ftoa

        Frot = response.rigidrot(nus, F0, vsini, u1, u2)
        mu = response.ipgauss_sampling(nusd, nus, Frot, beta, RV)
        np.savez("dtau_lpf.npz", [nus, dtaumCO, dtaumH2O])
        return mu
Esempio n. 6
0
    def obyo(y, tag, nusdx, nus, mdbCO, mdbH2O, cdbH2H2, cdbH2He):
        #CO
        SijM_CO, ngammaLM_CO, nsigmaDl_CO = exomol(mdbCO, Tarr, Parr, R_CO,
                                                   molmassCO)
        xsm_CO = xsmatrix(cnu_CO, indexnu_CO, R_CO, pmarray_CO, nsigmaDl_CO,
                          ngammaLM_CO, SijM_CO, nus, dgm_ngammaL_CO)
        dtaumCO = dtauM(dParr, jnp.abs(xsm_CO), MMR_CO * ONEARR, molmassCO, g)

        #H2O
        SijM_H2O, ngammaLM_H2O, nsigmaDl_H2O = exomol(mdbH2O, Tarr, Parr,
                                                      R_H2O, molmassH2O)
        xsm_H2O = xsmatrix(cnu_H2O, indexnu_H2O, R_H2O, pmarray_H2O,
                           nsigmaDl_H2O, ngammaLM_H2O, SijM_H2O, nus,
                           dgm_ngammaL_H2O)
        dtaumH2O = dtauM(dParr, jnp.abs(xsm_H2O), MMR_H2O * ONEARR, molmassH2O,
                         g)

        #CIA
        dtaucH2H2=dtauCIA(nus,Tarr,Parr,dParr,vmrH2,vmrH2,\
                          mmw,g,cdbH2H2.nucia,cdbH2H2.tcia,cdbH2H2.logac)
        dtaucH2He=dtauCIA(nus,Tarr,Parr,dParr,vmrH2,vmrHe,\
                          mmw,g,cdbH2He.nucia,cdbH2He.tcia,cdbH2He.logac)

        dtau = dtaumCO + dtaumH2O + dtaucH2H2 + dtaucH2He
        sourcef = planck.piBarr(Tarr, nus)

        Ftoa = Fref / Rp**2
        F0 = rtrun(dtau, sourcef) / baseline / Ftoa

        Frot = response.rigidrot(nus, F0, vsini, u1, u2)
        mu = response.ipgauss_sampling(nusdx, nus, Frot, beta, RV)
        if FP64 == True:

            np.savez("dtau_modit" + str(N) + "_64.npz",
                     [nus, dtaumCO, dtaumH2O])
        else:
            np.savez("dtau_modit" + str(N) + ".npz", [nus, dtaumCO, dtaumH2O])

        return mu
Esempio n. 7
0
    def xsmatrix(self, Tarr, Parr):
        """cross section matrix.

        Args:
           Tarr: temperature layer (K)
           Parr: pressure layer (bar)

        Returns:
           cross section (cm2)
        """
        mdb = self.mdb
        if self.database == 'ExoMol':
            qt = vmap(mdb.qr_interp)(Tarr)
            gammaLMP = jit(vmap(gamma_exomol,
                                (0, 0, None, None)))(Parr, Tarr, mdb.n_Texp,
                                                     mdb.alpha_ref)
            gammaLMN = gamma_natural(mdb.A)
            gammaLM = gammaLMP + gammaLMN[None, :]
            self.molmass = mdb.molmass
            SijM = jit(vmap(SijT, (0, None, None, None, 0)))(Tarr, mdb.logsij0,
                                                             mdb.nu_lines,
                                                             mdb.elower, qt)

        elif self.database == 'HITRAN' or self.database == 'HITEMP':
            qt = mdb.Qr_layer(Tarr)
            gammaLM = jit(vmap(gamma_hitran, (0, 0, 0, None, None, None)))(Parr, Tarr, Parr, mdb.n_air, mdb.gamma_air, mdb.gamma_self)\
                + gamma_natural(mdb.A)
            self.molmass = molinfo.molmass(self.molecules)
            SijM = jit(vmap(SijT, (0, None, None, None, 0)))(Tarr, mdb.logsij0,
                                                             mdb.nu_lines,
                                                             mdb.elower, qt)

        print('# of lines', len(mdb.nu_lines))
        memory_size = 15.0
        d = int(memory_size / (len(mdb.nu_lines) * 4 / 1024. / 1024.)) + 1
        d2 = 100
        Nlayer, Nline = np.shape(SijM)
        if self.xsmode == 'auto':
            xsmode = self.select_xsmode(Nline)
        else:
            xsmode = self.xsmode
        print('xsmode=', xsmode)

        if xsmode == 'lpf' or xsmode == 'LPF':
            sigmaDM = jit(vmap(doppler_sigma,
                               (None, 0, None)))(mdb.nu_lines, Tarr,
                                                 self.molmass)
            Nj = int(Nline / d2)
            xsm = []
            for i in tqdm.tqdm(range(0, int(len(self.nus) / d) + 1)):
                s = int(i * d)
                e = int((i + 1) * d)
                e = min(e, len(self.nus))
                xsmtmp = np.zeros((Nlayer, e - s))
                for j in range(0, Nj + 1):
                    s2 = int(j * d2)
                    e2 = int((j + 1) * d2)
                    e2 = min(e2, Nline)
                    numatrix = make_numatrix0(self.nus[s:e],
                                              mdb.nu_lines[s2:e2])
                    xsmtmp = xsmtmp +\
                        lpf.xsmatrix(
                            numatrix, sigmaDM[:, s2:e2], gammaLM[:, s2:e2], SijM[:, s2:e2])
                if i == 0:
                    xsm = np.copy(xsmtmp.T)
                else:
                    xsm = np.concatenate([xsm, xsmtmp.T])
            xsm = xsm.T
        elif xsmode == 'modit' or xsmode == 'MODIT':
            cnu, indexnu, R_mol, pmarray = initspec.init_modit(
                mdb.nu_lines, self.nus)
            nsigmaDl = normalized_doppler_sigma(Tarr, self.molmass,
                                                R_mol)[:, np.newaxis]
            ngammaLM = gammaLM / (mdb.nu_lines / R_mol)
            dgm_ngammaL = modit.dgmatrix(ngammaLM, 0.1)
            xsm = modit.xsmatrix(cnu, indexnu, R_mol, pmarray, nsigmaDl,
                                 ngammaLM, SijM, self.nus, dgm_ngammaL)
            xsm = self.nonnegative_xsm(xsm)
        elif xsmode == 'dit' or xsmode == 'DIT':
            cnu, indexnu, pmarray = initspec.init_dit(mdb.nu_lines, self.nus)
            sigmaDM = jit(vmap(doppler_sigma,
                               (None, 0, None)))(mdb.nu_lines, Tarr,
                                                 self.molmass)
            dgm_sigmaD = dit.dgmatrix(sigmaDM, 0.1)
            dgm_gammaL = dit.dgmatrix(gammaLM, 0.2)
            xsm = dit.xsmatrix(cnu, indexnu, pmarray, sigmaDM, gammaLM, SijM,
                               self.nus, dgm_sigmaD, dgm_gammaL)
            xsm = self.nonnegative_xsm(xsm)
        else:
            print('No such xsmode=', xsmode)
            xsm = None

        return xsm