# cuboid_subvolume_labels¶

halotools.mock_observables.cuboid_subvolume_labels(sample, Nsub, Lbox)[source]

Return integer labels indicating which cubical subvolume of a larger cubical volume a set of points occupy.

Parameters:
samplearray_like

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

Nsubarray_like

Length-3 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).

Lboxarray_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

Returns:
labelsnumpy.array

(Npts, ) numpy array with integer labels in the range [1,numpy.prod(Nsub)] indicating the subvolume each point in `sample` occupies.

N_sub_volint

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