conditional_spherical_isolation¶

halotools.mock_observables.
conditional_spherical_isolation
(sample1, sample2, r_max, marks1=None, marks2=None, cond_func=0, 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
, where various additional conditions may be applied to judge whether a matching point is considered to be a neighbor.For example,
conditional_spherical_isolation
can be used to identify galaxies as isolated if no other galaxy with a greater stellar mass lies within 500 kpc. Different additional criteria can be built up from different combinations of inputmarks1
,marks2
andcond_func
.See the Examples section for further details, and also Galaxy Catalog Analysis Example: Identifying isolated galaxies, Part II for a tutorial on usage with 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.
 marks1 : array_like, optional
Npts1 x N_marks array of marks. The supplied marks array must have the appropriate shape for the chosen
cond_func
(see Notes for requirements). If this parameter is not specified, all marks will be set to unity. marks2 : array_like, optional
Npts2 x N_marks array of marks. The supplied marks array must have the appropriate shape for the chosen
cond_func
(see Notes for requirements). If this parameter is not specified, all marks will be set to unity. cond_func : int, optional
Integer ID indicating which function should be used to apply an additional condition on whether a nearby point should be considered as a candidate neighbor. This allows, for example, stellar massdependent isolation criteria on a galaxybygalaxy basis.
Default is 0 for an unconditioned calculation, in which case points will be considered neighbor candidates regardless of the value of their marks. See Notes for a list of options for the conditional functions.
 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
The
conditional_spherical_isolation
function only differs from thespherical_isolation
function in the treatment of the input marks. In order for a point p2 insample2
with mark \(w_{2}\) to be considered a neighbor of a point p1 insample1
with mark \(w_{1}\), two following conditions must be met: p2 must lie within a distance
r_max
of p1, and  the input conditional marking function \(f(w_{1}, w_{2})\) must return True.
There are multiple conditional functions available. In general, each requires a different number of marks per point, N_marks. All conditional functions return a boolean and get passed two arrays per pair, w1 and w2, each of length N_marks. You can pass in more than one piece of information about each point by choosing a the input
marks
arrays to be multidimensional of shape (N_points, N_marks).The available marking functions,
cond_func
, and the associated integer ID numbers are: trivial (N_marks = 1)
 \[f(w_1,w_2) = True\]
 greater than (N_marks = 1)
 \[\begin{split}f(w_1,w_2) = \left \{ \begin{array}{ll} True & : w_1[0] > w_2[0] \\ False & : w_1[0] \leq w_2[0] \\ \end{array} \right.\end{split}\]
 less than (N_marks = 1)
 \[\begin{split}f(w_1,w_2) = \left \{ \begin{array}{ll} True & : w_1[0] < w_2[0] \\ False & : w_1[0] \geq w_2[0] \\ \end{array} \right.\end{split}\]
 equality (N_marks = 1)
 \[\begin{split}f(w_1,w_2) = \left \{ \begin{array}{ll} True & : w_1[0] = w_2[0] \\ False & : w_1[0] \neq w_2[0] \\ \end{array} \right.\end{split}\]
 inequality (N_marks = 1)
 \[\begin{split}f(w_1,w_2) = \left \{ \begin{array}{ll} True & : w_1[0] \neq w_2[0] \\ False & : w_1[0] = w_2[0] \\ \end{array} \right.\end{split}\]
 tolerance greater than (N_marks = 2)
 \[\begin{split}f(w_1,w_2) = \left \{ \begin{array}{ll} True & : w_1[0] > (w_2[0]+w_1[1]) \\ False & : w_1[0] \leq (w_2[0]+w_1[1]) \\ \end{array} \right.\end{split}\]
 tolerance less than (N_marks = 2)
 \[\begin{split}f(w_1,w_2) = \left \{ \begin{array}{ll} True & : w_1[0] < (w_2[0]+w_1[1]) \\ False & : w_1[0] \geq (w_2[0]+w_1[1]) \\ \end{array} \right.\end{split}\]
Examples
In this first example, we will show how to calculate the following notion of galaxy isolation. A galaxy is isolated if there are zero other more massive galaxies within 5 Mpc.
First we create a random distribution of points inside the box:
>>> Npts = 1000 >>> Lbox = 250. >>> 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
Now we will choose random stellar masses for our galaxies:
>>> stellar_mass = np.random.uniform(1e10, 1e12, Npts)
Since we are interested in whether a point in
sample1
is isolated from other points insample1
, we setsample2
tosample1
and bothmarks1
andmarks2
equal tostellar_mass
.>>> sample2 = sample1 >>> marks1 = stellar_mass >>> marks2 = stellar_mass
Referring to the Notes above for the definitions of the conditional marking functions, we see that for this particular isolation criteria the appropriate
cond_func
is 2. The reason is that this function only evaluates to True for those points insample2
that are more massive than thesample1
point under consideration. Thus the only relevant points to consider as candidate neighbors are the more massive ones; all othersample2
points will be disregarded irrespective of their distance from thesample1
point under consideration.>>> r_max = 5.0 >>> cond_func = 2
>>> is_isolated = conditional_spherical_isolation(sample1, sample2, r_max, marks1, marks2, cond_func, period=Lbox)