Ejemplo n.º 1
0
def plot_xi_model(file_name="infered_hod_file_name", observables=['xi'], 
                  Mr=20 , data_dict={'Mr':20, 'Nmock':500} , smooth = "False"):
    """
    2PCF model 1\sigma & 2\sigma model predictions 
    """    
    #load the data   
    theta = np.loadtxt(file_name+".dat")[:3] 
    for obv in observables: 
        if obv == 'xi': 
            # import xir and full covariance matrix of xir
            data_xi, data_xi_cov = Data.data_xi_full_cov(**data_dict)   
    
    xi_gg = []

    for i in xrange(len(theta)):
        
        #mod = PrebuiltHodModelFactory('zheng07', threshold=-1*Mr)
        #mod.param_dict["logM0"] = theta[i][0]
        #mod.param_dict["sigma_logM"] = np.exp(theta[i][1])
    	#mod.param_dict["logMmin"] = theta[i][2]
    	#mod.param_dict["alpha"] = theta[i][3]
    	#mod.param_dict["logM1"] = theta[i][4]  
        
        #mod.populate_mock()
        """ if we want to make a smooth plot, we do this:"""
        #rr , xi = mod.compute_average_compute_average_galaxy_clustering(rbins = xi_binedges() , num_iterations = 6 )
        """else"""
        HODsimulator(theta[i], prior_range=None, observables=['xi'], Mr=20)
        xi_gg.append(xi)
 
    xi_gg = np.array(xi_gg)
    a, b, c, d, e = np.percentile(xi_gg, [2.5, 16, 50, 84, 97.5], axis=0)
    
    fig1 = plt.figure()
    ax = fig1.add_subplot(111)

    
    ax.fill_between(rr, a, e, color="k", alpha=0.1, edgecolor="none")
    ax.fill_between(rr, b, d, color="k", alpha=0.3, edgecolor="none")
    ax.plot(rr, c, "k", lw=1)
    ax.errorbar(rr, data_xi, yerr = np.sqrt(np.diag(data_xi_cov)), fmt=".k",
                capsize=0)    
    xlabel = ax.set_xlabel(r'$r[\mathrm{Mpc}h^{-1}]$', fontsize=20)
    ylabel = ax.set_ylabel(r'$\xi_{\rm gg}$', fontsize=25)
    
    plt.xscale('log')
    plt.xlim(xmin = .1 , xmax = 15)
    fig1.savefig('../figs/xi_posterior_prediction'+str(Mr)+'.pdf', 
	        bbox_extra_artists=[xlabel, ylabel], bbox_inches='tight') 



    fig2 = plt.figure()
    ax = fig2.add_subplot(111)

    ax.fill_between(rr, rr*a, rr*e, color="k", alpha=0.1, edgecolor="none")
    ax.fill_between(rr, rr*b, rr*d, color="k", alpha=0.3, edgecolor="none")
    #ax.plot(rr, c, "k", lw=1) we don't care about the best fit here
    ax.errorbar(rr, rr*data_xi, yerr = rr*np.sqrt(np.diag(data_xi_cov)), fmt=".k",
                capsize=0)
    xlabel = ax.set_xlabel(r'$r[\mathrm{Mpc}h^{-1}]$', fontsize=20)
    ylabel = ax.set_ylabel(r'$r\xi_{\rm gg}$', fontsize=25)

    plt.xscale('log')
    plt.xlim(xmin = .1 , xmax = 15)
    fig2.savefig('../figs/xi_scaled_posterior_prediction'+str(Mr)+'.pdf',
                bbox_extra_artists=[xlabel, ylabel], bbox_inches='tight')

    
    fig3 = plt.figure()
    ax = fig3.add_subplot(111)

    ax.fill_between(rr, a - data_xi, e-data_xi, color="k", alpha=0.1, edgecolor="none")
    ax.fill_between(rr, b - data_xi, d-data_xi, color="k", alpha=0.3, edgecolor="none")
    #ax.plot(rr, c, "k", lw=1) we don't care about the best fit here
    ax.errorbar(rr, data_xi - data_xi, yerr = np.sqrt(np.diag(data_xi_cov)), fmt=".k",
                capsize=0)
    xlabel = ax.set_xlabel(r'$r[\mathrm{Mpc}h^{-1}]$', fontsize=20)
    ylabel = ax.set_ylabel(r'$\Delta \xi_{\rm gg}$', fontsize=25)

    plt.xscale('log')
    plt.xlim(xmin = .1 , xmax = 15)
    fig3.savefig('../figs/xi_residual_posterior_prediction'+str(Mr)+'.pdf',
                bbox_extra_artists=[xlabel, ylabel], bbox_inches='tight')


    fig4, axes = pl.subplots(2, 1, figsize=(10, 8) , sharex = True)
    fig4.subplots_adjust(wspace=0.0 , hspace=0.4)

    ax1 = axes[0,0]
    
    ax1.fill_between(rr, a, e, color="k", alpha=0.1, edgecolor="none")
    ax1.fill_between(rr, b, d, color="k", alpha=0.3, edgecolor="none")
    #ax1.plot(rr, c, "k", lw=1)
    ax1.errorbar(rr, data_xi, yerr = np.sqrt(np.diag(data_xi_cov)), fmt=".k",
                capsize=0)    
    ylabel = ax1.set_ylabel(r'$\xi_{\rm gg}$', fontsize=25)
    ax1.set_xscale("log")
    ax1.set_yscale("log")
    ax1_set.xlim(xmin = .1 , xmax = 15)
    
    ax2 = axes[0,0]
    ax2.fill_between(rr, a - data_xi, e- data_xi, color="k", alpha=0.1, edgecolor="none")
    ax2.fill_between(rr, b- data_xi, d- data_xi, color="k", alpha=0.3, edgecolor="none")
    #ax2.plot(rr, c, "k", lw=1)
    ax2.errorbar(rr, data_xi- data_xi , yerr = np.sqrt(np.diag(data_xi_cov)), fmt=".k",
                capsize=0)    
    ylabel = ax2.set_ylabel(r'$\Delta \xi_{\rm gg}$', fontsize=25)
    ax2.set_xscale("log")
    ax2_set.xlim(xmin = .1 , xmax = 15)

    fig4.savefig('../figs/xi&residual_posterior_prediction'+str(Mr)+'.pdf',
                bbox_extra_artists=[xlabel, ylabel], bbox_inches='tight')



    fig5, axes = pl.subplots(2, 1, figsize=(10, 8) , sharex = True)
    fig5.subplots_adjust(wspace=0.0 , hspace=0.4)

    ax1 = axes[0,0]
    
    ax1.fill_between(rr,rr* a, rr* e, color="k", alpha=0.1, edgecolor="none")
    ax1.fill_between(rr, rr* b, rr* d, color="k", alpha=0.3, edgecolor="none")
    #ax1.plot(rr, c, "k", lw=1)
    ax1.errorbar(rr, rr* data_xi, yerr = rr*np.sqrt(np.diag(data_xi_cov)), fmt=".k",
                capsize=0)    
    ylabel = ax1.set_ylabel(r'$r\xi_{\rm gg}$', fontsize=25)
    ax1.set_xscale("log")
    ax1.set_yscale("log")
    ax1_set.xlim(xmin = .1 , xmax = 15)
    
    ax2 = axes[0,0]
    ax2.fill_between(rr, rr* a - rr* data_xi, rr* e- rr* data_xi, color="k", alpha=0.1, edgecolor="none")
    ax2.fill_between(rr, rr* b- rr* data_xi, rr* d- rr* data_xi, color="k", alpha=0.3, edgecolor="none")
    #ax2.plot(rr, c, "k", lw=1)
    ax2.errorbar(rr, rr*data_xi- rr* data_xi , yerr = rr* np.sqrt(np.diag(data_xi_cov)), fmt=".k",
                capsize=0)    
    ylabel = ax2.set_ylabel(r'$\Delta(r\xi_{\rm gg})$', fontsize=25)
    ax2.set_xscale("log")
    ax2_set.xlim(xmin = .1 , xmax = 15)

    fig5.savefig('../figs/xi&residual_scaled_posterior_prediction'+str(Mr)+'.pdf',
                bbox_extra_artists=[xlabel, ylabel], bbox_inches='tight')
