tpcf_one_two_halo_decomp¶
- halotools.mock_observables.tpcf_one_two_halo_decomp(sample1, sample1_host_halo_id, rbins, sample2=None, sample2_host_halo_id=None, randoms=None, period=None, do_auto=True, do_cross=True, estimator='Natural', num_threads=1, approx_cell1_size=None, approx_cell2_size=None, approx_cellran_size=None, seed=None)[source]¶
Calculate the real space one-halo and two-halo decomposed two-point correlation functions, \(\xi^{1h}(r)\) and \(\xi^{2h}(r)\).
This returns the correlation function for galaxies which reside in the same halo, and those that reside in separate halos, as indicated by a host halo ID.
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
andsample2
arguments.See also Galaxy Catalog Analysis Example: Calculating galaxy clustering in 3d.
- Parameters:
- sample1array_like
Npts1 x 3 numpy array containing 3-D 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.- sample1_host_halo_idarray_like, optional
len(sample1) integer array of host halo ids.
- rbinsarray_like
array of boundaries defining the real space radial bins in which pairs are counted. Length units are comoving and assumed to be in Mpc/h, here and throughout Halotools.
- sample2array_like, optional
Npts2 x 3 array containing 3-D positions of points. Passing
sample2
as an input permits the calculation of the cross-correlation function. Default is None, in which case only the auto-correlation function will be calculated.- sample2_host_halo_idarray_like, optional
len(sample2) integer array of host halo ids.
- randomsarray_like, optional
Nran x 3 array containing 3-D positions of randomly distributed points. If no randoms are provided (the default option), calculation of the tpcf can proceed using analytical randoms (only valid for periodic boundary conditions).
- 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.- 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.- 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 forapprox_cell1_size
for details.- approx_cellran_sizearray_like, optional
Analogous to
approx_cell1_size
, but for randoms. See comments forapprox_cell1_size
for details.- seedint, optional
Random number seed used to randomly downsample data, if applicable. Default is None, in which case downsampling will be stochastic.
- Returns:
- correlation_function(s)numpy.array
Two len(rbins)-1 length arrays containing the one and two halo correlation functions, \(\xi^{1h}(r)\) and \(\xi^{2h}(r)\), computed in each of the radial bins defined by input
rbins
.\[1 + \xi(r) \equiv \mathrm{DD} / \mathrm{RR},\]if
estimator
is set to ‘Natural’, where \(\mathrm{DD}\) is calculated by the pair counter, and \(\mathrm{RR}\) is counted internally using “analytic randoms” if norandoms
are passed as an argument (see notes for an explanation). If a differentestimator
is specified, the appropiate formula is used.If
sample2
is passed as input, six arrays of length len(rbins)-1 are returned:\[\xi^{1h}_{11}(r), \ \xi^{2h}_{11}(r),\]\[\xi^{1h}_{12}(r), \ \xi^{2h}_{12}(r),\]\[\xi^{1h}_{22}(r), \ \xi^{2h}_{22}(r),\]the autocorrelation of one and two halo autocorrelation of
sample1
, the one and two halo cross-correlation betweensample1
andsample2
, and the one and two halo autocorrelation ofsample2
. Ifdo_auto
ordo_cross
is set to False, only the appropriate result(s) is returned.
Examples
For demonstration purposes, we’ll use the
FakeSim
to demonstrate how to calculate the 1- and 2-halo term on a set of fake halos.>>> from halotools.sim_manager import FakeSim >>> halocat = FakeSim()
>>> x,y,z = halocat.halo_table['halo_x'], halocat.halo_table['halo_y'], halocat.halo_table['halo_z'] >>> sample1 = np.vstack((x,y,z)).T
>>> rbins = np.logspace(-2,-1,10) >>> host_halo_IDs = halocat.halo_table['halo_hostid'] >>> xi_1h, xi_2h = tpcf_one_two_halo_decomp(sample1, host_halo_IDs, rbins, period=halocat.Lbox)