delta_sigma

halotools.mock_observables.delta_sigma(galaxies, particles, particle_masses, downsampling_factor, 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), num_threads=1, approx_cell1_size=None, approx_cell2_size=None)[source] [edit on github]

Calculate \(\Delta\Sigma(r_p)\), the galaxy-galaxy lensing signal as a function of projected distance.

The delta_sigma function calculates \(\Delta\Sigma(r_p)\) by calculating the excess surface density of particles in cylinders surrounding the input galaxies. The input particles should be a random downsampling of particles in the same simulation snapshot as the model galaxies.

By using the particle_masses argument, the function works equally well with DM-only 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: Galaxy-galaxy lensing.

Parameters:

galaxies : array_like

Numpy array of shape (num_gal, 3) containing 3-d 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 and particles arguments.

particles : array_like

Numpy array of shape (num_ptcl, 3) containing 3-d positions of particles.

Length units are comoving and assumed to be in Mpc/h, here and throughout Halotools.

particle_masses : float or ndarray

Float or array storing the mass of each particle in units of Msun with h=1 units.

If passing in an ndarray, must be of shape (num_ptcl, ), one array element for every particle.

If passing in a single float, it will be assumed that every particle has the same mass (as is the case in a typical DM-only simulation).

downsampling_factor : float

Factor by which the particles have been randomly downsampled. Should be unity if all simulation particles have been chosen.

See the Examples section below for how this can be calculated from Halotools-provided catalogs.

rp_bins : array_like

Numpy array of shape (num_rbins, ) 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

Length-3 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 comoving and assumed to be in Mpc/h, here and throughout Halotools.

num_threads : int, optional

Number of threads to use in calculation, where parallelization is performed using the python multiprocessing module. Default is 1 for a purely serial calculation, in which case a multiprocessing Pool object will never be instantiated. A string ‘max’ may be used to indicate that the pair counters should use all available cores on the machine.

approx_cell1_size : array_like, optional

Length-3 array serving as a guess for the optimal manner by how points will be apportioned into subvolumes of the simulation box. The optimum choice unavoidably depends on the specs of your machine. Default choice is to use Lbox/10 in each dimension, which will return reasonable result performance for most use-cases. Performance can vary sensitively with this parameter, so it is highly recommended that you experiment with this parameter when carrying out performance-critical calculations.

approx_cell2_size : array_like, optional

Analogous to approx_cell1_size, but for sample2. See comments for approx_cell1_size for details.

Returns:

rp_mids : array_like

Numpy array of shape (num_rbins-1, ) storing the projected radii at which Delta_Sigma has been evaluated.

Delta_Sigma : array_like

Numpy array of shape (num_rbins-1, ) 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 using a mock catalog generated with the FakeSim that is generated on-the-fly.

>>> 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 pair-counter by taking the transpose of the result of numpy.vstack. This boilerplate transformation is used throughout the mock_observables sub-package:

>>> 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 redshift-space 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 use-cases, the delta_sigma function converges at the percent-level 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
>>> rp_mids, ds = delta_sigma(galaxies, particles, particle_masses, downsampling_factor, rp_bins, period)

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.

The code shown above demonstrates how to calculate \(\Delta\Sigma\) via the excess surface density of mass using the z-axis as the axis of projection. However, it may be useful to project along the other Cartesian axes, for example to help beat down sample variance. While the delta_sigma function is written to always use the “third” dimension as the projection axis, you can easily hack the code to project along, say, the y-axis by simply transposing your y- and z-coordinates when you pack them into a 2-d array:

>>> particles = np.vstack((px, pz, py)).T
>>> galaxies = np.vstack((x, z, y)).T

Using the above particles and galaxies and otherwise calling the delta_sigma function as normal will instead calculate the surface mass density by projecting along the y-axis.