positional_marked_npairs_3d¶
- halotools.mock_observables.pair_counters.positional_marked_npairs_3d(sample1, sample2, rbins, period=None, weights1=None, weights2=None, weight_func_id=0, verbose=False, num_threads=1, approx_cell1_size=None, approx_cell2_size=None)[source]¶
Calculate the number of weighted pairs with separations greater than or equal to r, \(W(>r)\), where the weight of each pair is given by soe function of a N-d array stored in each input weight and the separation vector of the pair.
Note that if sample1 == sample2 that the
positional_marked_npairs
function double-counts pairs.- 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.
- rbinsarray_like
numpy array of length Nrbins+1 defining the boundaries of bins in which pairs are 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.
- weights1array_like, optional
Either a 1-D array of length N1, or a 2-D array of length N1 x N_weights1, containing the weights used for the weighted pair counts. If this parameter is None, the weights are set to np.ones((N1, N_weights1)).
- weights2array_like, optional
Either a 1-D array of length N2, or a 2-D array of length N2 x N_weights2, containing the weights used for the weighted pair counts. If this parameter is None, the weights are set to np.ones((N2, N_weights2)).
- weight_func_idint, optional
weighting function integer ID. Each weighting function requires a specific number of weights per point, N_weights1, N_weights2. See the Notes for a description of available weighting functions.
- verboseBoolean, optional
If True, print out information and progress.
- 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:
- wN_pairsnumpy.array
Numpy array of shape (Nrbins, ) containing the weighted number counts of pairs
- N_pairsnumpy.array
Numpy array of shape (Nrbins, ) containing the number counts of pairs
Notes
There are multiple marking functions available. In general, each requires a different number of marks per point, N_marks. The marking function gets passed three vectors per pair: \(w_1\) and \(w_2\) of length N_marks, and \(s_{12}\), the length 3 vector between points 1 and 2. Each function returns a float. The available marking functions,
weight_func_id
and the associated integer ID numbers are:- position-shape dot product (N_marks = 4,1)
- \[\begin{split}\begin{array}{ll} \cos\theta = (w_1[1]\times s_{12}[0] + w_1[2]\times s_{12}[1] + w_1[3]\times s_{12}[2])/\sqrt{|s_{12}|} \\ f(w_1,w_2) = w_1[0]\times w_2[0]\times \cos\theta \end{array}\end{split}\]
- gamma plus (N_marks = 4,1)
- \[\begin{split}\begin{array}{ll} \cos\theta = (w_1[1]\times s_{12}[0] + w_1[2]\times s_{12}[1] + w_1[3]\times s_{12}[2])/\sqrt{|s_{12}|} \\ \theta = \cos^{-1}(\cos\theta) \\ f(w_1,w_2) = w_1[0]\times w_2[0]\times \cos(2\theta) \end{array}\end{split}\]
- gamma minus (N_marks = 4,1)
- \[\begin{split}\begin{array}{ll} \cos\theta = (w_1[1]\times s_{12}[0] + w_1[2]\times s_{12}[1] + w_1[3]\times s_{12}[2])/\sqrt{|s_{12}|} \\ \theta = \cos^{-1}(\cos\theta) \\ f(w_1,w_2) = w_1[0]\times w_2[0]\times \sin(2\theta) \end{array}\end{split}\]
- position-shape dot product squared (N_marks = 4,1)
- \[\begin{split}\begin{array}{ll} \cos\theta = (w_1[1]\times s_{12}[0] + w_1[2]\times s_{12}[1] + w_1[3]\times s_{12}[2])/\sqrt{|s_{12}|} \\ f(w_1,w_2) = w_1[0]\times w_2[0]\times \cos\theta\cos\theta \end{array}\end{split}\]
Examples
For demonstration purposes we create randomly distributed sets of points within a periodic unit cube, using random weights.
>>> Npts1, Npts2, Lbox = 1000, 1000, 250. >>> period = [Lbox, Lbox, Lbox] >>> rbins = np.logspace(-1, 1.5, 15)
>>> 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
We create a set of random weights:
>>> weights1 = np.random.random((Npts1, 4)) >>> weights2 = np.random.random((Npts2, 1))
The weighted counts are calculated by:
>>> weighted_counts, counts = positional_marked_npairs_3d(sample1, sample2, rbins, period=period, weights1=weights1, weights2=weights2, weight_func_id=1)