Ejemplo n.º 2
0
def plot_posterior_model(observable, abc_theta_file=None, data_dict={'Mr':20, 'b_normal': 0.25, 'Nmock':500},
        clobber=False):
    '''
    Plot 1\sigma and 2\sigma model predictions from ABC-PMC posterior likelihood

    Parameters
    ----------
    observable : string
        One of the following strings ['xi', 'scaledxi', 'gmf']

    '''
    # load the particles
    if abc_theta_file is None:
        raise ValueError("Please specify the theta output file from ABC-PMC run")
    theta = np.loadtxt(abc_theta_file)

    if observable == 'scaledxi':
        obvs_str = 'xi'
    else:
        obvs_str = observable

    obvs_file = ''.join(abc_theta_file.rsplit('.dat')[:-1] + ['.', observable, '.dat'])
    print obvs_file
    if not os.path.isfile(obvs_file) or clobber:
        for i in xrange(len(theta)):
            obv_i  = HODsimulator(
                    theta[i], prior_range=None,
                    observables=[obvs_str], Mr=data_dict['Mr'])
            try:
                model_obv.append(obv_i[0])
            except UnboundLocalError:
                model_obv = [obv_i[0]]
        model_obv = np.array(model_obv)
        np.savetxt(obvs_file, model_obv)
    else:
        model_obv = np.loadtxt(obvs_file)

    if 'xi' in observable:
        r_bin = Data.data_xi_bins(Mr=data_dict['Mr'])
    elif observable == 'gmf':
        r_bin = Data.data_gmf_bins()

    a, b, c, d, e = np.percentile(model_obv, [2.5, 16, 50, 84, 97.5], axis=0)

    # plotting
    fig = plt.figure(1)
    ax = fig.add_subplot(111)

    if observable == 'xi':  # 2PCF
        data_xi, data_xi_cov = Data.data_xi_full_cov(**data_dict) # data

        ax.fill_between(r_bin, a, e, color="k", alpha=0.1, edgecolor="none")
        ax.fill_between(r_bin, b, d, color="k", alpha=0.3, edgecolor="none")
        #ax.plot(r_bin, c, "k", lw=1)
        ax.errorbar(r_bin, data_xi, yerr = np.sqrt(np.diag(data_xi_cov)), fmt=".k",
                    capsize=0)
        ax.set_xlabel(r'$r\;[\mathrm{Mpc}/h]$', fontsize=20)
        ax.set_ylabel(r'$\xi_{\rm gg}$', fontsize=25)
        ax.set_xscale('log')
        ax.set_xlim([0.1, 20.])

    elif observable == 'scaledxi':  # Scaled 2PFC (r * xi)
        data_xi, data_xi_cov = Data.data_xi_full_cov(**data_dict) # data

        ax.fill_between(r_bin, r_bin*a, r_bin*e, color="k", alpha=0.1, edgecolor="none")
        ax.fill_between(r_bin, r_bin*b, r_bin*d, color="k", alpha=0.3, edgecolor="none")
        ax.errorbar(r_bin, r_bin*data_xi, yerr=r_bin*np.sqrt(np.diag(data_xi_cov)), fmt=".k",
                    capsize=0)
        ax.set_xlabel(r'$r\;[\mathrm{Mpc}/h]$', fontsize=20)
        ax.set_ylabel(r'$r \xi_{\rm gg}$', fontsize=25)
        ax.set_xscale('log')
        ax.set_xlim([0.1, 20.])

    elif observable == 'gmf':   # GMF
        data_gmf, data_gmf_sigma = Data.data_gmf(**data_dict)
        ax.fill_between(r_bin, a, e, color="k", alpha=0.1, edgecolor="none")
        ax.fill_between(r_bin, b, d, color="k", alpha=0.3, edgecolor="none")
        ax.errorbar(r_bin, data_gmf, yerr = data_gmf_sigma, fmt=".k",
                    capsize=0)
        ax.set_xlabel(r'Group Richness', fontsize=25)
        ax.set_ylabel(r'GMF $[\mathrm{h}^3\mathrm{Mpc}^{-3}]$', fontsize=25)

        ax.set_yscale('log')
        ax.set_xlim([1., 50.])

    fig.savefig(
            ''.join([util.fig_dir(),
                observable, '.posterior_prediction',
                '.Mr', str(data_dict['Mr']), '_Nmock', str(data_dict['Nmock']),
                '.pdf']),
            bbox_inches='tight')
