nbodykit.algorithms.paircount_tpcf.tpcf¶
Classes

Base class for twopoint correlation function algorithms that use pair counting. 

Compute the twopoint correlation function for data in a simulation box as a function of \(r\), \((r,\mu)\), \((r_p, \pi)\), or \(\theta\) using pair counting. 

Compute the twopoint correlation function for observational survey data as a function of \(r\), \((r,\mu)\), \((r_p, \pi)\), or \(\theta\) using pair counting. 
 class nbodykit.algorithms.paircount_tpcf.tpcf.BasePairCount2PCF(mode, data1, edges, Nmu=None, pimax=None, randoms1=None, randoms2=None, data2=None, R1R2=None, **kws)[source]¶
Base class for twopoint correlation function algorithms that use pair counting. The API largely follows that of
SimulationBoxPairCount
andSurveyDataPairCount
. Parameters
mode ('1d', '2d', 'projected', 'angular') – the type of two point correlation function to compute
data1 (CatalogSource) – the data catalog; must have a ‘Position’ column
edges (array_like) – the bin edges along the first binning dimension
Nmu (int, optional) – when
mode
is ‘2d’, the number of mu bins, ranging from 0 to 1pimax (float, optional) – when
mode
is ‘projected’, the maximum separation along the lineofsightrandoms1 (CatalogSource, optional) – the catalog specifying the unclustered, random distribution for
data1
; if not provided, analytic randoms will be usedrandoms2 (CatalogSource, optional) – the catalog specifying the unclustered, random distribution for
data2
; if not provided, analytic randoms will be useddata2 (CatalogSource, optional) – the second data catalog to crosscorrelate; must have a ‘Position’ column
R1R2 (SimulationBoxPairCount, SurveyDataPairCount, optional) – if provided, random pairs R1R2 are not recalculated in the LandySzalay estimator
**kws – additional keyword arguments passed to the appropriate pair counting class
Methods
load
(output[, comm])Load a result has been saved to disk with
save()
.run
()Run the twopoint correlation function algorithm.
save
(output)Save result as a JSON file with name
output
 run()[source]¶
Run the twopoint correlation function algorithm.
There are two cases here:
If no randoms were provided, and the data is in a simulation box with periodic boundary conditions, the natural estimator \(DD/RR  1\) is used.
If randoms were provided, the LandySzalay estimator is used: \((D_1 D_2  D_1 R_2  D_2 R_1 + R_1 R_2) / R_1 R_2\)
 Raises
ValueError : – if periodic boundary conditions were not requested, and
randoms1
isNone
ValueError : – if periodic boundary conditions were not requested, and
data2
is not None, butrandoms2
isNone
 class nbodykit.algorithms.paircount_tpcf.tpcf.SimulationBox2PCF(mode, data1, edges, Nmu=None, pimax=None, data2=None, randoms1=None, randoms2=None, R1R2=None, periodic=True, BoxSize=None, los='z', weight='Weight', position='Position', show_progress=False, **config)[source]¶
Compute the twopoint correlation function for data in a simulation box as a function of \(r\), \((r,\mu)\), \((r_p, \pi)\), or \(\theta\) using pair counting.
This uses analytic randoms when using periodic conditions, unless a randoms catalog is specified. The “natural” estimator (DD/RR1) is used in the former case, and the LandySzalay estimator (DD/RR  2DR/RR + 1) in the latter case.
Note
When using analytic randoms, the expected counts are assumed to be unweighted.
 Parameters
mode ('1d', '2d', 'projected', 'angular') – the type of twopoint correlation function to compute; see the Notes below
data1 (CatalogSource) – the data catalog;
edges (array_like) – the separation bin edges along the first coordinate dimension; depending on
mode
, the options are \(r\), \(r_p\), or \(\theta\). Expected units for distances are \(\mathrm{Mpc}/h\) and degrees for angles. Length of nbins+1Nmu (int, optional) – the number of \(\mu\) bins, ranging from 0 to 1; requred if
mode='2d'
pimax (float, optional) – The maximum separation along the lineofsight when
mode='projected'
. Distances along the \(\pi\) direction are binned with unit depth. For instance, ifpimax=40
, then 40 bins will be created along the \(\pi\) direction.data2 (CatalogSource, optional) – the second data catalog to crosscorrelate;
randoms1 (CatalogSource, optional) – the catalog specifying the unclustered, random distribution for
data1
; if not provided, analytic randoms will be usedrandoms2 (CatalogSource, optional) – the catalog specifying the unclustered, random distribution for
data2
; if not provided, analytic randoms will be usedR1R2 (SimulationBoxPairCount, optional) – if provided, random pairs R1R2 are not recalculated in the LandySzalay estimator
periodic (bool, optional) – whether to use periodic boundary conditions
BoxSize (float, 3vector, optional) – the size of the box; if ‘BoxSize’ is not provided in the source ‘attrs’, it must be provided here
los ('x', 'y', 'z'; int, optional) – the axis of the simulation box to treat as the lineofsight direction; this can be provided as string identifying one of ‘x’, ‘y’, ‘z’ or the equivalent integer number of the axis
weight (str, optional) – the name of the column in the source specifying the particle weights
position (str, optional) – the name of the column in the source specifying the particle positions
show_progress (bool, optional) – if
True
, perform the pair counting calculation in 10 iterations, logging the progress after each iteration; this is useful for understanding the scaling of the code**config (key/value pairs) – additional keywords to pass to the
Corrfunc
function
Notes
This class can compute correlation functions using several different coordinate choices, based on the value of the input argument
mode
. The choices are:mode='1d'
: compute pairs as a function of the 3D separation \(r\)mode='2d'
: compute pairs as a function of the 3D separation \(r\) and the cosine of the angle to the lineofsight, \(\mu\)mode='projected'
: compute pairs as a function of distance perpendicular and parallel to the lineofsight, \(r_p\) and \(\pi\)mode='angular'
: compute pairs as a function of angle on the sky, \(\theta\)
If
mode='projected'
, the projected correlation function \(w_p(r_p)\) is also computed, using the input \(\pi_\mathrm{max}\) value.Methods
load
(output[, comm])Load a result has been saved to disk with
save()
.run
()Run the twopoint correlation function algorithm.
save
(output)Save result as a JSON file with name
output
 run()[source]¶
