API Reference¶
The full list of nbodykit modules is available here. We summarize the most important aspects of the API below.
The nbodykit lab¶
To make things easier for users, we import all of the classes and modules needed to do cool science into a single module:
The nbodykit lab, containing all of the necessary ingredients to use nbodykit. |
Cosmology (nbodykit.cosmology
)¶
The main cosmology object relies on the functionality of the classylss
package, which provides a binding of the CLASS CMB Boltzmann code.
The syntax largely follows that used by CLASS. Below, we list the main cosmology class,
as well as its attributes and methods:
|
A cosmology calculator based on the CLASS binding in |
Attributes
Methods
There are several transfer functions available to the user:
|
The linear matter transfer function using the CLASS Boltzmann code. |
|
The linear matter transfer function using the Eisenstein & Hu (1998) fitting formula with BAO wiggles. |
|
Linear power spectrum using the Eisenstein & Hu (1998) fitting formula without BAO wiggles. |
There are several power spectrum classes
|
An object to compute the linear power spectrum and related quantities, using a transfer function from the CLASS code or the analytic Eisenstein & Hu approximation. |
|
Nonlinear power spectrum computed using HaloFit via CLASS. |
|
The matter power spectrum in the Zel'dovich approximation. |
And a correlation function class and functions for transforming between power spectra and correlation functions
|
Evaluate the correlation function by Fourier transforming a power spectrum object, with automatic re-scaling with redshift and sigma8. |
|
Return a callable function returning the power spectrum multipole of degree \(\ell\), as computed from the Fourier transform of the input \(r\) and \(\xi_\ell(r)\) arrays. |
|
Return a callable function returning the correlation function multipole of degree \(\ell\), as computed from the Fourier transform of the input \(k\) and \(P_\ell(k)\) arrays. |
We also have a class for computing LPT background calculations:
|
The built-in cosmologies are:
Name |
Source |
\(H_0\) |
\(\Omega_{m,0}\) |
Flat |
---|---|---|---|---|
Komatsu et al. 2009 |
70.2 |
0.277 |
Yes |
|
Komatsu et al. 2011 |
70.4 |
0.272 |
Yes |
|
Hinshaw et al. 2013 |
69.3 |
0.287 |
Yes |
|
Planck Collab 2013, Paper XVI |
67.8 |
0.307 |
Yes |
|
Planck Collab 2015, Paper XIII |
67.7 |
0.307 |
Yes |
Transforming Catalog Data (nbodykit.transform
)¶
|
Concatenate CatalogSource objects together, optionally including only certain columns in the returned source. |
|
Stack the input dask arrays vertically, column by column. |
|
Return a dask array of the specified |
|
Convert sky coordinates ( |
|
Convert sky coordinates ( |
|
Return halo concentration from halo mass, based on the analytic fitting formulas presented in Dutton and Maccio 2014. |
|
Return proper halo radius from halo mass, based on the specified mass definition. |
Data Sources¶
Discrete Objects¶
Base class:
|
An abstract base class representing a catalog of discrete particles. |
And subclasses:
|
A CatalogSource that uses |
|
A CatalogSource that uses |
|
A CatalogSource that uses |
|
A CatalogSource that uses |
|
A CatalogSource that uses |
|
A CatalogSource that uses |
|
A CatalogSource that uses |
|
A CatalogSource initialized from an in-memory |
|
A CatalogSource of objects that represent halos, which can be populated using analytic models from |
|
A CatalogSource containing biased particles that have been Poisson-sampled from a log-normal density field. |
|
A CatalogSource that has uniformly-distributed |
|
A CatalogSource that can have columns added via a collective random number generator. |
|
An interface for simultaneous modeling of a |
|
A CatalogSource interface for handling multiples species of particles. |
|
Create a demo catalog of halos using one of the built-in |
Interpolating Objects to a Mesh¶
For simple object catalogs:
|
A mesh generated by resampling a Catalog with the given parameters. |
And Multiple Species
|
A subclass of |
And Survey Catalogs with a window / mask:
|
A subclass of |
Data Directly on a Mesh¶
Base class:
|
Base class for a source in the form of data on an input grid. |
And subclasses:
|
A MeshSource object that reads a mesh from disk using |
|
A MeshSource object that generates a |
|
A MeshSource initialized from an in-memory Field object, either a |
|
A MeshSource initalized from an in-memory numpy array. |
Algorithms (nbodykit.algorithms
)¶
Clustering Statistics¶
|
Algorithm to compute the 1d or 2d power spectrum and/or multipoles in a periodic box, using a Fast Fourier Transform (FFT). |
|
The power spectrum of a field in a periodic box, projected over certain axes. |
|
Algorithm to compute power spectrum multipoles using FFTs for a data survey with non-trivial geometry. |
|
Algorithm to compute the 1d or 2d correlation and/or multipoles in a periodic box, using a Fast Fourier Transform (FFT). |
|
Count (weighted) pairs of objects in a simulation box as a function of \(r\), \((r,\mu)\), \((r_p, \pi)\), or \(\theta\) using the |
|
Count (weighted) pairs of objects from a survey data catalog as a function of \(r\), \((r,\mu)\), \((r_p, \pi)\), or \(\theta\) using the |
|
Compute the two-point 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 two-point correlation function for observational survey data as a function of \(r\), \((r,\mu)\), \((r_p, \pi)\), or \(\theta\) using pair counting. |
|
Compute the multipoles of the isotropic, three-point correlation function in configuration space for data in a simulation box. |
|
Compute the multipoles of the isotropic, three-point correlation function in configuration space for observational survey data. |
Grouping Methods¶
|
A friends-of-friends halo finder that computes the label for each particle, denoting which halo it belongs to. |
|
Compute groups of objects using a cylindrical grouping method. |
|
Run an angular FOF algorithm to determine fiber collision groups from an input catalog, and then assign fibers such that the maximum amount of object receive a fiber. |
Miscellaneous¶
|
Estimate a proxy density based on the distance to the nearest neighbor. |
|
Compute the mean number density as a function of redshift \(n(z)\) from an input CatalogSource of particles. |
Managing Multiple Tasks (TaskManager
)¶
|
An MPI task manager that distributes tasks over a set of MPI processes, using a specified number of independent workers to compute each task. |
|
A generator that iterates through a series of tasks in parallel. |
|
Like the built-in |
Analyzing Results (BinnedStatistic
)¶
|
Lightweight class to hold statistics binned at fixed coordinates. |
|
Initialize a BinnedStatistic from a JSON file. |
|
Write a BinnedStatistic from a JSON file. |
|
Returns a copy of the BinnedStatistic, optionally change the type to cls. |
|
Rename a variable in |
|
Compute the average of each variable over the specified dimension. |
|
Reindex the dimension |
|
Return a new BinnedStatistic indexed by coordinate values along the specified dimension(s). |
|
Squeeze the BinnedStatistic along the specified dimension, which removes that dimension from the BinnedStatistic. |
The IO Library (nbodykit.io
)¶
Base class:
|
An abstract base class representing a file object. |
Subclasses available from the nbodykit.io
module:
|
A file object to handle the reading of columns of data from a |
|
A file object to handle the reading of columns of data from a binary file. |
|
A file object to handle the reading of columns of data from a CSV file. |
|
A file object to handle the reading of FITS data using the |
|
A file object to handle the reading of columns of data from a |
|
A file object that offers a continuous view of a stack of subclasses of |
|
Read snapshot binary files from Martin White's TPM simulations. |
|
Read snapshot binary files from Volkers Gadget 1/2/3 simulations. |
Internal Nuts and Bolts¶
MPI Utilities¶
A class to faciliate getting and setting the current MPI communicator. |
|
Decorator to attach the current MPI communicator to the input keyword arguments of |
|
Get the default current MPI communicator. |
|
Set the current MPI communicator to the input value. |
|
|
Gather the input data array from all ranks to the specified |
|
Scatter the input data array across all ranks, assuming data is initially only on root (and None on other ranks). |
General Utilities¶
|
Turn on logging, with the specified level. |
|
Set global configuration options. |
|
A subclass of |
|
A subclass of |
Generating Mock Data¶
Make a Gaussian realization of a overdensity field, \(\delta(x)\). |
|
Make a Gaussian realization of a overdensity field in real-space \(\delta(x)\). |
|
Poisson sample the linear delta and displacement fields to points. |