Ejemplo n.º 3
0
def mcmc_ipython_par(Nwalkers, Nchains_burn, Nchains_pro, observables=['nbar', 'xi'], 
        data_dict={'Mr':20, 'Nmock':500}, prior_name = 'first_try', threads=1): 
    '''
    Standard MCMC implementaion
    

    Parameters
    -----------
    - Nwalker : 
        Number of walkers
    - Nchains_burn : 
        Number of burn-in chains
    - Nchains_pro : 
        Number of production chains   
    - observables : 
        list of observables. Options are 'nbar', 'gmf', 'xi'
    - data_dict : dictionary that specifies the observation keywords
    '''
    # data observables
    fake_obs = []       # list of observables 
    fake_obs_cov = [] 
    for obv in observables: 
        if obv == 'nbar': 
            data_nbar, data_nbar_var = Data.data_nbar(**data_dict)
            fake_obs.append(data_nbar)
            fake_obs_cov.append(data_nbar_var)
        if obv == 'gmf': 
            data_gmf, data_gmf_sigma = Data.data_gmf(**data_dict)
            fake_obs.append(data_gmf)
            fake_obs_cov.append(data_gmf)
        if obv == 'xi': 
            # import xir and full covariance matrix of xir
            data_xi, data_xi_cov = Data.data_xi_full_cov(**data_dict)   
            data_xi_invcov = Data.data_xi_inv_cov(**data_dict)
            fake_obs.append(data_xi)
            fake_obs_cov.append(data_xi_invcov)

    # True HOD parameters
    data_hod_dict = Data.data_hod_param(Mr=data_dict['Mr'])
    data_hod = np.array([
        data_hod_dict['logM0'],                 # log M0 
        np.log(data_hod_dict['sigma_logM']),    # log(sigma)
        data_hod_dict['logMmin'],               # log Mmin
        data_hod_dict['alpha'],                 # alpha
        data_hod_dict['logM1']                  # log M1
        ])
    Ndim = len(data_hod)
    
    # Priors
    prior_min, prior_max = PriorRange(prior_name)
    prior_range = np.zeros((len(prior_min),2))
    prior_range[:,0] = prior_min
    prior_range[:,1] = prior_max
    
    # Initializing Walkers 
    random_guess = np.array([11. , np.log(.4) , 11.5 , 1.0 , 13.5])
    pos0 = np.repeat(random_guess, Nwalkers).reshape(Ndim, Nwalkers).T + \
            1e-1 * np.random.randn(Ndim * Nwalkers).reshape(Nwalkers, Ndim)

    # Initializing the emcee sampler
    hod_kwargs = {
            'prior_range': prior_range, 
            'data': fake_obs, 
            'data_cov': fake_obs_cov, 
            'observables': observables, 
            'Mr': data_dict['Mr']
            }
    # Set up the interface to the ipcluster.
    c = Client()
    view = c[:]
    view.push({"lnPost": lnPost})
     
    # Modules necessary in posterior calculation should be called here
    view.execute("import numpy as np")
    view.execute("from hod_sim import HODsimulator")

    # Setting up the Sampler
    sampler = emcee.EnsembleSampler(Nwalkers, Ndim, lnPost, kwargs=hod_kwargs, pool = view)

    # Setting up a file for saving the chains
    chain_file = ''.join([util.dat_dir(), 
        util.observable_id_flag(observables), 
        '_Mr', str(data_dict["Mr"]), '_theta.mcmc_chain.dat'])
    f = open(chain_file, "w")
    f.close()

    # Running the Sampler and writing out the chains
    for result in sampler.sample(pos0, iterations=Nchains_burn + Nchains_pro, storechain=False):
        position = result[0]
        f = open(chain_file, "a")
        for k in range(position.shape[0]):
	    output_str = '\t'.join(position[k].astype('str')) + '\n'
            f.write(output_str)
        f.close()
