angular_tpcf¶
- halotools.mock_observables.angular_tpcf(sample1, theta_bins, sample2=None, randoms=None, do_auto=True, do_cross=True, estimator='Natural', num_threads=1)[source]¶
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.
- Parameters:
- sample1array_like
Npts1 x 2 numpy array containing ra,dec positions of points in degrees.
- theta_binsarray_like
array of boundaries defining the angular distance bins in which pairs are counted.
- sample2array_like, optional
Npts2 x 2 array containing ra,dec positions of points in degrees.
- randomsarray_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_autoboolean, optional
Boolean determines whether the auto-correlation function will be calculated and returned. Default is True.
- do_crossboolean, 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 wheresample2
is provided, otherwise False.- estimatorstring, optional
Statistical estimator for the tpcf. Options are ‘Natural’, ‘Davis-Peebles’, ‘Hewett’ , ‘Hamilton’, ‘Landy-Szalay’ Default is
Natural
.- 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.
- Returns:
- 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” ifrandoms
is set to None (see notes for an explanation), otherwise it is calculated using the pair counter.If
sample2
is passed as input (and ifsample2
is not exactly the same assample1
), 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 betweensample1
andsample2
, and the autocorrelation ofsample2
, respectively. Ifdo_auto
ordo_cross
is set to False, the appropriate sequence of results is returned.
Notes
Pairs are counted using
npairs_3d
.Examples
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)