# s_mu_tpcf¶

halotools.mock_observables.s_mu_tpcf(sample1, s_bins, mu_bins, sample2=None, randoms=None, period=None, do_auto=True, do_cross=True, estimator=u'Natural', num_threads=1, approx_cell1_size=None, approx_cell2_size=None, approx_cellran_size=None, seed=None)[source] [edit on github]

Calculate the redshift space correlation function, $$\xi(s, \mu)$$

Divide redshift space into bins of radial separation and angle to to the line-of-sight (LOS). This is a pre-step for calculating correlation function multipoles.

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: sample1 : array_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. s_bins : array_like numpy array of shape (num_s_bin_edges, ) storing the $$s$$ boundaries defining the bins in which pairs are counted. mu_bins : array_like numpy array of shape (num_mu_bin_edges, ) storing the $$\cos(\theta_{\rm LOS})$$ boundaries defining the bins in which pairs are counted. All values must be between [0,1]. sample2 : array_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. randoms : array_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). period : array_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_auto : boolean, optional Boolean determines whether the auto-correlation function will be calculated and returned. Default is True. do_cross : boolean, 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. estimator : string, optional Statistical estimator for the tpcf. Options are ‘Natural’, ‘Davis-Peebles’, ‘Hewett’ , ‘Hamilton’, ‘Landy-Szalay’ Default is Natural. 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. approx_cellran_size : array_like, optional Analogous to approx_cell1_size, but for randoms. See comments for approx_cell1_size for details. seed : int, optional Random number seed used to randomly downsample data, if applicable. Default is None, in which case downsampling will be stochastic. correlation_function(s) : np.ndarray Numpy array of shape (num_s_bin_edges-1, num_mu_bin_edges-1) containing the correlation function $$\xi(s, \mu)$$ computed in each of the bins defined by input s_bins and mu_bins. $1 + \xi(s,\mu) = \mathrm{DD}(s,\mu) / \mathrm{RR}(s,\mu)$ if estimator is set to ‘Natural’, where $$\mathrm{DD}(s,\mu)$$ is calculated by the pair counter, and $$\mathrm{RR}(s,\mu)$$ is counted internally using “analytic randoms” if randoms is set to None (see notes for further details). If sample2 is not None (and not exactly the same as sample1), three arrays of shape len(s_bins)-1 by len(mu_bins)-1 are returned: $\xi_{11}(s,\mu), \xi_{12}(s,\mu), \xi_{22}(s,\mu),$ 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.

Notes

Let $$\vec{s}$$ be the radial vector connnecting two points. The magnitude, $$s$$, is:

$s = \sqrt{r_{\parallel}^2+r_{\perp}^2},$

where $$r_{\parallel}$$ is the separation parallel to the LOS and $$r_{\perp}$$ is the separation perpednicular to the LOS. $$\mu$$ is the cosine of the angle, $$\theta_{\rm LOS}$$, between the LOS and $$\vec{s}$$:

$\mu = \cos(\theta_{\rm LOS}) \equiv r_{\parallel}/s.$

Pairs are counted using npairs_s_mu.

If the period argument is passed in, the ith coordinate of all points must be between 0 and period[i].

Examples

For demonstration purposes we create a randomly distributed set of points within a periodic cube with 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.

>>> s_bins = np.logspace(-1, 1, 10)
>>> mu_bins = np.linspace(0, 1, 50)
>>> xi = s_mu_tpcf(sample1, s_bins, mu_bins, period=Lbox)