delta_sigma_from_precomputed_pairs¶

halotools.mock_observables.
delta_sigma_from_precomputed_pairs
(galaxies, mass_enclosed_per_galaxy, rp_bins, period, cosmology=FlatLambdaCDM(name="WMAP5", H0=70.2 km / (Mpc s), Om0=0.277, Tcmb0=2.725 K, Neff=3.04, m_nu=[ 0. 0. 0.] eV, Ob0=0.0459))[source] [edit on github]¶ Calculate \(\Delta\Sigma(r_p)\), the galaxygalaxy lensing signal as a function of projected distance, assuming the mass around each galaxy has been precomputed.
By using the
particle_masses
argument, the function works equally well with DMonly simulations as with hydro simulations that include particles of variable mass.Example calls to this function appear in the documentation below.
See also Galaxy Catalog Analysis Example: Galaxygalaxy lensing.
Parameters: galaxies : array_like
Numpy array of shape (num_gal, 3) containing 3d positions of galaxies. Length units are comoving and assumed to be in Mpc/h, here and throughout Halotools.
See the Formatting your xyz coordinates for Mock Observables calculations documentation page for instructions on how to transform your coordinate position arrays into the format accepted by the
galaxies
andparticles
arguments.mass_enclosed_per_galaxy : array_like
Numpy array of shape (num_gal, num_rp_bins+1) storing the mass enclosed inside each of the cylinders defined by the input
rp_bins
.The
mass_enclosed_per_galaxy
argument can be calculated using thetotal_mass_enclosed_per_cylinder
function, as demonstrated in the Examples section below.rp_bins : array_like
Numpy array of shape (num_rbins+1, ) of projected radial boundaries defining the bins in which the result is calculated.
Length units are comoving and assumed to be in Mpc/h, here and throughout Halotools.
period : array_like
Length3 sequence defining the periodic boundary conditions in each dimension. If you instead provide a single scalar, Lbox, period is assumed to be the same in all Cartesian directions. Length units are assumed to be in Mpc/h, here and throughout Halotools.
Returns: Delta_Sigma : array_like
Numpy array of shape (num_rbins1, ) storing \(\Delta\Sigma(r_p)\) in comoving units of \(h M_{\odot} / {\rm Mpc}^2\) assuming h=1.
Examples
For demonstration purposes we will calculate
delta_sigma_from_precomputed_pairs
using a mock catalog generated with theFakeSim
that is generated onthefly.>>> from halotools.sim_manager import FakeSim >>> halocat = FakeSim()
Now let’s populate this halo catalog with mock galaxies.
>>> from halotools.empirical_models import PrebuiltHodModelFactory >>> model = PrebuiltHodModelFactory('leauthaud11', threshold = 11.) >>> model.populate_mock(halocat)
Now we retrieve the positions of our mock galaxies and transform the arrays into the shape of the ndarray expected by the
delta_sigma
function. We transform our x, y, z points into the array shape used by the paircounter by taking the transpose of the result ofnumpy.vstack
. This boilerplate transformation is used throughout themock_observables
subpackage:>>> x = model.mock.galaxy_table['x'] >>> y = model.mock.galaxy_table['y'] >>> z = model.mock.galaxy_table['z'] >>> galaxies = np.vstack((x, y, z)).T
The
return_xyz_formatted_array
function also performs this same transformation, and can also be used to place mock galaxies into redshiftspace for additional observational realism.Let’s do the same thing for a set of particle data:
>>> px = model.mock.ptcl_table['x'] >>> py = model.mock.ptcl_table['y'] >>> pz = model.mock.ptcl_table['z'] >>> particles = np.vstack((px, py, pz)).T
The default Halotools catalogs come with ~1e6 particles. Using this many particles may be overkill: in many typical usecases, the
delta_sigma
function converges at the percentlevel using an order of magnitude fewer particles. The code below shows how to (optionally) downsample these particles using a Halotools convenience function.>>> from halotools.utils import randomly_downsample_data >>> num_ptcls_to_use = int(1e4) >>> particles = randomly_downsample_data(particles, num_ptcls_to_use) >>> particle_masses = np.zeros(num_ptcls_to_use) + halocat.particle_mass
Whether or not you perform additional downsampling, you will need to account for the fact that you are not using the entire snapshot of particles by providing the
downsampling_factor
argument:>>> total_num_ptcl_in_snapshot = halocat.num_ptcl_per_dim**3 >>> downsampling_factor = total_num_ptcl_in_snapshot/float(len(particles))
>>> rp_bins = np.logspace(1, 1, 10) >>> period = model.mock.Lbox
Now we calculate the mass enclosed by the cylinders around each galaxy:
>>> from halotools.mock_observables import total_mass_enclosed_per_cylinder
>>> mass_encl = total_mass_enclosed_per_cylinder(galaxies, particles, particle_masses, downsampling_factor, rp_bins, period)
At this point, we know the total mass enclosing every galaxy in our sample. Now suppose we are only interested in calculating the lensing signal around some subsample of our galaxies. Then we just build a mask for the sample of galaxies we are interested in and proceed as follows:
>>> cenmask = model.mock.galaxy_table['gal_type'] == 'centrals' >>> cens = galaxies[cenmask] >>> mass_encl_cens = mass_encl[cenmask, :]
>>> rp, ds = delta_sigma_from_precomputed_pairs(cens, mass_encl_cens, rp_bins, period, cosmology=halocat.cosmology)
Take care with the units. The values for \(\Delta\Sigma\) returned by the
delta_sigma
functions are in comoving units of \(h M_{\odot} / {\rm Mpc}^2\) assuming h=1, whereas the typical units used to plot \(\Delta\Sigma\) are in physical units of \(M_{\odot} / {\rm pc}^2\) using the value of little h appropriate for your assumed cosmology.