nbodykit.algorithms.paircount module

class nbodykit.algorithms.paircount.PairCountBase(mode, source1, source2, redges, Nmu)[source]

Bases: object

Base class for pair counting algorithms, either for a simulation box or survey data

Parameters:
  • mode ({'1d', '2d'}) – compute paircounts as a function of r and mu or just r
  • source1 (CatalogSource) – the first source of particles
  • source2 (CatalogSource, optional) – the second source of particles to cross-correlate
  • redges (array_like) – the radius bin edges; length of nbins+1
  • Nmu (int) – the number of mu bins to use; bins range from [0,1]

Methods

load(output[, comm]) Load a result has been saved to disk with save().
save(output) Save result as a JSON file with name output
classmethod load(output, comm=None)[source]

Load a result has been saved to disk with save().

save(output)[source]

Save result as a JSON file with name output

class nbodykit.algorithms.paircount.SimulationBoxPairCount(mode, source1, redges, BoxSize=None, periodic=True, source2=None, Nmu=5, los='z', weight='Weight', **config)[source]

Bases: nbodykit.algorithms.paircount.PairCountBase

Count (weighted) pairs of objects in a simulation box using the Corrfunc package.

This uses the Corrfunc.theory.DD.DD() and Corrfunc.theory.DDsmu.DDsmu() functions to count pairs.

Results are computed when the object is inititalized. See the documenation of run() for the attributes storing the results.

Note

The algorithm expects the positions of particles in a simulation box to be the Cartesian x, y, and z vectors. To compute pair counts on survey data, using right ascension, declination, and redshift, see SurveyDataPairCount.

Parameters:
  • mode ({'1d', '2d'}) – compute pair counts as a function of r and mu or just r
  • source1 (CatalogSource) – the first source of particles, providing the ‘Position’ column
  • redges (array_like) – the radius bin edges; length of nbins+1
  • BoxSize (float, 3-vector, optional) – the size of the box; if ‘BoxSize’ is not provided in the source ‘attrs’, it must be provided here
  • source2 (CatalogSource, optional) – the second source of particles to cross-correlate
  • Nmu (int, optional) – the number of mu bins, ranging from 0 to 1
  • los ({'x', 'y', 'z'}, int, optional) – the axis of the simulation box to treat as the line-of-sight direction; this can be provided as string identifying one of ‘x’, ‘y’, ‘z’ or the equivalent integer number of the axis
  • periodic (bool, optional) – whether to use periodic boundary conditions
  • weight (str, optional) – the name of the column in the source specifying the particle weights
  • **config (key/value pairs) – additional keywords to pass to the Corrfunc function

Methods

load(output[, comm]) Load a result has been saved to disk with save().
run() Calculate the 3D pair-counts in a simulation box as a function of separation r or separation and angle to line-of-sight (r, mu).
save(output) Save result as a JSON file with name output
load(output, comm=None)

Load a result has been saved to disk with save().

logger = <logging.Logger object>
run()[source]

Calculate the 3D pair-counts in a simulation box as a function of separation r or separation and angle to line-of-sight (r, mu). This adds the following attributes to the class:

result

BinnedStatistic – a BinnedStatistic object holding the pair count and correlation function results. The coordinate grid is either r or r and mu. It stores the following variables:

  • r: the mean separation value in the bin
  • xi: the mean correlation function value in the bin, computed as \(DD/RR - 1\), where \(RR\) is the number of random pairs in the bin
  • npairs: the number of pairs in the bin
  • weightavg: the average weight value in the bin; each pair contributes the product of the individual weight values
save(output)

Save result as a JSON file with name output

class nbodykit.algorithms.paircount.SurveyDataPairCount(mode, source1, redges, cosmo, source2=None, Nmu=5, ra='RA', dec='DEC', redshift='Redshift', weight='Weight', **config)[source]

Bases: nbodykit.algorithms.paircount.PairCountBase

Count (weighted) pairs of objects from a survey data catalog using the Corrfunc package.

This uses the:func:Corrfunc.mocks.DDsmu_mocks.DDsmu_mocks function to count pairs.

Results are computed when the object is inititalized. See the documenation of run() for the attributes storing the results.

Note

The algorithm expects the positions of particles from a survey catalog be the sky coordinates, right ascension and declination, and redshift. To compute pair counts in a simulation box, using the Cartesian coordinate vectors, see SimulationBoxPairCount.

Warning

The right ascension and declination columns should be specified in degrees.

Parameters:
  • mode ({'1d', '2d'}) – compute paircounts as a function of r and mu or just r
  • source1 (CatalogSource) – the first source of particles, providing the ‘Position’ column
  • redges (array_like) – the radius bin edges; length of nbins+1
  • cosmo (Cosmology) – the cosmology instance used to convert redshift into comoving distance
  • source2 (CatalogSource, optional) – the second source of particles to cross-correlate
  • Nmu (int, optional) – the number of mu bins, ranging from 0 to 1
  • 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
  • **config (key/value pairs) – additional keywords to pass to the Corrfunc function

Methods

load(output[, comm]) Load a result has been saved to disk with save().
run() Calculate the 3D pair-counts of a survey data catalog as a function of separation r or separation and angle to line-of-sight (r, mu).
save(output) Save result as a JSON file with name output
load(output, comm=None)

Load a result has been saved to disk with save().

logger = <logging.Logger object>
run()[source]

Calculate the 3D pair-counts of a survey data catalog as a function of separation r or separation and angle to line-of-sight (r, mu). This adds the following attribute:

result

BinnedStatistic – a BinnedStatistic object holding the pair count and correlation function results. The coordinate grid is either r or r and mu. It stores the following variables:

  • r: the mean separation value in the bin
  • npairs: the number of pairs in the bin
  • weightavg: the average weight value in the bin; each pair contributes the product of the individual weight values
save(output)

Save result as a JSON file with name output

nbodykit.algorithms.paircount.get_comoving_dist(comm, pos, cosmo)[source]

Return comoving distances from RA, DEC, Redshift

pos has 3 columns giving: ra, dec, redshift

nbodykit.algorithms.paircount.verify_input_sources(first, second, BoxSize, required_columns, inspect_boxsize=True)[source]

Verify the input source objects have