cuboid_subvolume_labels¶

halotools.mock_observables.
cuboid_subvolume_labels
(sample, Nsub, Lbox)[source] [edit on github]¶ Return integer labels indicating which cubical subvolume of a larger cubical volume a set of points occupy.
Parameters:  sample : array_like
Npts x 3 numpy array containing 3D positions of points.
 Nsub : array_like
Length3 numpy array of integers indicating how many times to split the volume along each dimension. If a single integer, N, is supplied,
Nsub
is set to [N,N,N], and the volume is split along each dimension N times. The total number of subvolumes is given by numpy.prod(Nsub). Lbox : array_like
Length3 numpy array definging the lengths of the sides of the cubical volume that
sample
occupies. If only a single scalar is specified, the volume is assumed to be a cube with sidelength Lbox
Returns:  labels : numpy.array
(Npts, ) numpy array with integer labels in the range [1,numpy.prod(Nsub)] indicating the subvolume each point in
sample
occupies. N_sub_vol : int
number of subvolumes.
Examples
For demonstration purposes we create a randomly distributed set of points within a periodic unit cube.
>>> Npts = 1000 >>> Lbox = 1.0 >>> period = np.array([Lbox,Lbox,Lbox])
>>> x = np.random.random(Npts) >>> y = np.random.random(Npts) >>> z = np.random.random(Npts)
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:>>> sample = np.vstack((x,y,z)).T
Divide the volume into cubes with length 0.25 on a side.
>>> Nsub = [4,4,4] >>> labels, N_sub_vol = cuboid_subvolume_labels(sample, Nsub, Lbox)