예제 #1
0
def lnlike(theta):
    
    model = Zheng07(threshold = -20.)
    model.param_dict['logM0'] = theta[0]
    model.param_dict['sigma_logM'] = np.exp(theta[1])
    model.param_dict['logMmin'] = theta[2]     
    model.param_dict['alpha'] = theta[3]
    model.param_dict['logM1'] = theta[4]
    model.populate_mock()
    r , xir_model = model.mock.compute_galaxy_clustering()
    res = xir_data - xir_model
    return -0.5*np.sum(np.dot(np.dot(res , inv_c) , res))
예제 #2
0
 def __init__(self): 
     self.model = Zheng07(threshold = -21.5)
예제 #3
0
import numpy as np
import abcpmc
import matplotlib.pyplot as plt
from interruptible_pool import InterruptiblePool
import time
plt.switch_backend("Agg")


from halotools.empirical_models import Zheng07


model = Zheng07(threshold = -21.5)
print 'Data HOD Parameters ', model.param_dict

n_avg = 5
avg_nz, avg_corr = 0., 0.

for i in xrange(n_avg): 
    
    model.populate_mock()
    
    # number density
    avg_nz += model.mock.number_density
    
    # 6th element of xi(r) array
    r, xi_r = model.mock.compute_galaxy_clustering(N_threads=1)

    try:
    	avg_xi += xi_r
    except NameError:
	avg_xi = xi_r
예제 #4
0
 def __init__(self):
     self.model = Zheng07()
예제 #5
0
import time
plt.switch_backend("Agg")
from halotools.empirical_models import Zheng07
from astropy.table import Table
import corner
from scipy.stats import norm, gamma
from scipy.stats import multivariate_normal
from scipy.spatial import cKDTree
import abcpmc
import seaborn as sns
sns.set_style("white")
np.random.seed()
from abcpmc import mpi_util
from scipy.stats import ks_2samp

model = Zheng07(threshold=-20.)
print 'Data HOD Parameters ', model.param_dict
"""data and covariance"""
#We shouldn't treat a mean of mocks as a data!

mock_nbar = np.loadtxt("nbar_Mr20.dat")
#data_nbar = np.mean(mock_nbar)
#mocks_xir = np.loadtxt("xir.dat")
#data_xir = np.mean(mocks_xir , axis = 0)

model.populate_mock()
data_nbar = model.mock.number_density
data_xir = model.mock.compute_galaxy_clustering()[1]
np.savetxt("xir_Mr20.dat", data_xir)
data = [data_nbar, data_xir]
예제 #6
0
ax.plot(mass, input_hod_centrals, color='red', linewidth = 1.)
plt.loglog()
plt.xlim(xmin=1e11, xmax=1e14)
plt.ylim(ymin=5e-3, ymax=10)
plt.xticks(fontsize=20)
plt.yticks(fontsize=20)
fig4.savefig('/home/mj/public_html/abcpaper/hod_centrals.pdf', 
                bbox_extra_artists=[xlabel, ylabel], bbox_inches='tight')

"""
fig5 = plt.figure()
ax = fig5.add_subplot(111)
xlabel = ax.set_xlabel('R [Mpc]', fontsize=20)
ylabel = ax.set_ylabel(r'$\xi_{\rm gg}$', fontsize=25)
title = ax.set_title(r'tpcf of galaxies with $M_{r} > -20$', fontsize=25)
m = Zheng07()
m.populate_mock()
rr = m.compute_galaxy_clustering()[0]
xir = np.loadtxt("xir_Mr20.dat")
xir_cov = np.loadtxt("clustering_covariance_Mr20.dat")
ax.errorbar(rr,
            xir,
            yerr=np.diag(xir_cov)**.5,
            fmt="ok",
            ms=1,
            capsize=2,
            alpha=1.)
plt.xticks(fontsize=20)
plt.yticks(fontsize=20)
plt.xlim(xmin=0.1, xmax=15)
ax.set_yscale("log")
예제 #7
0
from halotools.empirical_models import Zheng07, model_defaults
from halotools.mock_observables import wp
from halotools.mock_observables.clustering import tpcf
from halotools.empirical_models.mock_helpers import (three_dim_pos_bundle,
                                                     infer_mask_from_kwargs)
from halotools.mock_observables.clustering import wp
from halotools.sim_manager import supported_sims
import matplotlib.pyplot as plt
plt.switch_backend("Agg")
import time
import numpy as np
model = Zheng07()

xir = []
for i in range(500):
    model.populate_mock()
    xir.append(model.mock.compute_galaxy_clustering()[1])

covar = np.cov(np.array(xir).T)
np.savetxt("clustering_covariance_Mr20.dat", covar)
"""
a = time.time()
model.mock.compute_galaxy_clustering()
print time.time()  - a
rbins = model_defaults.default_rbins
rbin_centers  = (rbins[1:] + rbins[:-1])/2.
cat = supported_sims.HaloCatalog()
l = cat.Lbox
print l
p_bins = np.linspace(0,l/2,200)
mask = infer_mask_from_kwargs(model.mock.galaxy_table)