Exemple #1
0
def correlation_unit_test():
    import correlation
    import hod
    import kernel
    print "\n******************************"
    print "*                            *"
    print "* Testing Correlation Module *"
    print "*                            *"
    print "******************************\n"

    ### Definining a correlation object requires first two window functions
    ### (these could in principle be the same window function), theta bounds to
    ### compute the correlation over, and optionaly and HOD object and a
    ### specification as to which power spectrum to use. Note: the different
    ### correlation classes have approprate default values.

    ### As in kernel_unit_test create galaxy distributions
    lens_dist = kernel.dNdzMagLim(0.0, 2.0, 2, 0.3, 2)
    source_dist = kernel.dNdzGaussian(0.0, 2.0, 1.0, 0.2)

    ### create appropreate window objects
    lens_window = kernel.WindowFunctionGalaxy(lens_dist)
    source_window = kernel.WindowFunctionConvergence(source_dist)

    ### define an hod (optional but needed in order to use power_gm or power_gg)
    zheng = hod.HODZheng(10**13.0, 0.15, 10**13.0, 10**14.0, 1.0)
    ### Define the correlation objects. Note that each of these correlations
    ### is computed using the nonlinear dark matter power spectrum, power_mm.
    ### other options are linear_power which computes the correlation for the
    ### linear spectrum only, power_gm which is the galaxy-matter cross spectrum
    ### and power_gg which is the galaxy-galaxy power spectrum.
    ### Here we define the correlation function of galaxy clustering, note that
    ### it takes only one window function as the second is assumed identical
    theta_array = numpy.logspace(-3, 0, 5)
    auto = correlation.AutoCorrelation(theta_min=0.001 * degToRad,
                                       theta_max=1.0 * degToRad,
                                       window_function_galaxy=lens_window,
                                       input_hod=zheng,
                                       powSpec='power_mm')
    print "Auto Correlation: (theta [deg], wtheta)"
    for theta in theta_array:
        print "\t", (theta, auto.correlation(theta * degToRad))
    ### Define the correlation for galaxy-galaxy magnification. Note it takes
    ### and WindowFunctionGalaxy object and a WindowFunctionConvergence Object
    mag = correlation.MagCorrelation(0.001 * degToRad,
                                     1.0 * degToRad,
                                     lens_window,
                                     source_window,
                                     input_hod=zheng,
                                     powSpec='power_mm')
    print "Convergence Correlation: (theta [deg], wtheta)"
    for theta in theta_array:
        print "\t", (theta, mag.correlation(theta * degToRad))
    print ""
Exemple #2
0
    def __init__(self,
                 redshift=0.0,
                 single_epoch_cosmo=None,
                 mass_func_second=None,
                 perturbation=None,
                 halo_dict=None,
                 input_hod=None,
                 power_spec='power_mmmm'):
        self.pert = perturbation
        halo.Halo.__init__(self, redshift, None, single_epoch_cosmo,
                           mass_func_second, halo_dict)
        self.power_spec = power_spec
        if input_hod is None:
            input_hod = hod.HODZheng()
        self.local_hod = input_hod

        self._initialized_i_0_4 = False
Exemple #3
0
def hod_unit_test():
    import hod
    print "\n**********************"
    print "*                    *"
    print "* Testing HOD Module *"
    print "*                    *"
    print "**********************\n"
    ### Create a Zheng et al. 2007 HOD object with central mass 10**13,
    ### satellite mass difference. The other parameters are fixed M_0 = M_min,
    ### alpha = 1.0, log_sigma_m = 0.15
    zheng = hod.HODZheng(10**12, 0.15, 10**12, 10**13, 1.0)
    mass_array = numpy.logspace(9, 16, 5)
    ### compute the first three moments of the HOD and print to screen
    print "HOD: (mass [M_solar/h], <N>, <N(N-1)>, <N(N-1)(N-2)>)"
    for mass in mass_array:
        print "\t", (mass, zheng.first_moment(mass), zheng.second_moment(mass),
                     zheng.nth_moment(mass, 3))
    print ""
Exemple #4
0
def halo_unit_test():
    import halo
    import hod
    print "\n***********************"
    print "*                     *"
    print "* Testing Halo Module *"
    print "*                     *"
    print "***********************\n"

    ### We test each of the 4 avalible power spectra as a function of redshift
    ### first create a halo occupation distribution object using a Zheng07 HOD
    zheng = hod.HODZheng(10**13.0, 0.15, 10**13.0, 10**14.0, 1.0)
    ### initialize the halo model object at z=0.0 with the Zheng HOD
    h = halo.Halo(redshift=0.0, input_hod=zheng)
    print(
        "Halo: (k [Mpc/h], linear_power, power_mm, "
        "power_gm, power_gg [(Mpc/h)^3])")
    k_array = numpy.logspace(-3, 2, 5)
    for k in k_array:
        print "\t", (k, h.linear_power(k), h.power_mm(k), h.power_gm(k),
                     h.power_gg(k))
    print ""
