spherical_isolation

halotools.mock_observables.spherical_isolation(sample1, sample2, r_max, period=None, num_threads=1, approx_cell1_size=None, approx_cell2_size=None)[source] [edit on github]

Determine whether a set of points, sample1, is isolated, i.e. does not have a neighbor in sample2 within an user specified spherical volume centered at each point in sample1.

See also Galaxy Catalog Analysis Example: Identifying isolated galaxies for example usage on a mock galaxy catalog.

Parameters:

sample1 : array_like

Npts1 x 3 numpy array 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 and sample2 arguments.

Length units are comoving and assumed to be in Mpc/h, here and throughout Halotools.

sample2 : array_like

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

r_max : array_like

radius of spheres to search for neighbors around galaxies in sample1. If a single float is given, r_max is assumed to be the same for each galaxy in sample1. You may optionally pass in an array of length Npts1, in which case each point in sample1 will have its own individual neighbor-search radius.

Length units are comoving and assumed to be in Mpc/h, here and throughout Halotools.

period : array_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.

Length units are comoving and assumed to be in Mpc/h, here and throughout Halotools.

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

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 r_max/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_size : array_like, optional

Analogous to approx_cell1_size, but for sample2. See comments for approx_cell1_size for details.

Returns:

is_isolated : numpy.array

array of booleans indicating if each point in sample1 is isolated.

Notes

There is one edge-case of all the isolation criteria functions worthy of special mention. Suppose there exists a point p in sample1 with the exact same spatial coordinates as one or more points in sample2. The matching point(s) in sample2 will not be considered neighbors of p.

Examples

For demonstration purposes we create a randomly distributed set of points sample1. We will use the spherical_isolation function to determine which points in sample1 are a distance r_max greater than all other points in the sample.

>>> Npts = 1000
>>> Lbox = 250.0
>>> period = Lbox
>>> x = np.random.uniform(0, Lbox, Npts)
>>> y = np.random.uniform(0, Lbox, Npts)
>>> z = np.random.uniform(0, Lbox, 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:

>>> sample1 = np.vstack((x,y,z)).T

Alternatively, you may use the return_xyz_formatted_array convenience function for this same purpose, which provides additional wrapper behavior around numpy.vstack such as placing points into redshift-space.

Now we will call spherical_isolation with sample2 set to sample1, requiring that no other galaxy be located within 500 kpc/h in order for a point to be considered isolated. Recall that Halotools assumes h=1 and that all length-units are in Mpc/h throughout the package.

>>> r_max = 0.5 # isolation cut of 500 kpc/h
>>> is_isolated = spherical_isolation(sample1, sample1, r_max, period=period)

In the next example that follows, sample2 will be a different set of points from sample1, so we will determine which points in sample1 are located greater than distance r_max away from all points in sample2.

>>> x2 = np.random.uniform(0, Lbox, Npts)
>>> y2 = np.random.uniform(0, Lbox, Npts)
>>> z2 = np.random.uniform(0, Lbox, Npts)
>>> sample2 = np.vstack([x2, y2, z2]).T
>>> is_isolated = spherical_isolation(sample1, sample2, r_max, period=period)