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 insample2
within an user specified spherical volume centered at each point insample1
.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 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
Npts2 x 3 numpy array containing 3D 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 insample1
. You may optionally pass in an array of length Npts1, in which case each point insample1
will have its own individual neighborsearch radius.Length units are comoving and assumed to be in Mpc/h, here and throughout Halotools.
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.
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
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
r_max
/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 forsample2
. See comments forapprox_cell1_size
for details.Returns: is_isolated : numpy.array
array of booleans indicating if each point in
sample1
is isolated.Notes
There is one edgecase 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 insample2
. The matching point(s) insample2
will not be considered neighbors of p.Examples
For demonstration purposes we create a randomly distributed set of points
sample1
. We will use thespherical_isolation
function to determine which points insample1
are a distancer_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 paircounter by taking the transpose of the result of
numpy.vstack
. This boilerplate transformation is used throughout themock_observables
subpackage:>>> 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 aroundnumpy.vstack
such as placing points into redshiftspace.Now we will call
spherical_isolation
withsample2
set tosample1
, 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 lengthunits 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 fromsample1
, so we will determine which points insample1
are located greater than distancer_max
away from all points insample2
.>>> 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)