gi_plus_3d

halotools.mock_observables.gi_plus_3d(sample1, orientations1, ellipticities1, sample2, rbins, randoms1=None, randoms2=None, weights1=None, weights2=None, ran_weights1=None, ran_weights2=None, estimator='Landy-Szalay', period=None, num_threads=1, approx_cell1_size=None, approx_cell2_size=None)[source]

Calculate the 3-D gravitational shear-intrinsic ellipticity correlation function (GI), \(\xi_{g+}(r_p)\). See the ‘Notes’ section for details of this calculation.

Parameters:
sample1array_like

Npts1 x 3 numpy array containing 3-D positions of points with associated orientations and ellipticities. 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.

orientations1array_like

Npts1 x 3 numpy array containing 3-D orientation vectors for each point in sample1. these will be normalized if not already.

ellipticities1: array_like

Npts1 x 1 numpy array containing ellipticities for each point in sample1.

sample2array_like, optional

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

rbinsarray_like

array of boundaries defining the radial bins in which pairs are counted. Length units are comoving and assumed to be in Mpc/h, here and throughout Halotools.

randoms1array_like, optional

Nran1 x 3 array containing 3-D positions of randomly distributed points corresponding to sample1. If no randoms are provided (the default option), the calculation can proceed using analytical randoms (only valid for periodic boundary conditions).

randoms2array_like, optional

Nran2 x 3 array containing 3-D positions of randomly distributed points corresponding to sample2. If no randoms are provided (the default option), the calculation can proceed using analytical randoms (only valid for periodic boundary conditions).

weights1array_like, optional

Npts1 array of weghts. If this parameter is not specified, it is set to numpy.ones(Npts1).

weights2array_like, optional

Npts2 array of weghts. If this parameter is not specified, it is set to numpy.ones(Npts2).

ran_weights1array_like, optional

Npran1 array of weghts. If this parameter is not specified, it is set to numpy.ones(Nran1).

ran_weights2array_like, optional

Nran2 array of weghts. If this parameter is not specified, it is set to numpy.ones(Nran2).

estimatorstring, optional

string indicating which estimator to use

periodarray_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. If set to None (the default option), PBCs are set to infinity, in which case randoms must be provided. Length units are comoving and assumed to be in Mpc/h, here and throughout Halotools.

num_threadsint, 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_sizearray_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 Lbox/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_sizearray_like, optional

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

Returns:
correlation_functionnumpy.array

len(rbins)-1 length array containing the correlation function \(w_{g+}(r)\) computed in each of the bins defined by input rbins.

Notes

If the Landy-Szalay estimator is indicated, the correlation function is estimated as:

\[ \begin{align}\begin{aligned}\xi_{g+}(r) = \frac{S_{+}D-S_{+}R}{R_sR}\\where\end{aligned}\end{align} \]
\[S_{+}D = \sum_{i \neq j} w_jw_i e_{+}(j|i)\]

\(w_j\) and \(w_j\) are weights. Weights are set to 1 for all galaxies by default. The alingment of the \(j\)-th galaxy relative to the direction to the \(i\)-th galaxy is given by:

\[e_{+}(j|i) = e_j\cos(2\phi)\]

where \(e_j\) is the ellipticity of the \(j\)-th galaxy. \(\phi\) is the angle between the orientation vector, \(\vec{o}_j\), and the direction between the \(j\)-th and \(i\)-th galaxy, \(\vec{r}_{i,j}\).

\[\cos(\phi) = \vec{o}_j \cdot \vec{r}_{i,j}\]

\(S_{+}R\) is analgous to \(S_{+}D\) but instead is computed with respect to a “random” catalog of galaxies. \(R_sR\) are random pair counts, where \(R_s\) corresponds to the shapes sample, i.e. the sample with orienttions and ellipticies, sample1, and R correspoinds to sample2.

Examples

For demonstration purposes we create a randomly distributed set of points within a periodic cube of Lbox = 250 Mpc/h.

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

We then create a set of random orientation vectors and ellipticities for each point

>>> random_orientations = np.random.random((Npts,3))
>>> random_ellipticities = np.random.random(Npts)

We can the calculate the auto-GI correlation between these points:

>>> rbins = np.logspace(-1,1,10)
>>> w = gi_plus_3d(sample1, random_orientations, random_ellipticities, sample1, rbins, period=Lbox)