Ejemplo n.º 4
0
def plot_posterior_model(observable,
                         abc_theta_file=None,
                         data_dict={
                             'Mr': 20,
                             'b_normal': 0.25,
                             'Nmock': 500
                         },
                         clobber=False):
    '''
    Plot 1\sigma and 2\sigma model predictions from ABC-PMC posterior likelihood

    Parameters
    ----------
    observable : string
        One of the following strings ['xi', 'scaledxi', 'gmf']

    '''
    # load the particles
    if abc_theta_file is None:
        raise ValueError(
            "Please specify the theta output file from ABC-PMC run")
    theta = np.loadtxt(abc_theta_file)

    if observable == 'scaledxi':
        obvs_str = 'xi'
    else:
        obvs_str = observable

    obvs_file = ''.join(
        abc_theta_file.rsplit('.dat')[:-1] + ['.', observable, '.dat'])
    print obvs_file
    if not os.path.isfile(obvs_file) or clobber:
        for i in xrange(len(theta)):
            obv_i = HODsimulator(theta[i],
                                 prior_range=None,
                                 observables=[obvs_str],
                                 Mr=data_dict['Mr'])
            try:
                model_obv.append(obv_i[0])
            except UnboundLocalError:
                model_obv = [obv_i[0]]
        model_obv = np.array(model_obv)
        np.savetxt(obvs_file, model_obv)
    else:
        model_obv = np.loadtxt(obvs_file)

    if 'xi' in observable:
        r_bin = Data.data_xi_bins(Mr=data_dict['Mr'])
    elif observable == 'gmf':
        r_bin = Data.data_gmf_bins()

    a, b, c, d, e = np.percentile(model_obv, [2.5, 16, 50, 84, 97.5], axis=0)

    # plotting
    fig = plt.figure(1)
    ax = fig.add_subplot(111)

    if observable == 'xi':  # 2PCF
        data_xi, data_xi_cov = Data.data_xi_full_cov(**data_dict)  # data

        ax.fill_between(r_bin, a, e, color="k", alpha=0.1, edgecolor="none")
        ax.fill_between(r_bin, b, d, color="k", alpha=0.3, edgecolor="none")
        #ax.plot(r_bin, c, "k", lw=1)
        ax.errorbar(r_bin,
                    data_xi,
                    yerr=np.sqrt(np.diag(data_xi_cov)),
                    fmt=".k",
                    capsize=0)
        ax.set_xlabel(r'$r\;[\mathrm{Mpc}/h]$', fontsize=20)
        ax.set_ylabel(r'$\xi_{\rm gg}$', fontsize=25)
        ax.set_xscale('log')
        ax.set_xlim([0.1, 20.])

    elif observable == 'scaledxi':  # Scaled 2PFC (r * xi)
        data_xi, data_xi_cov = Data.data_xi_full_cov(**data_dict)  # data

        ax.fill_between(r_bin,
                        r_bin * a,
                        r_bin * e,
                        color="k",
                        alpha=0.1,
                        edgecolor="none")
        ax.fill_between(r_bin,
                        r_bin * b,
                        r_bin * d,
                        color="k",
                        alpha=0.3,
                        edgecolor="none")
        ax.errorbar(r_bin,
                    r_bin * data_xi,
                    yerr=r_bin * np.sqrt(np.diag(data_xi_cov)),
                    fmt=".k",
                    capsize=0)
        ax.set_xlabel(r'$r\;[\mathrm{Mpc}/h]$', fontsize=20)
        ax.set_ylabel(r'$r \xi_{\rm gg}$', fontsize=25)
        ax.set_xscale('log')
        ax.set_xlim([0.1, 20.])

    elif observable == 'gmf':  # GMF
        data_gmf, data_gmf_sigma = Data.data_gmf(**data_dict)
        ax.fill_between(r_bin, a, e, color="k", alpha=0.1, edgecolor="none")
        ax.fill_between(r_bin, b, d, color="k", alpha=0.3, edgecolor="none")
        ax.errorbar(r_bin, data_gmf, yerr=data_gmf_sigma, fmt=".k", capsize=0)
        ax.set_xlabel(r'Group Richness', fontsize=25)
        ax.set_ylabel(r'GMF $[\mathrm{h}^3\mathrm{Mpc}^{-3}]$', fontsize=25)

        ax.set_yscale('log')
        ax.set_xlim([1., 50.])

    fig.savefig(''.join([
        util.fig_dir(), observable, '.posterior_prediction', '.Mr',
        str(data_dict['Mr']), '_Nmock',
        str(data_dict['Nmock']), '.pdf'
    ]),
                bbox_inches='tight')
