nbodykit.algorithms.zhist

Functions

scotts_bin_width(data, comm) Return the optimal histogram bin width using Scott’s rule, defined as:

Classes

RedshiftHistogram(source, fsky, cosmo[, …]) Compute the mean number density as a function of redshift \(n(z)\) from an input CatalogSource of particles.
class nbodykit.algorithms.zhist.RedshiftHistogram(source, fsky, cosmo, bins=None, redshift='Redshift', weight=None)[source]

Compute the mean number density as a function of redshift \(n(z)\) from an input CatalogSource of particles.

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

Note

The units of the number density are \((\mathrm{Mpc}/h)^{-3}\)

Parameters:
  • source (CatalogSource) – the source of particles holding the redshift column to histogram
  • fsky (float) – the sky area fraction, which is used in the volume calculation when normalizing \(n(z)\)
  • cosmo (nbodykit.cosmology.core.Cosmology) – the cosmological parameters, which are used to compute the volume from redshift shells when normalizing \(n(z)\)
  • bins (int or sequence of scalars, optional) – If bins is an int, it defines the number of equal-width bins in the given range. If bins is a sequence, it defines the bin edges, including the rightmost edge, allowing for non-uniform bin widths. If not provided, Scott’s rule is used to estimate the optimal bin width from the input data (default)
  • redshift (str, optional) – the name of the column specifying the redshift data
  • weight (str, optional) – the name of the column specifying weights to use when histogramming the data

Methods

interpolate(z) Interpoalte dndz as a function of redshift.
load(output[, comm]) Load a saved RedshiftHistogram result.
run() Run the algorithm, which computes the histogram.
save(output) Save the RedshiftHistogram result to disk.
interpolate(z)[source]

Interpoalte dndz as a function of redshift.

The interpolation acts as a band pass filter, removing small scale fluctuations in the estimator.

Returns:n
Return type:n(z)
classmethod load(output, comm=None)[source]

Load a saved RedshiftHistogram result.

The result has been saved to disk with RedshiftHistogram.save().

run()[source]

Run the algorithm, which computes the histogram. This function does not return anything, but adds the following attributes to the class:

Note

All ranks store the same result attributes.

bin_edges

the edges of the redshift bins

Type:array_like
bin_centers

the center values of each redshift bin

Type:array_like
dV

the volume of each redshift shell in units of \((\mathrm{Mpc}/h)^3\)

Type:array_like
nbar

the values of the redshift histogram, normalized to number density (in units of \((\mathrm{Mpc}/h)^{-3}\))

Type:array_like
save(output)[source]

Save the RedshiftHistogram result to disk.

The format is JSON.

nbodykit.algorithms.zhist.scotts_bin_width(data, comm)[source]

Return the optimal histogram bin width using Scott’s rule, defined as:

\[h = \sigma \sqrt[3]{\frac{24 * \sqrt{\pi}}{n}}\]

Note

This is a collective operation

Parameters:
  • data (array_like) – the array that we are histograming
  • comm – the MPI communicator
Returns:

  • dx (float) – the bin spacing
  • edges (array_like) – the array holding the bin edges