Exemple #5
0
 def setUp(self):
     cosmo_multi = cosmology.MultiEpoch(0.0, 5.0, cosmo_dict=c_dict)
     lens_dist = kernel.dNdzMagLim(z_min=0.0, z_max=2.0, 
                                   a=2, z0=0.3, b=2)
     source_dist = kernel.dNdzGaussian(z_min=0.0, z_max=2.0,
                                       z0=1.0, sigma_z=0.2)
     lens_window = kernel.WindowFunctionGalaxy(
         lens_dist, cosmo_multi_epoch=cosmo_multi)
     source_window = kernel.WindowFunctionConvergence(
         source_dist, cosmo_multi_epoch=cosmo_multi)
     kern = kernel.Kernel(0.001*0.001*deg_to_rad, 1.0*100.0*deg_to_rad,
                          window_function_a=lens_window,
                          window_function_b=source_window,
                          cosmo_multi_epoch=cosmo_multi)
     
     zheng = hod.HODZheng(hod_dict)
     cosmo_single = cosmology.SingleEpoch(0.0, cosmo_dict=c_dict)
     h = halo.Halo(input_hod=zheng, cosmo_single_epoch=cosmo_single)
     self.corr = correlation.Correlation(0.001, 1.0,
                                         input_kernel=kern,
                                         input_halo=h,
                                         power_spec='power_mm')
     self.theta_array = numpy.logspace(-3, 0, 4)*deg_to_rad
Exemple #6
0
    def __init__(self, redshift=0.0, input_hod=None, cosmo_dict=None,
                 halo_dict=None, use_camb=False, **kws):
        # Hard coded, but we shouldn't expect halos outside of this range.
        self._k_min = 0.001
        self._k_max = 100.0
        ln_mass_min = numpy.log(1.0e9)
        ln_mass_max = numpy.log(5.0e16)
        
        self._ln_k_max = numpy.log(self._k_max)
        self._ln_k_min = numpy.log(self._k_min)

        self._ln_k_array = numpy.linspace(
            self._ln_k_min, self._ln_k_max,
            defaults.default_precision["halo_npoints"])

        if cosmo_dict is None:
            cosmo_dict = defaults.default_cosmo_dict
        self.cosmo_dict = cosmo_dict

        if halo_dict is None:
            halo_dict = defaults.default_halo_dict
        self.halo_dict = halo_dict

        if redshift is None: redshift = 0.0
        self._redshift = redshift

        self.c0 = halo_dict["c0"]/(1.0 + self._redshift)
        self.beta = halo_dict["beta"]

        # If we hard-code to an NFW profile, then we can use an analytic
        # form for the halo profile Fourier transform.
        # self.alpha = -1.0*halo_dict.dpalpha
        self.alpha = -1.0

        self.cosmo = cosmology.SingleEpoch(self._redshift, cosmo_dict)
        self.delta_v = self.cosmo.delta_v()
        self.rho_bar = self.cosmo.rho_bar()
        self._h = self.cosmo._h

        self.mass = mass_function.MassFunction(
            self._redshift, cosmo_dict, halo_dict)

        if input_hod is None:
            input_hod = hod.HODZheng()
        self.local_hod = input_hod
    
        self.use_camb = use_camb
        if self.use_camb:
            self.camb = camb.CambWrapper(cosmo_dict)
            self.camb.set_redshift(redshift)
            self.camb.run()
            self.camb.normalize(self.cosmo.sigma_8*self.cosmo._growth)

        self._calculate_n_bar()
        self._initialize_halo_splines()

        self._initialized_h_m = False
        self._initialized_h_g = False

        self._initialized_pp_mm = False
        self._initialized_pp_gm = False
        self._initialized_pp_gg = False
Exemple #7
0
mass_tmp = np.loadtxt(mass_file)
mass = interpolate.InterpolatedUnivariateSpline(np.log(mass_tmp[:, 0]),
                                                mass_tmp[:, 6])
#mass = mass_function.MassFunction(redshift=3.0,
#cosmo_single_epoch=cosmo_single,
#halo_dict=halo_dict)
hod_dict_ini = {
    "log_M_min": 12.14,
    "sigma": 0.15,
    "log_M_0": 12.14,
    "log_M_1p": 13.43,
    "alpha": 1.0,
    "w": 1.0
}

sdss_hod = hod.HODZheng(hod_dict_ini)

halo_model_low = halo.Halo(redshift=0.1,
                           input_hod=sdss_hod,
                           cosmo_single_epoch=cosmo_single_low,
                           mass_func=mass_low)

lens_dist_low = kernel.dNdzInterpolation(
    p_z[:25, 0], p_z[:25, 1])  #dNdzGaussian(0.0, 5.0, 3.1, 0.05)#0.1)#0.5

lens_window_low = kernel.WindowFunctionGalaxy(lens_dist_low, cosmo_multi)
con_kernel_low = kernel.Kernel(ktheta_min=0.001 * 0.001 * deg_to_rad,
                               ktheta_max=100.0 * 1.0 * deg_to_rad,
                               window_function_a=lens_window_low,
                               window_function_b=lens_window_low,
                               cosmo_multi_epoch=cosmo_multi)
Exemple #8
0
 def setUp(self):
     cosmo = cosmology.SingleEpoch(0.0, cosmo_dict=c_dict)
     zheng = hod.HODZheng(hod_dict)
     self.h = halo.Halo(input_hod=zheng, cosmo_single_epoch=cosmo)
     self.k_array = numpy.logspace(-3, 2, 4)
Exemple #9
0
 def setUp(self):
     self.zheng = hod.HODZheng(hod_dict)
     self.mass_array = numpy.logspace(9, 16, 4)
     self.first_moment_list = [0.0, 0.0, 2.6732276, 372.48394295]
     self.second_moment_list = [0.0, 0.0, 6.14614597, 138743.2877621]
     self.nth_moment_list = [0.0, 0.0, 11.83175124, 51678901.92217977]