Ejemplo n.º 5
0
def mcmc_ipython_par(Nwalkers,
                     Nchains_burn,
                     Nchains_pro,
                     observables=['nbar', 'xi'],
                     data_dict={
                         'Mr': 20,
                         'Nmock': 500
                     },
                     prior_name='first_try',
                     threads=1):
    '''
    Standard MCMC implementaion
    

    Parameters
    -----------
    - Nwalker : 
        Number of walkers
    - Nchains_burn : 
        Number of burn-in chains
    - Nchains_pro : 
        Number of production chains   
    - observables : 
        list of observables. Options are 'nbar', 'gmf', 'xi'
    - data_dict : dictionary that specifies the observation keywords
    '''
    # data observables
    fake_obs = []  # list of observables
    fake_obs_cov = []
    for obv in observables:
        if obv == 'nbar':
            data_nbar, data_nbar_var = Data.data_nbar(**data_dict)
            fake_obs.append(data_nbar)
            fake_obs_cov.append(data_nbar_var)
        if obv == 'gmf':
            data_gmf, data_gmf_sigma = Data.data_gmf(**data_dict)
            fake_obs.append(data_gmf)
            fake_obs_cov.append(data_gmf)
        if obv == 'xi':
            # import xir and full covariance matrix of xir
            data_xi, data_xi_cov = Data.data_xi_full_cov(**data_dict)
            data_xi_invcov = Data.data_xi_inv_cov(**data_dict)
            fake_obs.append(data_xi)
            fake_obs_cov.append(data_xi_invcov)

    # True HOD parameters
    data_hod_dict = Data.data_hod_param(Mr=data_dict['Mr'])
    data_hod = np.array([
        data_hod_dict['logM0'],  # log M0 
        np.log(data_hod_dict['sigma_logM']),  # log(sigma)
        data_hod_dict['logMmin'],  # log Mmin
        data_hod_dict['alpha'],  # alpha
        data_hod_dict['logM1']  # log M1
    ])
    Ndim = len(data_hod)

    # Priors
    prior_min, prior_max = PriorRange(prior_name)
    prior_range = np.zeros((len(prior_min), 2))
    prior_range[:, 0] = prior_min
    prior_range[:, 1] = prior_max

    # Initializing Walkers
    random_guess = np.array([11., np.log(.4), 11.5, 1.0, 13.5])
    pos0 = np.repeat(random_guess, Nwalkers).reshape(Ndim, Nwalkers).T + \
            1e-1 * np.random.randn(Ndim * Nwalkers).reshape(Nwalkers, Ndim)

    # Initializing the emcee sampler
    hod_kwargs = {
        'prior_range': prior_range,
        'data': fake_obs,
        'data_cov': fake_obs_cov,
        'observables': observables,
        'Mr': data_dict['Mr']
    }
    # Set up the interface to the ipcluster.
    c = Client()
    view = c[:]
    view.push({"lnPost": lnPost})

    # Modules necessary in posterior calculation should be called here
    view.execute("import numpy as np")
    view.execute("from hod_sim import HODsimulator")

    # Setting up the Sampler
    sampler = emcee.EnsembleSampler(Nwalkers,
                                    Ndim,
                                    lnPost,
                                    kwargs=hod_kwargs,
                                    pool=view)

    # Setting up a file for saving the chains
    chain_file = ''.join([
        util.dat_dir(),
        util.observable_id_flag(observables), '_Mr',
        str(data_dict["Mr"]), '_theta.mcmc_chain.dat'
    ])
    f = open(chain_file, "w")
    f.close()

    # Running the Sampler and writing out the chains
    for result in sampler.sample(pos0,
                                 iterations=Nchains_burn + Nchains_pro,
                                 storechain=False):
        position = result[0]
        f = open(chain_file, "a")
        for k in range(position.shape[0]):
            output_str = '\t'.join(position[k].astype('str')) + '\n'
            f.write(output_str)
        f.close()
