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)
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)
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)
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)
def frun(Tarr, MMR_CH4, Mp, Rp, u1, u2, RV, vsini): g = 2478.57730044555 * Mp / Rp**2 SijM_CH4, ngammaLM_CH4, nsigmaDl_CH4 = modit.exomol( mdbCH4, Tarr, Parr, R, molmassCH4) xsm_CH4 = modit.xsmatrix(cnu, indexnu, R, pmarray, nsigmaDl_CH4, ngammaLM_CH4, SijM_CH4, nus, dgm_ngammaL) # abs is used to remove negative values in xsv dtaumCH4 = dtauM(dParr, jnp.abs(xsm_CH4), MMR_CH4 * ONEARR, molmassCH4, g) # CIA dtaucH2H2 = dtauCIA(nus, Tarr, Parr, dParr, vmrH2, vmrH2, mmw, g, cdbH2H2.nucia, cdbH2H2.tcia, cdbH2H2.logac) dtau = dtaumCH4 + 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_inst, RV) return mu
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
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
def frun(Tarr, MMR_H2O, MMR_CO, Mp, Rp, u1, u2, RV, vsini): g = 2478.57730044555 * Mp / Rp**2 SijM_H2O, ngammaLM_H2O, nsigmaDl_H2O = modit.exomol( mdbH2O, Tarr, Parr, R, molmassH2O) xsm_H2O = modit.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) SijM_CO, ngammaLM_CO, nsigmaDl_CO = modit.exomol(mdbCO, Tarr, Parr, R, molmassCO) xsm_CO = modit.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) # CIA dtaucH2H2 = dtauCIA(nus, Tarr, Parr, dParr, vmrH2, vmrH2, mmw, g, cdbH2H2.nucia, cdbH2H2.tcia, cdbH2H2.logac) dtau = dtaumH2O + 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_inst, RV) return mu
def test_VALD_MODIT(): #wavelength range wls, wll = 10395, 10405 #Set a model atmospheric layers, wavenumber range for the model, an instrument NP = 100 Parr, dParr, k = pressure_layer(NP=NP) Pref = 1.0 #bar ONEARR = np.ones_like(Parr) Nx = 2000 nus, wav, res = nugrid(wls - 5.0, wll + 5.0, Nx, unit="AA", xsmode="modit") Rinst = 100000. #instrumental spectral resolution beta_inst = R2STD( Rinst) #equivalent to beta=c/(2.0*np.sqrt(2.0*np.log(2.0))*R) #atoms and ions from VALD adbV = moldb.AdbVald( path_ValdLineList, nus, crit=1e-100 ) #The crit is defined just in case some weak lines may cause an error that results in a gamma of 0... (220219) asdb = moldb.AdbSepVald(adbV) #molecules from exomol mdbH2O = moldb.MdbExomol('.database/H2O/1H2-16O/POKAZATEL', nus, crit=1e-50) #,crit = 1e-40) mdbTiO = moldb.MdbExomol('.database/TiO/48Ti-16O/Toto', nus, crit=1e-50) #,crit = 1e-50) mdbOH = moldb.MdbExomol('.database/OH/16O-1H/MoLLIST', nus) mdbFeH = moldb.MdbExomol('.database/FeH/56Fe-1H/MoLLIST', nus) #CIA cdbH2H2 = contdb.CdbCIA('.database/H2-H2_2011.cia', nus) #molecular mass molmassH2O = molinfo.molmass("H2O") molmassTiO = molinfo.molmass("TiO") molmassOH = molinfo.molmass("OH") molmassFeH = molinfo.molmass("FeH") molmassH = molinfo.molmass("H") molmassH2 = molinfo.molmass("H2") #Initialization of MODIT (for separate VALD species, and exomol molecules(e.g., FeH)) cnuS, indexnuS, R, pmarray = initspec.init_modit_vald( asdb.nu_lines, nus, asdb.N_usp) cnu_FeH, indexnu_FeH, R, pmarray = initspec.init_modit( mdbFeH.nu_lines, nus) cnu_H2O, indexnu_H2O, R, pmarray = initspec.init_modit( mdbH2O.nu_lines, nus) cnu_OH, indexnu_OH, R, pmarray = initspec.init_modit(mdbOH.nu_lines, nus) cnu_TiO, indexnu_TiO, R, pmarray = initspec.init_modit( mdbTiO.nu_lines, nus) #sampling the max/min of temperature profiles fT = lambda T0, alpha: T0[:, None] * (Parr[None, :] / Pref)**alpha[:, None] T0_test = np.array([1500.0, 4000.0, 1500.0, 4000.0]) alpha_test = np.array([0.2, 0.2, 0.05, 0.05]) res = 0.2 #Assume typical atmosphere H_He_HH_VMR_ref = [0.1, 0.15, 0.75] PH_ref = Parr * H_He_HH_VMR_ref[0] PHe_ref = Parr * H_He_HH_VMR_ref[1] PHH_ref = Parr * H_He_HH_VMR_ref[2] #Precomputing dgm_ngammaL dgm_ngammaL_VALD = setdgm_vald_all(asdb, PH_ref, PHe_ref, PHH_ref, R, fT, res, T0_test, alpha_test) dgm_ngammaL_FeH = setdgm_exomol(mdbFeH, fT, Parr, R, molmassFeH, res, T0_test, alpha_test) dgm_ngammaL_H2O = setdgm_exomol(mdbH2O, fT, Parr, R, molmassH2O, res, T0_test, alpha_test) dgm_ngammaL_OH = setdgm_exomol(mdbOH, fT, Parr, R, molmassOH, res, T0_test, alpha_test) dgm_ngammaL_TiO = setdgm_exomol(mdbTiO, fT, Parr, R, molmassTiO, res, T0_test, alpha_test) T0 = 3000. alpha = 0.07 Mp = 0.155 * 1.99e33 / 1.90e30 Rp = 0.186 * 6.96e10 / 6.99e9 u1 = 0.0 u2 = 0.0 RV = 0.00 vsini = 2.0 mmw = 2.33 * ONEARR #mean molecular weight log_e_H = -4.2 VMR_H = 0.09 VMR_H2 = 0.77 VMR_FeH = 10**-8 VMR_H2O = 10**-4 VMR_OH = 10**-4 VMR_TiO = 10**-8 A_Fe = 1.5 A_Ti = 1.2 adjust_continuum = 0.99 ga = 2478.57730044555 * Mp / Rp**2 Tarr = T0 * (Parr / Pref)**alpha PH = Parr * VMR_H PHe = Parr * (1 - VMR_H - VMR_H2) PHH = Parr * VMR_H2 VMR_e = VMR_H * 10**log_e_H #VMR of atoms and ions (+Abundance modification) mods_ID = jnp.array([[26, 1], [22, 1]]) mods = jnp.array([A_Fe, A_Ti]) VMR_uspecies = atomll.get_VMR_uspecies(asdb.uspecies, mods_ID, mods) VMR_uspecies = VMR_uspecies[:, None] * ONEARR #Compute delta tau #Atom & ions (VALD) SijMS, ngammaLMS, nsigmaDlS = vald_all(asdb, Tarr, PH, PHe, PHH, R) xsmS = xsmatrix_vald(cnuS, indexnuS, R, pmarray, nsigmaDlS, ngammaLMS, SijMS, nus, dgm_ngammaL_VALD) dtauatom = dtauVALD(dParr, xsmS, VMR_uspecies, mmw, ga) #FeH SijM_FeH, ngammaLM_FeH, nsigmaDl_FeH = exomol(mdbFeH, Tarr, Parr, R, molmassFeH) xsm_FeH = xsmatrix(cnu_FeH, indexnu_FeH, R, pmarray, nsigmaDl_FeH, ngammaLM_FeH, SijM_FeH, nus, dgm_ngammaL_FeH) dtaum_FeH = dtauM_mmwl(dParr, jnp.abs(xsm_FeH), VMR_FeH * ONEARR, mmw, ga) #H2O SijM_H2O, ngammaLM_H2O, nsigmaDl_H2O = exomol(mdbH2O, Tarr, Parr, R, molmassH2O) xsm_H2O = xsmatrix(cnu_H2O, indexnu_H2O, R, pmarray, nsigmaDl_H2O, ngammaLM_H2O, SijM_H2O, nus, dgm_ngammaL_H2O) dtaum_H2O = dtauM_mmwl(dParr, jnp.abs(xsm_H2O), VMR_H2O * ONEARR, mmw, ga) #OH SijM_OH, ngammaLM_OH, nsigmaDl_OH = exomol(mdbOH, Tarr, Parr, R, molmassOH) xsm_OH = xsmatrix(cnu_OH, indexnu_OH, R, pmarray, nsigmaDl_OH, ngammaLM_OH, SijM_OH, nus, dgm_ngammaL_OH) dtaum_OH = dtauM_mmwl(dParr, jnp.abs(xsm_OH), VMR_OH * ONEARR, mmw, ga) #TiO SijM_TiO, ngammaLM_TiO, nsigmaDl_TiO = exomol(mdbTiO, Tarr, Parr, R, molmassTiO) xsm_TiO = xsmatrix(cnu_TiO, indexnu_TiO, R, pmarray, nsigmaDl_TiO, ngammaLM_TiO, SijM_TiO, nus, dgm_ngammaL_TiO) dtaum_TiO = dtauM_mmwl(dParr, jnp.abs(xsm_TiO), VMR_TiO * ONEARR, mmw, ga) #Hminus dtau_Hm = dtauHminus_mmwl(nus, Tarr, Parr, dParr, VMR_e * ONEARR, VMR_H * ONEARR, mmw, ga) #CIA dtauc_H2H2 = dtauCIA_mmwl(nus, Tarr, Parr, dParr, VMR_H2 * ONEARR, VMR_H2 * ONEARR, mmw, ga, cdbH2H2.nucia, cdbH2H2.tcia, cdbH2H2.logac) #Summations dtau = dtauatom + dtaum_FeH + dtaum_H2O + dtaum_OH + dtaum_TiO + dtau_Hm + dtauc_H2H2 sourcef = planck.piBarr(Tarr, nus) F0 = rtrun(dtau, sourcef) Frot = response.rigidrot(nus, F0, vsini, u1, u2) wavd = jnp.linspace(wls, wll, 500) nusd = jnp.array(1.e8 / wavd[::-1]) mu = response.ipgauss_sampling(nusd, nus, Frot, beta_inst, RV) mu = mu / jnp.nanmax(mu) * adjust_continuum assert (np.all(~np.isnan(mu)) * \ np.all(mu != 0) * \ np.all(abs(mu) != np.inf))
sourcef = planck.piBarr(Tarr, nus) F0 = rtrun(dtau, sourcef) wavd = jnp.linspace(15910, 16290, 1500) # observational wavelength grid nusd = 1.e8 / wavd[::-1] RV = 10.0 # RV km/s vsini = 20.0 # Vsini km/s u1 = 0.0 # limb darkening u1 u2 = 0.0 # limb darkening u2 Rinst = 100000. beta = c / (2.0 * np.sqrt(2.0 * np.log(2.0)) * Rinst) # IP sigma need check Frot = response.rigidrot(nus, F0, vsini, u1, u2) F = response.ipgauss_sampling(nusd, nus, Frot, beta, RV) ### # In[42]: fig = plt.figure(figsize=(20, 4)) plt.plot(wav[::-1], F0, alpha=0.5, color='C1', label='exojax (CH4 only)') # plt.plot(wavd[::-1],F) plt.plot(wavmic, flux, alpha=0.5, color='C2', label='petit?') plt.legend() plt.ylim(0, 15000) plt.xlim(np.min(wav), np.max(wav)) plt.xlabel('wavelength ($\AA$)') plt.savefig('moditCH4.png')
def spectrum(self, nuobs, Rinst, vsini, RV, u1=0.0, u2=0.0, zeta=0., betamic=0., direct=True): """generating spectrum. Args: nuobs: observation wavenumber array Rinst: instrumental resolving power vsini: vsini for a stellar/planet rotation RV: radial velocity (km/s) u1: Limb-darkening coefficient 1 u2: Limb-darkening coefficient 2 zeta: macroturbulence distrubunce (km/s) in the radial-tangential model (Gray2005) betamic: microturbulence beta (STD, km/s) direct: True=use rigidrot/ipgauss_sampling, False=use rigidrot2, ipgauss2, sampling Returns: spectrum (F) """ self.nuobs = nuobs self.Rinst = Rinst self.vsini = vsini self.u1 = u1 self.u2 = u2 self.zeta = zeta self.betamic = betamic self.RV = RV self.betaIP = R2STD(self.Rinst) beta = np.sqrt((self.betaIP)**2 + (self.betamic)**2) F0 = self.rtrun() if len(self.nus) < 50000 and direct == True: print('rotation (1)') Frot = response.rigidrot(self.nus, F0, self.vsini, u1=self.u1, u2=self.u2) self.F = response.ipgauss_sampling(self.nuobs, self.nus, Frot, beta, self.RV) else: print('rotation (2): Require CuDNN') dv = c * (np.log(self.nus[1]) - np.log(self.nus[0])) Nv = int(self.vsini / dv) + 1 vlim = Nv * dv varr_kernel = jnp.linspace(-vlim, vlim, 2 * Nv + 1) Frot = response.rigidrot2(self.nus, F0, varr_kernel, self.vsini, u1=self.u1, u2=self.u2) maxp = 5.0 # 5sigma Nv = int(maxp * beta / dv) + 1 vlim = Nv * dv varr_kernel = jnp.linspace(-vlim, vlim, 2 * Nv + 1) Fgrot = response.ipgauss2(self.nus, Frot, varr_kernel, beta) self.F = response.sampling(self.nuobs, self.nus, Fgrot, self.RV) return self.F