halotools.mock_observables.angular_tpcf(sample1, theta_bins, sample2=None, randoms=None, do_auto=True, do_cross=True, estimator='Natural', num_threads=1)[source] [edit on github]

Calculate the angular two-point correlation function, \(w(\theta)\).

Example calls to this function appear in the documentation below. See the Formatting your xyz coordinates for Mock Observables calculations documentation page for instructions on how to transform your coordinate position arrays into the format accepted by the sample1 argument.

For a step-by-step tutorial, see Galaxy Catalog Analysis Example: Angular galaxy clustering.

sample1 : array_like

Npts1 x 2 numpy array containing ra,dec positions of points in degrees.

theta_bins : array_like

array of boundaries defining the angular distance bins in which pairs are counted.

sample2 : array_like, optional

Npts2 x 2 array containing ra,dec positions of points in degrees.

randoms : array_like, optional

Nran x 2 array containing ra,dec positions of points in degrees. If no randoms are provided analytic randoms are used (only valid for for continuous all-sky coverage).

do_auto : boolean, optional

Boolean determines whether the auto-correlation function will be calculated and returned. Default is True.

do_cross : boolean, optional

Boolean determines whether the cross-correlation function will be calculated and returned. Only relevant when sample2 is also provided. Default is True for the case where sample2 is provided, otherwise False.

estimator : string, optional

Statistical estimator for the tpcf. Options are ‘Natural’, ‘Davis-Peebles’, ‘Hewett’ , ‘Hamilton’, ‘Landy-Szalay’ Default is Natural.

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.

correlation_function(s) : numpy.array

len(theta_bins)-1 length array containing the correlation function \(w(\theta)\) computed in each of the bins defined by input theta_bins.

\[1 + w(\theta) \equiv \mathrm{DD}(\theta) / \mathrm{RR}(\theta),\]

If estimator is set to ‘Natural’. \(\mathrm{DD}(\theta)\) is the number of sample pairs with separations equal to \(\theta\), calculated by the pair counter. \(\mathrm{RR}(\theta)\) is the number of random pairs with separations equal to \(\theta\), and is counted internally using “analytic randoms” if randoms is set to None (see notes for an explanation), otherwise it is calculated using the pair counter.

If sample2 is passed as input (and if sample2 is not exactly the same as sample1), then three arrays of length len(rbins)-1 are returned:

\[w_{11}(\theta), w_{12}(\theta), w_{22}(\theta),\]

the autocorrelation of sample1, the cross-correlation between sample1 and sample2, and the autocorrelation of sample2, respectively. If do_auto or do_cross is set to False, the appropriate sequence of results is returned.


Pairs are counted using npairs_3d.


For demonstration purposes we create a randomly distributed set of points on the sky:

>>> from halotools.utils import sample_spherical_surface
>>> Npts = 1000
>>> angular_coords = sample_spherical_surface(Npts) #in degrees
>>> theta_bins = np.logspace(-2,1,10)
>>> w = angular_tpcf(angular_coords, theta_bins)