# rp_pi_tpcf¶

halotools.mock_observables.rp_pi_tpcf(sample1, rp_bins, pi_bins, sample2=None, randoms=None, period=None, do_auto=True, do_cross=True, estimator='Natural', num_threads=1, approx_cell1_size=None, approx_cell2_size=None, approx_cellran_size=None, seed=None)[source]

Calculate the redshift space correlation function, $$\xi(r_{p}, \pi)$$

Calculate the correlation function as a function of pair separation perpendicular to the line-of-sight (LOS) and parallel to the LOS.

The first two dimensions (x, y) define the plane for perpendicular distances. The third dimension (z) is used for parallel distances, i.e. x,y positions are on the plane of the sky, and z is the radial distance coordinate. This is the ‘distant observer’ approximation.

Example calls to this function appear in the documentation below. 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 sample1 and sample2 arguments.

Parameters:
sample1array_like

Npts1 x 3 numpy array containing 3-D positions of points. See the Formatting your xyz coordinates for Mock Observables calculations documentation page, or the Examples section below, for instructions on how to transform your coordinate position arrays into the format accepted by the sample1 and sample2 arguments. Length units are comoving and assumed to be in Mpc/h, here and throughout Halotools.

rp_binsarray_like

array of boundaries defining the radial bins perpendicular to the LOS in which pairs are counted. Length units are comoving and assumed to be in Mpc/h, here and throughout Halotools.

pi_binsarray_like

array of boundaries defining the p radial bins parallel to the LOS in which pairs are counted. Length units are comoving and assumed to be in Mpc/h, here and throughout Halotools.

sample2array_like, optional

Npts2 x 3 array containing 3-D positions of points. Passing sample2 as an input permits the calculation of the cross-correlation function. Default is None, in which case only the auto-correlation function will be calculated.

randomsarray_like, optional

Nran x 3 array containing 3-D positions of randomly distributed points. If no randoms are provided (the default option), calculation of the tpcf can proceed using analytical randoms (only valid for periodic boundary conditions).

periodarray_like, optional

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. If set to None (the default option), PBCs are set to infinity, in which case randoms must be provided. Length units are comoving and assumed to be in Mpc/h, here and throughout Halotools.

do_autoboolean, optional

Boolean determines whether the auto-correlation function will be calculated and returned. Default is True.

do_crossboolean, optional

Boolean determines whether the cross-correlation function will be calculated and returned. Only relevant when sample2 is also provided. Default is True for the case where sample2 is provided, otherwise False.

estimatorstring, optional

Statistical estimator for the tpcf. Options are ‘Natural’, ‘Davis-Peebles’, ‘Hewett’ , ‘Hamilton’, ‘Landy-Szalay’ Default is Natural.

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_sizearray_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_sizearray_like, optional

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

approx_cellran_sizearray_like, optional

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

seedint, optional

Random number seed used to randomly downsample data, if applicable. Default is None, in which case downsampling will be stochastic.

Returns:
correlation_function(s)numpy.ndarray

len(rp_bins)-1 by len(pi_bins)-1 ndarray containing the correlation function $$\xi(r_p, \pi)$$ computed in each of the bins defined by input rp_bins and pi_bins.

$1 + \xi(r_{p},\pi) = \mathrm{DD}r_{p},\pi) / \mathrm{RR}r_{p},\pi)$

if estimator is set to ‘Natural’, where $$\mathrm{DD}(r_{p},\pi)$$ is calculated by the pair counter, and $$\mathrm{RR}(r_{p},\pi)$$ is counted internally using “analytic randoms” if randoms is set to None (see notes for further details).

If sample2 is passed as input (and not exactly the same as sample1), three arrays of shape len(rp_bins)-1 by len(pi_bins)-1 are returned:

$\xi_{11}(r_{p},\pi), \xi_{12}(r_{p},\pi), \xi_{22}(r_{p},\pi),$

the autocorrelation of sample1, the cross-correlation between sample1 and sample2, and the autocorrelation of sample2, respectively. If do_auto or do_cross is set to False, the appropriate result(s) are returned.

Examples

For demonstration purposes we create a randomly distributed set of points within a periodic cube of Lbox = 250 Mpc/h.

>>> Npts = 1000
>>> Lbox = 250

>>> x = np.random.uniform(0, Lbox, Npts)
>>> y = np.random.uniform(0, Lbox, Npts)
>>> z = np.random.uniform(0, Lbox, Npts)


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:

>>> sample1 = np.vstack((x,y,z)).T


Alternatively, you may use the return_xyz_formatted_array convenience function for this same purpose, which provides additional wrapper behavior around numpy.vstack such as placing points into redshift-space.

>>> rp_bins = np.logspace(-1,1,10)
>>> pi_bins = np.logspace(-1,1,10)
>>> xi = rp_pi_tpcf(sample1, rp_bins, pi_bins, period=Lbox)