def log_likelihood(N_nu=mycosmo['N_nu'], Y_He=mycosmo['Y_He'], h=mycosmo['h'], n=mycosmo['n'], omega_M_0=mycosmo['omega_M_0'], omega_b_0=mycosmo['omega_b_0'], omega_lambda_0=mycosmo['omega_lambda_0'], omega_n_0=mycosmo['omega_n_0'], sigma_8=mycosmo['sigma_8'], t_0=mycosmo['t_0'], tau=mycosmo['tau'], w=mycosmo['w'], z_reion=mycosmo['z_reion'],nmassless=mycosmo['Num_Nu_massless'],nmassive=mycosmo['Num_Nu_massive'],library='astropy'): cosmo=mcmc.get_cosmology(N_nu,Y_He,h,n,omega_M_0,omega_b_0,omega_lambda_0,omega_n_0,sigma_8,t_0,tau,w,z_reion,nmassless,nmassive,library=library) if library == 'astropy': cosast=astropy.cosmology.wCDM(cosmo['h']*100,cosmo['omega_M_0'],cosmo['omega_lambda_0'],w0=cosmo['w']) try: if library == 'cosmolopy': #print('log_likelihood Beutler Da: cosmolopy') daval=cosmolopy.distance.angular_diameter_distance(z,**cosmo) elif library == 'astropy': #print('log_likelihood Beutler Da: astropy') daval=cosast.angular_diameter_distance(z) elif library == 'jc': #print('log_likelihood Beutler Da: jc') daval=cosmo_utils.angdist(z,**cosmo) except: daval=-1. try: if library == 'cosmolopy': #print('log_likelihood Beutler Hz: cosmolopy') hval=cosmolopy.distance.e_z(z,**cosmo)*cosmo['h']*100 elif library == 'astropy': #print('log_likelihood Beutler Hz: astropy') hval=100*cosmo['h']/cosast.inv_efunc(z) elif library == 'jc': #print('log_likelihood Beutler Hz: jc') hval=cosmo_utils.e_z(z,**cosmo)*cosmo['h']*100 except: hval=-1. dvval=((1+z)**2*daval**2*cc*z/hval)**(1./3) rsval=cosmo_utils.rs_zdrag_fast_camb(**cosmo)*corr rs_dv=rsval/dvval chi2=(rs_dv-rs_dv_mes)**2/drs_dv_mes**2 return(-0.5*chi2)
def log_likelihood( N_nu=np.array(mycosmo["N_nu"]), Y_He=np.array(mycosmo["Y_He"]), h=np.array(mycosmo["h"]), n=np.array(mycosmo["n"]), omega_M_0=np.array(mycosmo["omega_M_0"]), omega_b_0=np.array(mycosmo["omega_b_0"]), omega_lambda_0=np.array(mycosmo["omega_lambda_0"]), omega_n_0=np.array(mycosmo["omega_n_0"]), sigma_8=np.array(mycosmo["sigma_8"]), t_0=np.array(mycosmo["t_0"]), tau=np.array(mycosmo["tau"]), w=np.array(mycosmo["w"]), z_reion=np.array(mycosmo["z_reion"]), nmassless=mycosmo["Num_Nu_massless"], nmassive=mycosmo["Num_Nu_massive"], library="astropy", ): cosmo = mcmc.get_cosmology( N_nu, Y_He, h, n, omega_M_0, omega_b_0, omega_lambda_0, omega_n_0, sigma_8, t_0, tau, w, z_reion, nmassless, nmassive, library=library, ) # print(cosmo['h'],cosmo['omega_M_0'],cosmo['omega_lambda_0'],cosmo['omega_M_0']+cosmo['omega_lambda_0'],cosmo['omega_k_0'],cosmo['w']) if library == "astropy": cosast = astropy.cosmology.wCDM(cosmo["h"] * 100, cosmo["omega_M_0"], cosmo["omega_lambda_0"], w0=cosmo["w"]) try: if library == "cosmolopy": # print('log_likelihood lyaDR11 Hz: cosmolopy') hval = cosmolopy.distance.e_z(zlya, **cosmo) * cosmo["h"] elif library == "astropy": # print('log_likelihood lyaDR11 Hz: astropy') hval = cosmo["h"] / cosast.inv_efunc(zlya) elif library == "jc": # print('log_likelihood lyaDR11 Hz: jc') hval = cosmo_utils.e_z(zlya, **cosmo) * cosmo["h"] except: hval = -1.0 rsval = cosmo_utils.rs_zdrag_fast_camb(**cosmo) invhrs = 1.0 / (hval * rsval) valprob = likelihood_interp(invhrs) return np.log(valprob)
def log_likelihood(N_nu=np.array(mycosmo['N_nu']), Y_He=np.array(mycosmo['Y_He']), h=np.array(mycosmo['h']), n=np.array(mycosmo['n']), omega_M_0=np.array(mycosmo['omega_M_0']), omega_b_0=np.array(mycosmo['omega_b_0']), omega_lambda_0=np.array(mycosmo['omega_lambda_0']), omega_n_0=np.array(mycosmo['omega_n_0']), sigma_8=np.array(mycosmo['sigma_8']), t_0=np.array(mycosmo['t_0']), tau=np.array(mycosmo['tau']), w=np.array(mycosmo['w']), z_reion=np.array(mycosmo['z_reion']),nmassless=mycosmo['Num_Nu_massless'],nmassive=mycosmo['Num_Nu_massive'],library='astropy'): cosmo=mcmc.get_cosmology(N_nu,Y_He,h,n,omega_M_0,omega_b_0,omega_lambda_0,omega_n_0,sigma_8,t_0,tau,w,z_reion,nmassless,nmassive,library=library) theobh2=cosmo['omega_b_0']*cosmo['h']**2 theoch2=(cosmo['omega_M_0']-cosmo['omega_b_0']-cosmo['omega_n_0'])*cosmo['h']**2 thethetamc=100*cosmo_utils.thetamc(**cosmo) thevals=[theobh2,theoch2,thethetamc] chi2=np.dot(np.dot(thevals-vals,invcovar),thevals-vals) #chi2=np.sum((vals-thevals)**2/sigs**2) return(-0.5*chi2)
def log_likelihood(N_nu=np.array(mycosmo['N_nu']), Y_He=np.array(mycosmo['Y_He']), h=np.array(mycosmo['h']), n=np.array(mycosmo['n']), omega_M_0=np.array(mycosmo['omega_M_0']), omega_b_0=np.array(mycosmo['omega_b_0']), omega_lambda_0=np.array(mycosmo['omega_lambda_0']), omega_n_0=np.array(mycosmo['omega_n_0']), sigma_8=np.array(mycosmo['sigma_8']), t_0=np.array(mycosmo['t_0']), tau=np.array(mycosmo['tau']), w=np.array(mycosmo['w']), z_reion=np.array(mycosmo['z_reion']),nmassless=mycosmo['Num_Nu_massless'],nmassive=mycosmo['Num_Nu_massive'],library='astropy'): cosmo=mcmc.get_cosmology(N_nu,Y_He,h,n,omega_M_0,omega_b_0,omega_lambda_0,omega_n_0,sigma_8,t_0,tau,w,z_reion,nmassless,nmassive,library=library) #print(cosmo['h'],cosmo['omega_M_0'],cosmo['omega_lambda_0'],cosmo['omega_M_0']+cosmo['omega_lambda_0'],cosmo['omega_k_0'],cosmo['w']) if library == 'astropy': cosast=astropy.cosmology.wCDM(cosmo['h']*100,cosmo['omega_M_0'],cosmo['omega_lambda_0'],w0=cosmo['w']) try: if library == 'cosmolopy': #print('log_likelihood lyaDR11 Da: cosmolopy') daval=cosmolopy.distance.angular_diameter_distance(zlya,**cosmo) elif library == 'astropy': #print('log_likelihood lyaDR11 Da: astropy') daval=cosast.angular_diameter_distance(zlya) elif library == 'jc': #print('log_likelihood lyaDR11 Da: jc') daval=cosmo_utils.angdist(zlya,**cosmo) except: daval=-1. try: if library == 'cosmolopy': #print('log_likelihood lyaDR11 Hz: cosmolopy') hval=cosmolopy.distance.e_z(zlya,**cosmo)*cosmo['h'] elif library == 'astropy': #print('log_likelihood lyaDR11 Hz: astropy') hval=cosmo['h']/cosast.inv_efunc(zlya) elif library == 'jc': #print('log_likelihood lyaDR11 Hz: jc') hval=cosmo_utils.e_z(zlya,**cosmo)*cosmo['h'] except: hval=-1. rsval=cosmo_utils.rs_zdrag_fast_camb(**cosmo) invhrs=1./(hval*rsval) da_rs=daval/rsval valprob=likelihood_interp(invhrs,da_rs) return(np.log(valprob))
def log_likelihood(N_nu=np.array(mycosmo['N_nu']), Y_He=np.array(mycosmo['Y_He']), h=np.array(mycosmo['h']), n=np.array(mycosmo['n']), omega_M_0=np.array(mycosmo['omega_M_0']), omega_b_0=np.array(mycosmo['omega_b_0']), omega_lambda_0=np.array(mycosmo['omega_lambda_0']), omega_n_0=np.array(mycosmo['omega_n_0']), sigma_8=np.array(mycosmo['sigma_8']), t_0=np.array(mycosmo['t_0']), tau=np.array(mycosmo['tau']), w=np.array(mycosmo['w']), z_reion=np.array(mycosmo['z_reion']),nmassless=mycosmo['Num_Nu_massless'],nmassive=mycosmo['Num_Nu_massive'],library='astropy'): cosmo=mcmc.get_cosmology(N_nu,Y_He,h,n,omega_M_0,omega_b_0,omega_lambda_0,omega_n_0,sigma_8,t_0,tau,w,z_reion,nmassless,nmassive,library=library) chi2=(cosmo['omega_b_0']*cosmo['h']**2-0.02207)**2/(0.00033*2)**2 return(-0.5*chi2)