Ejemplo n.º 6
0
Nwalkers = 10
Nchains_burn = 1
Nchains_pro = 1
    
# data observables
fake_obs = []       # list of observables 
for obv in observables: 
    if obv == 'nbar': 
        data_nbar, data_nbar_var = Data.data_nbar(**data_dict)
        fake_obs.append(data_nbar)
    if obv == 'gmf': 
        data_gmf, data_gmf_sigma = Data.data_gmf(**data_dict)
        fake_obs.append(data_gmf)
    if obv == 'xi': 
        # import xir and full covariance matrix of xir 
        data_xi, data_xi_cov = Data.data_xi_full_cov(**data_dict)           
        # take the inverse of the covariance matrix
        data_xi_invcov = solve(np.eye(len(data_xi)) , data_xi_cov)          
        fake_obs.append(data_xi)

# 'True' HOD parameters
data_hod_dict = Data.data_hod_param(Mr=data_dict['Mr'])
data_hod = np.array([
    data_hod_dict['logM0'],                 # log M0 
    np.log(data_hod_dict['sigma_logM']),    # log(sigma)
    data_hod_dict['logMmin'],               # log Mmin
    data_hod_dict['alpha'],                 # alpha
    data_hod_dict['logM1']                  # log M1
    ])
Ndim = len(data_hod)
Ejemplo n.º 7
0
Nwalkers = 10
Nchains_burn = 1
Nchains_pro = 1

# data observables
fake_obs = []  # list of observables
for obv in observables:
    if obv == 'nbar':
        data_nbar, data_nbar_var = Data.data_nbar(**data_dict)
        fake_obs.append(data_nbar)
    if obv == 'gmf':
        data_gmf, data_gmf_sigma = Data.data_gmf(**data_dict)
        fake_obs.append(data_gmf)
    if obv == 'xi':
        # import xir and full covariance matrix of xir
        data_xi, data_xi_cov = Data.data_xi_full_cov(**data_dict)
        # take the inverse of the covariance matrix
        data_xi_invcov = solve(np.eye(len(data_xi)), data_xi_cov)
        fake_obs.append(data_xi)

# 'True' HOD parameters
data_hod_dict = Data.data_hod_param(Mr=data_dict['Mr'])
data_hod = np.array([
    data_hod_dict['logM0'],  # log M0 
    np.log(data_hod_dict['sigma_logM']),  # log(sigma)
    data_hod_dict['logMmin'],  # log Mmin
    data_hod_dict['alpha'],  # alpha
    data_hod_dict['logM1']  # log M1
])
Ndim = len(data_hod)