#FLUX reference Fabs_REF2 = 2.7e-12 #absolute flux (i.e. flux@10pc) erg/s/cm2/um Burgasser+ 1303.7283 @2.29um fac0 = RJ**2 / ((10.0 * pc)**2) #nomralize by RJ Fref = (2.29**2) * Fabs_REF2 / fac0 / 1.e4 #erg/cm2/s/cm-1 @ 2.3um #loading spectrum dat = pd.read_csv("../data/luhman16a_spectra_detector1.csv", delimiter=",") wavd = (dat["wavelength_micron"].values) * 1.e4 #AA nusd = 1.e8 / wavd[::-1] fobs = (dat["normalized_flux"].values)[::-1] err = (dat["err_normalized_flux"].values)[::-1] #ATMOSPHERE NP = 100 Parr, dParr, k = rt.pressure_layer(NP=NP) mmw = 2.33 #mean molecular weight R = 100000. beta = c / (2.0 * np.sqrt(2.0 * np.log(2.0)) * R) #IP sigma need check ONEARR = np.ones_like(Parr) #ones_array for MMR molmassCO = molinfo.molmass("CO") #molecular mass (CO) molmassH2O = molinfo.molmass("H2O") #molecular mass (H2O) #LOADING CIA mmrH2 = 0.74 mmrHe = 0.25 molmassH2 = molinfo.molmass("H2") molmassHe = molinfo.molmass("He") vmrH2 = (mmrH2 * mmw / molmassH2) vmrHe = (mmrHe * mmw / molmassHe)
delimiter='\s') wavmic = dats['wav'].values * 1.e4 ccgs = 29979245800.0 flux = dats['flux'].values * ccgs # print(wavmic) # plt.plot(wavmic,flux) # plt.show() #import sys # sys.exit() dat = pd.read_csv('data/profile.dat') Parr = dat['P'].values NP = len(Parr) Parrx, dParr, k = rt.pressure_layer(NP=NP, logPtop=np.log10(Parr[0]), logPbtm=np.log10(Parr[-1])) Tarr = dat['T'].values MMR = dat['C1H4'].values #Parr, dParr, k=rt.pressure_layer(NP=NP) #Tarr = T0*(Parr)**0.1 nus, wav, R = nugrid(15900, 16300, 30000, unit='AA', xsmode='modit') print('R=', R) mdbCH4 = moldb.MdbExomol('.database/CH4/12C-1H4/YT10to10/', nus, crit=1.e-36) cdbH2H2 = contdb.CdbCIA('.database/H2-H2_2011.cia', nus) print('N=', len(mdbCH4.A)) molmassCH4 = molinfo.molmass('CH4') qt = vmap(mdbCH4.qr_interp)(Tarr) gammaLMP = jit(vmap(gamma_exomol, (0, 0, None, None)))(Parr, Tarr, mdbCH4.n_Texp,
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))
# FLUX reference Fabs_REF2 = 2.7e-12 #absolute flux (i.e. flux@10pc) erg/s/cm2/um Burgasser+ 1303.7283 @2.29um fac0 = RJ**2 / ((10.0 * pc)**2) #nomralize by RJ Fref = (2.29**2) * Fabs_REF2 / fac0 / 1.e4 #erg/cm2/s/cm-1 @ 2.3um # Loading spectrum dat = pd.read_csv("../data/luhman16a_spectra_detector1.csv", delimiter=",") wavd = (dat["wavelength_micron"].values) * 1.e4 #AA nusd = 1.e8 / wavd[::-1] fobs = (dat["normalized_flux"].values)[::-1] err = (dat["err_normalized_flux"].values)[::-1] # ATMOSPHERIC LAYER Pref = 1.0 # Reference pressure for a T-P model (bar) NP = 100 Parr, dParr, k = pressure_layer(NP=NP) mmw = 2.33 # Mean molecular weight ONEARR = np.ones_like(Parr) # ones_array for MMR molmassCO = molinfo.molmass("CO") # molecular mass (CO) molmassH2O = molinfo.molmass("H2O") # molecular mass (H2O) # Instrument beta = R2STD(100000.) #std of gaussian from R=100000. # LOADING CIA mmrH2 = 0.74 # mean molecualr weight of H2 for CIA mmrHe = 0.25 # mean molecualr weight of He for CIA molmassH2 = molinfo.molmass("H2") molmassHe = molinfo.molmass("He") vmrH2 = (mmrH2 * mmw / molmassH2) vmrHe = (mmrHe * mmw / molmassHe)