Example #1
0
 def setUp(self):
     self.lens_dist = kernel.dNdzMagLim(z_min=0.0, z_max=2.0, 
                                        a=2, z0=0.3, b=2)
     self.source_dist = kernel.dNdzGaussian(z_min=0.0, z_max=2.0,
                                            z0=1.0, sigma_z=0.2)
     self.z_array = numpy.linspace(0.0, 2.0, 4)
     self.lens_dist_list = [0.0, 0.00318532, 0.0, 0.0]
     self.source_dist_list = [3.72665317e-06, 0.24935220, 
                              0.24935220, 3.72665317e-06]
Example #2
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 ""
Example #3
0
 def setUp(self):
     lens_dist = kernel.dNdzMagLim(z_min=0.0, z_max=2.0, 
                                        a=1, z0=0.3, b=1)
     source_dist = kernel.dNdzGaussian(z_min=0.0, z_max=2.0,
                                            z0=1.0, sigma_z=0.2)
     cosmo = cosmology.MultiEpoch(0.0, 5.0, cosmo_dict=c_dict)
     self.lens_window = kernel.WindowFunctionGalaxy(
         lens_dist, cosmo_multi_epoch=cosmo)
     self.source_window = kernel.WindowFunctionConvergence(
         source_dist, cosmo_multi_epoch=cosmo)
     self.z_array = numpy.linspace(0.0, 2.0, 4)
Example #4
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 ""
Example #5
0
 def setUp(self):
     cosmo = 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)
     source_window = kernel.WindowFunctionConvergence(
         source_dist, cosmo_multi_epoch=cosmo)
     self.kern = kernel.Kernel(0.001*0.001*degToRad, 1.0*100.0*degToRad,
                            window_function_a=lens_window,
                            window_function_b=source_window,
                            cosmo_multi_epoch=cosmo)
     self.ln_ktheta_array = numpy.linspace(-15, -1, 4)
Example #6
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
Example #7
0
### Initialize the halo object with the mass function and single epoch
### cosmology implementation is from Seljak2000.
halo_model = halo.Halo(redshift=0.0,
                       input_hod=sdss_hod,
                       cosmo_single_epoch=cosmo_single)

### From this point we have fully defined our cosmology and halo model.
### The next step is defining the redshift distributions and appropriate
### window functions.

### Below we define our foreground lenses and background source distributions
### needed for projecting our power spectrum from halo onto the sky. We use
### the functional form of a magnitude limited sample for the lens and for the
### sources we use a Gaussian with mean z=1.0. Other options could be used here,
### see kernel.py for other implemented distributions.
lens_dist = kernel.dNdzMagLim(0.0, 2.0, 2.0, 0.3, 2.0)
source_dist = kernel.dNdzGaussian(0.0, 2.0, 1.0, 0.2)

