npairs_projected¶
- halotools.mock_observables.npairs_projected(sample1, sample2, rp_bins, pi_max, period=None, num_threads=1, approx_cell1_size=None, approx_cell2_size=None)[source]¶
Function counts the number of pairs of points with separation in the xy-plane less than the input
rp_bins
and separation in the z-dimension less than the inputpi_max
.Note that if sample1 == sample2 that the
npairs_projected
function double-counts pairs. If your science application requires sample1==sample2 inputs and also pairs to not be double-counted, simply divide the final counts by 2.A common variation of pair-counting calculations is to count pairs with separations between two different distances r1 and r2. You can retrieve this information from the
npairs_projected
by takingnumpy.diff
of the returned array.- Parameters:
- sample1array_like
Numpy array of shape (Npts1, 3) 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
andsample2
arguments. Length units are comoving and assumed to be in Mpc/h, here and throughout Halotools.- sample2array_like
Numpy array of shape (Npts2, 3) containing 3-D positions of points. Should be identical to sample1 for cases of auto-sample pair counts.
- 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_maxfloat
Maximum value in the z-dimension over which pairs will be counted.
- 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.
- num_threadsint, 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_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 forapprox_cell1_size
for details.
- Returns:
- num_pairsarray_like
Numpy array of length len(rp_bins) storing the numbers of pairs in the input bins.
Examples
For demonstration purposes we create randomly distributed sets of points within a periodic unit cube.
>>> Npts1, Npts2, Lbox = 1000, 1000, 250. >>> period = [Lbox, Lbox, Lbox] >>> rp_bins = np.logspace(-1, 1.5, 15) >>> pi_max = 40.
>>> x1 = np.random.uniform(0, Lbox, Npts1) >>> y1 = np.random.uniform(0, Lbox, Npts1) >>> z1 = np.random.uniform(0, Lbox, Npts1) >>> x2 = np.random.uniform(0, Lbox, Npts2) >>> y2 = np.random.uniform(0, Lbox, Npts2) >>> z2 = np.random.uniform(0, Lbox, Npts2)
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 themock_observables
sub-package:>>> sample1 = np.vstack([x1, y1, z1]).T >>> sample2 = np.vstack([x2, y2, z2]).T
>>> result = npairs_projected(sample1, sample2, rp_bins, pi_max, period = period)