nbodykit.algorithms.sim_paircount

Functions

verify_input_sources(first, second, BoxSize, …) Verify that the input source objects have all of the required columns and appropriate box size attributes.

Classes

CorrfuncResult(data) A class used internally holding the array like result of a pair counting algorithm from Corrfunc.
PairCountBase(first, second[, show_progress]) An abstract base class for pair counting algorithms, either for a simulation box or survey data.
SimulationBoxPairCount(mode, first, redges) Count (weighted) pairs of objects in a simulation box using the Corrfunc package.

Exceptions

MissingCorrfuncError()
class nbodykit.algorithms.sim_paircount.CorrfuncResult(data)[source]

A class used internally holding the array like result of a pair counting algorithm from Corrfunc.

This class is useful for summing pair count results, accounting for columns that are pair-weighted.

Parameters:data (numpy.ndarray) – the numpy structured array result from Corrfunc

Attributes

dtype
shape

Methods

reshape(*args, **kwargs)
class nbodykit.algorithms.sim_paircount.PairCountBase(first, second, show_progress=True)[source]

An abstract base class for pair counting algorithms, either for a simulation box or survey data.

Users should use one of the subclasses of this class.

Parameters:
  • first (CatalogSource) – the first source of particles
  • second (CatalogSource, optional) – the second source of particles to cross-correlate

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.sim_paircount.SimulationBoxPairCount(mode, first, redges, BoxSize=None, periodic=True, second=None, Nmu=5, los='z', weight='Weight', show_progress=True, **config)[source]

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
  • first (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
  • second (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
  • 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

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
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
nbodykit.algorithms.sim_paircount.verify_input_sources(first, second, BoxSize, required_columns, inspect_boxsize=True)[source]

Verify that the input source objects have all of the required columns and appropriate box size attributes.