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.


sample : array_like

Npts x 3 numpy array containing 3-D positions of points.

Nsub : array_like

Length-3 numpy array of integers indicating how many times to split the volume along each dimension. If 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 then given by

Lbox : array_like

Length-3 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 side-length Lbox


labels : numpy.array

numpy array with integer labels in the range [1,] indicating the subvolume each point in sample occupies.

N_sub_vol : int

number of subvolumes.


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 pair-counter by taking the transpose of the result of numpy.vstack. This boilerplate transformation is used throughout the mock_observables sub-package:

>>> 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)