예제 #1
0
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)
예제 #2
0
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)
예제 #3
0
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))
예제 #4
0
mycosmo['baryonic_effects']=True
mycosmo['h']=0.7
mycosmo['omega_M_0']=0.27
mycosmo['omega_lambda_0']=0.73
mycosmo['omega_k_0']=0.
mycosmo['w']=-1.0
mycosmo['omega_b_0']=0.0227/mycosmo['h']**2
mycosmo['omega_n_0']=0
mycosmo['Num_Nu_massless']=3.046
mycosmo['Num_Nu_massive']=0

print(L.rs_fidu)
print(cosmo_utils.rs(**mycosmo))
print(cosmo_utils.rs_zstar_camb(**mycosmo))
print(cosmo_utils.rs_zdrag_camb(**mycosmo))
print(cosmo_utils.rs_zdrag_fast_camb(**mycosmo))

cosmoplanck=L.mycosmo.copy()
cosmoplanck['h']=0.6704
cosmoplanck['Y_He']=0.247710
obh2=0.022032
onh2=0.000645
och2=0.120376-onh2
cosmoplanck['omega_M_0']=(och2+obh2+onh2)/cosmoplanck['h']**2
cosmoplanck['omega_lambda_0']=1.-cosmoplanck['omega_M_0']
cosmoplanck['omega_k_0']=0
cosmoplanck['omega_b_0']=obh2/cosmoplanck['h']**2
cosmoplanck['omega_n_0']=onh2/cosmoplanck['h']**2
cosmoplanck['n']=0.9619123

print(cosmo_utils.rs_camb(**cosmoplanck))
예제 #5
0
### fiducial cosmo
zlya = 2.46
mycosmo = cosmolopy.fidcosmo.copy()
mycosmo["baryonic_effects"] = True
mycosmo["h"] = 0.7
mycosmo["omega_M_0"] = 0.27
mycosmo["omega_lambda_0"] = 0.73
mycosmo["omega_k_0"] = 0.0
mycosmo["w"] = -1.0
mycosmo["omega_b_0"] = 0.0227 / mycosmo["h"] ** 2
mycosmo["omega_n_0"] = 0
mycosmo["Num_Nu_massless"] = 3.046
mycosmo["Num_Nu_massive"] = 0
da_fidu = cosmolopy.distance.angular_diameter_distance(zlya, **mycosmo)
h_fidu = cosmolopy.distance.e_z(zlya, **mycosmo) * mycosmo["h"]
rs_fidu = cosmo_utils.rs_zdrag_fast_camb(**mycosmo)
hrs_fidu = h_fidu * rs_fidu
da_rs_fidu = da_fidu / rs_fidu

X_hrs = apar1d / hrs_fidu
Yda_rs = aper1d * da_rs_fidu
X_hrs_min = aparmin / hrs_fidu
Yda_rs_min = apermin * da_rs_fidu
newdx = dx / hrs_fidu
newdy = dy * da_rs_fidu
proba = proba / np.sum(proba) / newdx / newdy

# clf()
# xlabel('$1/(H r_s)$')
# ylabel('$D_A/r_s$')
# imshow(transpose(proba/np.max(proba)),extent=(np.min(X_hrs)-newdx/2,np.max(X_hrs)+newdx/2,np.min(Yda_rs)-newdy/2,np.max(Yda_rs)+newdy/2),origin='lower',interpolation='nearest',aspect='auto')