### Now we need to create the appropriate window functions that will allow us
### to project the power spectrum from halo. Currently these come in two
### varieties. The first is WindowFunctionGalaxy which defines the dn/dchi
### distribution of galaxies. If one is interested in the clustering of two(one)
### galaxy populations this is correlation should be used. The second is
### WindowFunctionConvergence which defines the lensing kernel weighted
### distribution. Cosmic shear and magnification studies should use 2 of
### these. For the galaxy-galaxy magnification which we are trying to compute we
### need both a galaxy window function (for the lenses) and a convergence
### window function (for the sources).
lens_window = kernel.WindowFunctionGalaxy(lens_dist, cosmo_multi)
source_window = kernel.WindowFunctionConvergence(source_dist, cosmo_multi)
lens_window.write('test_lens_window.ascii')
Example #8
0
def kernel_unit_test():
    import cosmology
    import kernel
    print "\n*************************"
    print "*                       *"
    print "* Testing kernel Module *"
    print "*                       *"
    print "*************************\n"

    print "Testing dNdz"
    print "*************************"

    ### To define a Kernel object we need several things first. We need redshift
    ### distributions as well as the corresponding window functions.

    ### initilized to galaxy redshift distributions one as a magnitude limited
    ### sample, the other a Guassian with mean z=1.0
    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)
    ### normalize the distributions and create PDFs
    lens_dist.normalize()
    source_dist.normalize()

    z_array = numpy.linspace(0.0, 2.0, 5)
    print "Lens dNdz: (z, p(z)dz)"
    for z in z_array:
        print "\t", (z, lens_dist.dndz(z))

    print "Source dNdz: (z, p(z)dz)"
    for z in z_array:
        print "\t", (z, source_dist.dndz(z))
    print ""

    print "Testing WindowFunction"
    print "*************************"
    cosmo = cosmology.MultiEpoch(0.0, 2.0)

    ### using the distributions defined above compute the distance weighted
    ### window functions for use in projecting a powerspectrum
    ### Define a galaxy window function
    chi_array = cosmo.comoving_distance(z_array)
    lens_window = kernel.WindowFunctionGalaxy(redshift_dist=lens_dist)
    print "Lens Window: (chi [Mpc/h], window value [h/Mpc])"
    for chi in chi_array:
        print "\t", (chi, lens_window.window_function(chi))
    ### Backup write command if more information is needed
    # lens_window.write('test_galaxy_window_function.ascii')

    ### Define a lensed population of galaxies
    source_window = kernel.WindowFunctionConvergence(redshift_dist=source_dist)
    print "Source Window: (chi [Mpc/h], window value [h/Mpc])"
    for chi in chi_array:
        print "\t", (chi, source_window.window_function(chi))

    ### Backup write command if more information is needed
    # source_window.write('test_convergence_window_function.ascii')

    print "Testing Kernel"
    print "*************************"

    ### Initialize the kernel objects for projecting a power spectrum in z space
    ### Initilize the kernel for galaxy clustering
    ln_ktheta_array = numpy.linspace(-15, -1, 5)
    k_Auto = kernel.Kernel(ktheta_min=0.001 * degToRad * 0.001,
                           ktheta_max=1.0 * degToRad * 100.0,
                           window_function_a=lens_window,
                           window_function_b=lens_window)
    print "Auto Kernel: (k*theta [h/Mpc*Radians], kernel value [(h/Mpc)^2])"
    for ln_ktheta in ln_ktheta_array:
        print "\t", (numpy.exp(ln_ktheta), k_Auto.kernel(ln_ktheta))
    ### Backup write command if more information is needed
    # k_Auto.write('test_clustering_kernel.ascii')

    ### Kernel computing lensing convergence
    k_Con = kernel.Kernel(0.001 * degToRad * 0.001, 1.0 * degToRad * 100.0,
                          lens_window, source_window)
    print(
        "Convergence Kernel: (k*theta [h/Mpc*Radians], "
        "kernel value [(h/Mpc)^2])")
    for ln_ktheta in ln_ktheta_array:
        print "\t", (numpy.exp(ln_ktheta), k_Con.kernel(ln_ktheta))
    print ""
    ### Backup write command if more information is needed
    # k_Con.write("test_convergence_kernel.ascii")

    ### Print out the redshifts for which the kernel is maximaly sensitive
    print "Peak Sensitivity at Redshifts:", k_Auto.z_bar, k_Con.z_bar
halo_model = halo.Halo(redshift=0.0, input_hod=sdss_hod,
                       cosmo_single_epoch=cosmo_single,
                       mass_func=mass,
                       extrapolate=True)


### From this point we have fully defined our cosmology and halo model.
### The next step is defining the redshift distributions and appropriate 
### window functions.

### Below we define our foreground lenses and background source distributions 
### needed for projecting our power spectrum from halo onto the sky. We use
### the functional form of a magnitude limited sample for the lens and for the
### sources we use a Gaussian with mean z=1.0. Other options could be used here,
### see kernel.py for other implemented distributions.
lens_dist = kernel.dNdzMagLim(0.001, 5.0, 2.0, 0.3, 2.0)
z_bar = 1.0
dz = 0.001
source_dist = kernel.dNdzGaussian(z_bar - 5.0*dz, z_bar + 5.0*dz, z_bar, dz)