Run the twopoint correlation function algorithm. This attaches the following attributes:
SimulationBox2PCF.wp
(ifmode='projected'
)
 D1D2¶
the data1  data2 pair counts
 Type
 D1R2¶
the data1  randoms2 pair counts
 Type
 D2R1¶
the data2  randoms1 pair counts
 Type
 R1R2¶
the randoms1  randoms2 pair counts
 Type
 corr¶
the correlation function values, stored as the
corr
variable, computed from the pair counts Type
 wp¶
the projected correlation function, \(w_p(r_p)\), computed if
mode='projected'
; correlation is stored as thecorr
variable Type
Notes
The
D1D2
,D1R2
,D2R1
, andR1R2
attributes are identical to thepairs
attribute ofSimulationBoxPairCount
.
 save(output)¶
Save result as a JSON file with name
output
 class nbodykit.algorithms.paircount_tpcf.tpcf.SurveyData2PCF(mode, data1, randoms1, edges, cosmo=None, Nmu=None, pimax=None, data2=None, randoms2=None, R1R2=None, ra='RA', dec='DEC', redshift='Redshift', weight='Weight', show_progress=False, **config)[source]¶
Compute the twopoint correlation function for observational survey data as a function of \(r\), \((r,\mu)\), \((r_p, \pi)\), or \(\theta\) using pair counting.
The LandySzalay estimator (DD/RR  2 DD/RR + 1) is used to transform pair counts in to the correlation function.
 Parameters
mode ('1d', '2d', 'projected', 'angular') – the type of twopoint correlation function to compute; see the Notes below
data1 (CatalogSource) – the data catalog; must have ra, dec, redshift, columns
randoms1 (CatalogSource) – the catalog specifying the unclustered, random distribution for
data1
edges (array_like) – the separation bin edges along the first coordinate dimension; depending on
mode
, the options are \(r\), \(r_p\), or \(\theta\). Expected units for distances are \(\mathrm{Mpc}/h\) and degrees for angles. Length of nbins+1cosmo (
Cosmology
, optional) – the cosmology instance used to convert redshift into comoving distance; this is required for all cases exceptmode='angular'
Nmu (int, optional) – the number of \(\mu\) bins, ranging from 0 to 1; requred if
mode='2d'
pimax (float, optional) – The maximum separation along the lineofsight when
mode='projected'
. Distances along the \(\pi\) direction are binned with unit depth. For instance, ifpimax=40
, then 40 bins will be created along the \(\pi\) direction.data2 (CatalogSource, optional) – the second data catalog to crosscorrelate;
randoms2 (CatalogSource, optional) – the catalog specifying the unclustered, random distribution for
data2
; if not specified anddata2
is provied, thenrandoms1
will be used for both.R1R2 (SurveyDataPairCount, optional) – if provided, random pairs R1R2 are not recalculated in the LandySzalay estimator
ra (str, optional) – the name of the column in the source specifying the right ascension coordinates in units of degrees; default is ‘RA’
dec (str, optional) – the name of the column in the source specifying the declination coordinates; default is ‘DEC’
redshift (str, optional) – the name of the column in the source specifying the redshift coordinates; default is ‘Redshift’
weight (str, optional) – the name of the column in the source specifying the object weights
show_progress (bool, optional) – if
True
, perform the pair counting calculation in 10 iterations, logging the progress after each iteration; this is useful for understanding the scaling of the code**config (key/value pairs) – additional keywords to pass to the
Corrfunc
function
Notes
This class can compute correlation functions using several different coordinate choices, based on the value of the input argument
mode
. The choices are:mode='1d'
: compute pairs as a function of the 3D separation \(r\)mode='2d'
: compute pairs as a function of the 3D separation \(r\) and the cosine of the angle to the lineofsight, \(\mu\)mode='projected'
: compute pairs as a function of distance perpendicular and parallel to the lineofsight, \(r_p\) and \(\pi\)mode='angular'
: compute pairs as a function of angle on the sky, \(\theta\)
If
mode='projected'
, the projected correlation function \(w_p(r_p)\) is also computed, using the input \(\pi_\mathrm{max}\) value.Methods
load
(output[, comm])Load a result has been saved to disk with
save()
.run
()Run the twopoint correlation function algorithm.
save
(output)Save result as a JSON file with name
output
 run()[source]¶
Run the twopoint correlation function algorithm. This attaches the following attributes:
SurveyData2PCF.wp
(ifmode='projected'
)
 D1D2¶
the data1  data2 pair counts
 Type
 D1R2¶
the data1  randoms2 pair counts
 Type
 D2R1¶
the data2  randoms1 pair counts
 Type
 R1R2¶
the randoms1  randoms2 pair counts
 Type
 corr¶
the correlation function values, stored as the
corr
variable, computed from the pair counts Type
 wp¶
the projected correlation function, \(w_p(r_p)\), computed if
mode='projected'
; correlation is stored as thecorr
variable Type
Notes
The
D1D2
,D1R2
,D2R1
, andR1R2
attributes are identical to thepairs
attribute ofSurveyDataPairCount
.
 save(output)¶
Save result as a JSON file with name
output