コード例 #1
0
ファイル: data_Beutler.py プロジェクト: jchamilton75/MySoft
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 my_invhrs(h=h,om=om,w=w,ob=ob):
    cosmo=cosmolopy.fidcosmo.copy()
    cosmo['h']=h
    cosmo['omega_M_0']=om
    cosmo['omega_lambda_0']=1.-om
    cosmo['omega_k_0']=0.
    cosmo['omega_b_0']=ob
    cosmo['w']=w
    #cosast=astropy.cosmology.wCDM(cosmo['h']*100,cosmo['omega_M_0'],cosmo['omega_lambda_0'],w0=cosmo['w'])
    try:
        hval=cosmo_utils.e_z(zlya,**cosmo)*cosmo['h']
        #hval=cosmolopy.distance.e_z(zlya,**cosmo)*cosmo['h']
        #hval=cosmo['h']/cosast.inv_efunc(zlya)
    except ValueError:
        hval=-1.
    rsval=cosmo_utils.rs(**cosmo)
    theinvhrs=1./(hval*rsval)
    return(theinvhrs)
コード例 #4
0
def thelogproba_ext(h=h,om=om,w=w,ob=ob):
    cosmo=cosmolopy.fidcosmo.copy()
    cosmo['h']=h
    cosmo['omega_M_0']=om
    cosmo['omega_lambda_0']=1.-om
    cosmo['omega_k_0']=0.
    cosmo['omega_b_0']=ob
    cosmo['w']=w
    try:
        daval=cosmo_utils.angdist(zlya,**cosmo)
    except ValueError:
        daval=-1.
    try:
        hval=cosmo_utils.e_z(zlya,**cosmo)*cosmo['h']
    except ValueError:
        hval=-1.
    rsval=cosmo_utils.rs(**cosmo)
    invhrs=1./(hval*rsval)
    da_rs=daval/rsval
    vallogprob=logproba_interp(invhrs,da_rs)
    return(vallogprob,invhrs,da_rs)
コード例 #5
0
ファイル: data_lyaDR11.py プロジェクト: jchamilton75/MySoft
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))
コード例 #6
0
ファイル: plots_bao.py プロジェクト: jchamilton75/MySoft
planck=dict([names[i],planck_chains[:,i+2]] for i in range(np.size(names)))
sz=len(planck['H0*'])

#### Calculate Da and H for Planck
davals=np.zeros((sz,nbz))
hvals=np.zeros((sz,nbz))
for i in np.arange(sz):
    print(i)
    cosmo=mycosmo.copy()
    cosmo['h']=planck['H0*'][i]/100
    cosmo['omega_M_0']=planck['omegam*'][i]
    cosmo['omega_lambda_0']=planck['omegal*'][i]
    cosmo['omega_k_0']=1.-cosmo['omega_M_0']-cosmo['omega_lambda_0']
    cosmo['w']=-1.
    davals[i,:]=cosmo_utils.angdist(zvals,**cosmo)
    hvals[i,:]=cosmo_utils.e_z(zvals,**cosmo)*cosmo['h']

### modele autre
cosmonew=cosmo.copy()
cosmonew['h']=planck['H0*'][i]/100
cosmonew['omega_M_0']=0.26
cosmonew['omega_k_0']=-0.007
cosmonew['omega_lambda_0']=1-cosmonew['omega_M_0']-cosmonew['omega_k_0']
cosmonew['w']=-1.
dazarb=cosmo_utils.angdist(zvals,**cosmonew)
hzarb=cosmo_utils.e_z(zvals,**cosmonew)*cosmonew['h']


    
mda=np.zeros(nbz)
sda=np.zeros(nbz)