### Now we need to create the appropriate window functions that will allow us 
### to project the power spectrum from halo. Currently these come in two
### varieties. The first is WindowFunctionGalaxy which defines the dn/dchi
### distribution of galaxies. If one is interested in the clustering of two(one)
### galaxy populations this is correlation should be used. The second is
### WindowFunctionConvergence which defines the lensing kernel weighted
### distribution. Cosmic shear and magnification studies should use 2 of 
### these. For the galaxy-galaxy magnification which we are trying to compute we
### need both a galaxy window function (for the lenses) and a convergence
### window function (for the sources).
lens_window = kernel.WindowFunctionGalaxy(lens_dist, cosmo_multi)
Example #10
0
def kernel_unit_test():
    import cosmology
    import kernel
    print "\n*************************"
    print "*                       *"
    print "* Testing kernel Module *"
    print "*                       *"
    print "*************************\n"

    print "Testing dNdz"
    print "*************************"

    ### To define a Kernel object we need several things first. We need redshift
    ### distributions as well as the corresponding window functions.
    
    ### initilized to galaxy redshift distributions one as a magnitude limited
    ### sample, the other a Guassian with mean z=1.0
    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)
    ### normalize the distributions and create PDFs
    lens_dist.normalize()
    source_dist.normalize()

    z_array = numpy.linspace(0.0, 2.0, 5)
    print "Lens dNdz: (z, p(z)dz)"
    for z in z_array:
        print "\t",(z, lens_dist.dndz(z))

    print "Source dNdz: (z, p(z)dz)"
    for z in z_array:
        print "\t",(z, source_dist.dndz(z))
    print ""

    print "Testing WindowFunction"
    print "*************************"
    cosmo = cosmology.MultiEpoch(0.0, 2.0)

    ### using the distributions defined above compute the distance weighted
    ### window functions for use in projecting a powerspectrum
    ### Define a galaxy window function
    chi_array = cosmo.comoving_distance(z_array)
    lens_window = kernel.WindowFunctionGalaxy(redshift_dist=lens_dist)
    print "Lens Window: (chi [Mpc/h], window value [h/Mpc])"
    for chi in chi_array:
        print "\t",(chi, lens_window.window_function(chi))
    ### Backup write command if more information is needed
    # lens_window.write('test_galaxy_window_function.ascii')

    ### Define a lensed population of galaxies
    source_window = kernel.WindowFunctionConvergence(redshift_dist=source_dist)
    print "Source Window: (chi [Mpc/h], window value [h/Mpc])"
    for chi in chi_array:
        print "\t",(chi, source_window.window_function(chi))

    ### Backup write command if more information is needed
    # source_window.write('test_convergence_window_function.ascii')

    print "Testing Kernel"
    print "*************************"
    
    ### Initialize the kernel objects for projecting a power spectrum in z space
    ### Initilize the kernel for galaxy clustering
    ln_ktheta_array = numpy.linspace(-15, -1, 5)
    k_Auto = kernel.Kernel(ktheta_min=0.001*degToRad*0.001, 
                           ktheta_max=1.0*degToRad*100.0,
                           window_function_a=lens_window, 
                           window_function_b=lens_window)
    print "Auto Kernel: (k*theta [h/Mpc*Radians], kernel value [(h/Mpc)^2])"
    for ln_ktheta in ln_ktheta_array:
        print "\t",(numpy.exp(ln_ktheta), k_Auto.kernel(ln_ktheta))
    ### Backup write command if more information is needed
    # k_Auto.write('test_clustering_kernel.ascii')

    ### Kernel computing lensing convergence
    k_Con = kernel.Kernel(0.001*degToRad*0.001, 1.0*degToRad*100.0,
                          lens_window, source_window)
    print ("Convergence Kernel: (k*theta [h/Mpc*Radians], "
           "kernel value [(h/Mpc)^2])")
    for ln_ktheta in ln_ktheta_array:
        print "\t",(numpy.exp(ln_ktheta), k_Con.kernel(ln_ktheta))
    print ""
    ### Backup write command if more information is needed
    # k_Con.write("test_convergence_kernel.ascii")    
    
    ### Print out the redshifts for which the kernel is maximaly sensitive
    print "Peak Sensitivity at Redshifts:", k_Auto.z_bar, k_Con.z_bar