marked_npairs_3d¶

halotools.mock_observables.pair_counters.
marked_npairs_3d
(sample1, sample2, rbins, weight_func_id, period=None, weights1=None, weights2=None, num_threads=1, approx_cell1_size=None, approx_cell2_size=None)[source] [edit on github]¶ Calculate the weighted number of pairs with separations less than or equal to the input
rbins
, \(W(<r)\).The weight given to each pair is determined by the weights for a pair, \(w_1\), \(w_2\), and a userspecified “weighting function”, indicated by the
weight_func_id
parameter, \(f(w_1,w_2)\).Note that if sample1 == sample2 that the
marked_npairs
function doublecounts pairs.Note that this does not count the number of pairs between the bins, but rather the total number with separation smaller than each bin.
Parameters:  sample1 : array_like
Numpy array of shape (Npts1, 3) containing 3D 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. sample2 : array_like
Numpy array of shape (Npts2, 3) containing 3D positions of points. Should be identical to sample1 for cases of autosample pair counts.
 rbins : array_like
numpy array of length Nrbins+1 defining the boundaries of bins in which pairs are counted.
 weight_func_id : int, optional
weighting function integer ID. Each weighting function requires a specific number of weights per point, N_weights. See the Notes for a description of available weighting functions.
 period : array_like, optional
Length3 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.
 weights1 : array_like, optional
Either a 1D array of length N1, or a 2D array of length N1 x N_weights, containing the weights used for the weighted pair counts. If this parameter is None, the weights are set to np.ones((N1,N_weights)).
 weights2 : array_like, optional
Either a 1D array of length N1, or a 2D array of length N1 x N_weights, containing the weights used for the weighted pair counts. If this parameter is None, the weights are set to np.ones((N1,N_weights)).
 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
Length3 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 usecases. Performance can vary sensitively with this parameter, so it is highly recommended that you experiment with this parameter when carrying out performancecritical calculations.
 approx_cell2_size : array_like, optional
Analogous to
approx_cell1_size
, but for sample2. See comments forapprox_cell1_size
for details.
Returns:  wN_pairs : numpy.array
array of length Nrbins containing the weighted number counts of pairs
Notes
See the docstring of the
marked_tpcf
function for a description of the available marking functions that can be passed in via thewfunc
optional argument.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 paircounter by taking the transpose of the result of
numpy.vstack
. This boilerplate transformation is used throughout themock_observables
subpackage:>>> sample1 = np.vstack([x1, y1, z1]).T >>> sample2 = np.vstack([x2, y2, z2]).T >>> weights1 = np.random.random(Npts1) >>> weights2 = np.random.random(Npts2)
>>> result = marked_npairs_3d(sample1, sample2, rbins, period = period, weights1 = weights1, weights2 = weights2, weight_func_id=1)