nbodykit.algorithms.
FFTPower
(first, mode, Nmesh=None, BoxSize=None, second=None, los=[0, 0, 1], Nmu=5, dk=None, kmin=0.0, poles=[])[source]¶Algorithm to compute the 1d or 2d power spectrum and/or multipoles in a periodic box, using a Fast Fourier Transform (FFT).
This computes the power spectrum as the square of the Fourier modes of the density field, which are computed via a FFT.
Results are computed when the object is inititalized. See the documenation
of run()
for the attributes storing the results.
Note
A full tutorial on the class is available in the documentation here.
Parameters: |
|
---|
Methods
load (output[, comm]) |
Load a saved FFTPower result. |
run () |
Compute the power spectrum in a periodic box, using FFTs. |
save (output) |
Save the FFTPower result to disk. |
run
()[source]¶Compute the power spectrum in a periodic box, using FFTs. This function returns nothing, but attaches several attributes to the class:
edges
¶array_like – the edges of the wavenumber bins
power
¶BinnedStatistic
– a BinnedStatistic object that holds the measured \(P(k)\) or
\(P(k,\mu)\). It stores the following variables:
the mean value for each k
bin
mode=2d
onlythe mean value for each mu
bin
complex array storing the real and imaginary components of the power
the number of Fourier modes averaged together in each bin
poles
¶BinnedStatistic
or None
– a BinnedStatistic object to hold the multipole results
\(P_\ell(k)\); if no multipoles were requested by the user,
this is None
. It stores the following variables:
k
binattrs
¶dict – dictionary of meta-data; in addition to storing the input parameters, it includes the following fields computed during the algorithm execution:
nbodykit.algorithms.
ProjectedFFTPower
(first, Nmesh=None, BoxSize=None, second=None, axes=(0, 1), dk=None, kmin=0.0)[source]¶The power spectrum of a field in a periodic box, projected over certain axes.
This is not really always physically meaningful, but convenient for making sense of Lyman-Alpha forest or lensing maps.
This is usually called the 1d power spectrum or 2d power spectrum.
Results are computed when the object is inititalized. See the documenation
of run()
for the attributes storing the results.
Parameters: |
|
---|
Methods
load (output[, comm]) |
Load a saved FFTPower result. |
run () |
Run the algorithm. |
save (output) |
Save the FFTPower result to disk. |
run
()[source]¶Run the algorithm. This attaches the following attributes to the class:
edges
¶array_like – the edges of the wavenumber bins
power
¶BinnedStatistic
– a BinnedStatistic object that holds the projected power.
It stores the following variables:
k
binnbodykit.algorithms.
FFTCorr
(first, mode, Nmesh=None, BoxSize=None, second=None, los=[0, 0, 1], Nmu=5, dr=None, rmin=0.0, poles=[])[source]¶Algorithm to compute the 1d or 2d correlation and/or multipoles in a periodic box, using a Fast Fourier Transform (FFT).
This computes the power spectrum as the square of the Fourier modes of the density field, which are computed via a FFT. Then it is transformed back to obtain the correlation function.
Results are computed when the object is inititalized. See the documenation
of run()
for the attributes storing the results.
Note
This is very similar to FFTPower
.
Parameters: |
|
---|
Methods
load (output[, comm]) |
Load a saved FFTPower result. |
run () |
Compute the correlation function in a periodic box, using FFTs. |
save (output) |
Save the FFTPower result to disk. |
run
()[source]¶Compute the correlation function in a periodic box, using FFTs. This function returns nothing, but attaches several attributes to the class:
edges
¶array_like – the edges of the wavenumber bins
corr
¶BinnedStatistic
– a BinnedStatistic object that holds the measured \(\xi(r)\) or
\(\xi(r,\mu)\). It stores the following variables:
the mean value for each r
bin
mode=2d
onlythe mean value for each mu
bin
real array storing the correlation function
the number of modes averaged together in each bin
poles
¶BinnedStatistic
or None
– a BinnedStatistic object to hold the multipole results
\(\xi_\ell(r)\); if no multipoles were requested by the user,
this is None
. It stores the following variables:
r
binattrs
¶dict – dictionary of meta-data; in addition to storing the input parameters, it includes the following fields computed during the algorithm execution:
nbodykit.algorithms.
KDDensity
(source, margin=1.0)[source]¶Estimate a proxy density based on the distance to the nearest neighbor. The result is proportional to the density but the scale is unspecified.
Results are computed when the object is inititalized. See the documenation
of run()
for the attributes storing the results.
Parameters: |
|
---|
Methods
run () |
Compute the density proxy. |
nbodykit.algorithms.
FOF
(source, linking_length, nmin, absolute=False, periodic=True)[source]¶A friends-of-friends halo finder that computes the label for each particle, denoting which halo it belongs to.
Friends-of-friends was first used by Davis et al 1985 to define halos in hierachical structure formation of cosmological simulations. The algorithm is also known as DBSCAN in computer science. The subroutine here implements a parallel version of the FOF.
The underlying local FOF algorithm is from kdcount.cluster
,
which is an adaptation of the implementation in Volker Springel’s
Gadget and Martin White’s PM.
Results are computed when the object is inititalized. See the documenation
of run()
for the attributes storing the results.
For returning a CatalogSource of the FOF halos, see find_features()
and for computing a halo catalog with added analytic information for
a specific redshift and cosmology, see to_halos()
.
Parameters: |
|
---|
Methods
find_features ([peakcolumn]) |
Based on the particle labels, identify the groups, and return the center-of-mass CMPosition , CMVelocity , and Length of each feature. |
run () |
Run the FOF algorithm. |
to_halos (particle_mass, cosmo, redshift[, …]) |
Return a HaloCatalog , holding the center-of-mass position and velocity of each FOF halo, as well as the properly scaled mass, for a given cosmology and redshift. |
find_features
(peakcolumn=None)[source]¶Based on the particle labels, identify the groups, and return
the center-of-mass CMPosition
, CMVelocity
, and Length of each
feature.
If a peakcolumn
is given, the PeakPosition
and PeakVelocity
is also calculated for the particle at the peak value of the column.
Data is scattered evenly across all ranks.
Returns: | a source holding the (‘CMPosition’, ‘CMVelocity’, ‘Length’)
of each feature; optionaly, PeakPosition , PeakVelocity are
also included if peakcolumn is not None |
---|---|
Return type: | ArrayCatalog |
run
()[source]¶Run the FOF algorithm. This function returns nothing, but does attach several attributes to the class instance:
max_labels
Note
The labels
array is scattered evenly across all ranks.
labels
¶array_like, length: size
– an array the label that specifies which FOF halo each particle
belongs to
max_label
¶int – the maximum label across all ranks; this represents the total number of FOF halos found
to_halos
(particle_mass, cosmo, redshift, mdef='vir', posdef='cm', peakcolumn='Density')[source]¶Return a HaloCatalog
, holding
the center-of-mass position and velocity of each FOF halo, as well as
the properly scaled mass, for a given cosmology and redshift.
The returned catalog also has default analytic prescriptions for halo radius and concentration.
The data is scattered evenly across all ranks.
Parameters: |
|
---|---|
Returns: | a HaloCatalog at the specified cosmology and redshift |
Return type: |
nbodykit.algorithms.
ConvolvedFFTPower
(first, poles, second=None, Nmesh=None, kmin=0.0, dk=None, use_fkp_weights=False, P0_FKP=None)[source]¶Algorithm to compute power spectrum multipoles using FFTs for a data survey with non-trivial geometry.
Due to the geometry, the estimator computes the true power spectrum convolved with the window function (FFT of the geometry).
This estimator implemented in this class is described in detail in Hand et al. 2017 (arxiv:1704.02357). It uses the spherical harmonic addition theorem such that only \(2\ell+1\) FFTs are required to compute each multipole. This differs from the implementation in Bianchi et al. and Scoccimarro et al., which requires \((\ell+1)(\ell+2)/2\) FFTs.
Results are computed when the object is inititalized, and the result is
stored in the poles
attribute. Important meta-data computed
during algorithm execution is stored in the attrs
dict. See the
documenation of run()
.
Note
A full tutorial on the class is available in the documentation here.
Note
Cross correlations are only supported when the FKP weight column
differs between the two mesh objects, i.e., the underlying data
and randoms
must be the same. This allows users to compute
the cross power spectrum of the same density field, weighted
differently.
Parameters: |
|
---|
References
Methods
load (output[, comm]) |
Load a saved ConvolvedFFTPower result, which has been saved to disk with ConvolvedFFTPower.save() . |
normalization (name, alpha) |
Compute the power spectrum normalization, using either the data or randoms source. |
run () |
Compute the power spectrum multipoles. |
save (output) |
Save the ConvolvedFFTPower result to disk. |
shotnoise (alpha) |
Compute the power spectrum shot noise, using either the data or randoms source. |
to_pkmu (mu_edges, max_ell) |
Invert the measured multipoles \(P_\ell(k)\) into power spectrum wedges, \(P(k,\mu)\). |
load
(output, comm=None)[source]¶Load a saved ConvolvedFFTPower result, which has been saved to
disk with ConvolvedFFTPower.save()
.
The current MPI communicator is automatically used
if the comm
keyword is None
normalization
(name, alpha)[source]¶Compute the power spectrum normalization, using either the
data
or randoms
source.
The normalization is given by:
The mean densities are assumed to be the same, so this can be converted to a summation over objects in the source, as
References
see Eqs. 13,14 of Beutler et al. 2014, “The clustering of galaxies in the SDSS-III Baryon Oscillation Spectroscopic Survey: testing gravity with redshift space distortions using the power spectrum multipoles”
run
()[source]¶Compute the power spectrum multipoles. This function does not return anything, but adds several attributes (see below).
edges
¶array_like – the edges of the wavenumber bins
poles
¶BinnedStatistic
– a BinnedStatistic object that behaves similar to a structured array, with
fancy slicing and re-indexing; it holds the measured multipole
results, as well as the number of modes (modes
) and average
wavenumbers values in each bin (k
)
attrs
¶dict – dictionary holding input parameters and several important quantites computed during execution:
data.W
to randoms.W
data.shotnoise
+ randoms.shotnoise
; this should be subtracted from
the monopole.For further details on the meta-data, see the documentation.
save
(output)[source]¶Save the ConvolvedFFTPower result to disk.
The format is currently json.
Parameters: | output (str) – the name of the file to dump the JSON results to |
---|
shotnoise
(alpha)[source]¶Compute the power spectrum shot noise, using either the
data
or randoms
source.
This computes:
References
see Eq. 15 of Beutler et al. 2014, “The clustering of galaxies in the SDSS-III Baryon Oscillation Spectroscopic Survey: testing gravity with redshift space distortions using the power spectrum multipoles”
to_pkmu
(mu_edges, max_ell)[source]¶Invert the measured multipoles \(P_\ell(k)\) into power spectrum wedges, \(P(k,\mu)\).
Parameters: |
|
---|---|
Returns: | pkmu – a data set holding the \(P(k,\mu)\) wedges |
Return type: |
nbodykit.algorithms.
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: |
|
---|
Methods
load (output[, comm]) |
Load a saved RedshiftHistogram result. |
run () |
Run the algorithm, which computes the histogram. |
save (output) |
Save the RedshiftHistogram result to disk. |
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
¶array_like – the edges of the redshift bins
bin_centers
¶array_like – the center values of each redshift bin
dV
¶array_like – the volume of each redshift shell in units of \((\mathrm{Mpc}/h)^3\)
nbar
¶array_like – the values of the redshift histogram, normalized to number density (in units of \((\mathrm{Mpc}/h)^{-3}\))
nbodykit.algorithms.
FiberCollisions
(ra, dec, collision_radius=0.017222222222222226, seed=None, degrees=True, comm=None)[source]¶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.
This amounts to determining the following population of objects:
Results are computed when the object is inititalized. See the documenation
of run()
for the attributes storing the results.
Parameters: |
|
---|
References
Methods
run () |
Run the fiber assignment algorithm. |
run
()[source]¶Run the fiber assignment algorithm. This attaches the following attribute to the object:
Note
The labels
attribute has a 1-to-1 correspondence with
the rows in the input source.
labels
¶ArrayCatalog
; size: size
– a CatalogSource that has the following columns:
source
, else it is set to -1nbodykit.algorithms.
Multipoles3PCF
(source, poles, edges, BoxSize=None, periodic=True, weight='Weight', selection='Selection')[source]¶Compute the multipoles of the isotropic, three-point correlation function in configuration space.
This uses the algorithm of Slepian and Eisenstein, 2015 which scales as \(\mathcal{O}(N^2)\), where \(N\) is the number of objects.
Results are computed when the object is inititalized. See the documenation
of run()
for the attributes storing the results.
Parameters: |
|
---|
References
Slepian and Eisenstein, MNRAS 454, 4142-4158 (2015)
Methods
load (filename[, comm]) |
Load a Multipoles3PCF result from filename that has been saved to disk with save() . |
run () |
Compute the three-point CF multipoles. |
save (output) |
Save the poles result to a JSON file with name output |
load
(filename, comm=None)[source]¶Load a Multipoles3PCF result from filename
that has been saved to
disk with save()
.
run
()[source]¶Compute the three-point CF multipoles. This attaches the following the attributes to the class:
poles
¶BinnedStatistic
– a BinnedStatistic object to hold the multipole results; the
binned statistics stores the multipoles as variables zeta_0
,
zeta_1
, etc for \(\ell=0,1,\) etc. The coordinates
of the binned statistic are r1
and r2
, which give the
separations between the three objects in CF
nbodykit.algorithms.
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: |
|
---|
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 binxi
: the mean correlation function value in the bin, computed as
\(DD/RR - 1\), where \(RR\) is the number of random pairs
in the binnpairs
: the number of pairs in the binweightavg
: the average weight value in the bin; each pair
contributes the product of the individual weight valuesnbodykit.algorithms.
SurveyDataPairCount
(mode, first, redges, cosmo, second=None, Nmu=5, ra='RA', dec='DEC', redshift='Redshift', weight='Weight', show_progress=True, **config)[source]¶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: |
|
---|
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 |
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 results. The
coordinate grid is either r
or r
and mu
.
It stores the following variables:
r
: the mean separation value in the binnpairs
: the number of pairs in the binweightavg
: the average weight value in the bin; each pair
contributes the product of the individual weight valuesnbodykit.algorithms.
AngularPairCount
(first, edges, second=None, ra='RA', dec='DEC', weight='Weight', show_progress=True, **config)[source]¶Count (weighted) angular pairs of objects from a survey data catalog using the
Corrfunc
package.
This uses the:func:Corrfunc.mocks.DDtheta_mocks.DDtheta_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 the survey catalog be the right ascension and declination angular coordinates.
Warning
The right ascension and declination columns should be specified in degrees.
Parameters: |
|
---|
Methods
load (output[, comm]) |
Load a result has been saved to disk with save() . |
run () |
Calculate the angular pair counts of a survey data catalog as a function of separation angle on the sky. |
save (output) |
Save result as a JSON file with name output |
run
()[source]¶Calculate the angular pair counts of a survey data catalog as a function of separation angle on the sky. This adds the following attribute:
result
¶BinnedStatistic
– a BinnedStatistic object holding the pair count results.
The coordinate grid is theta
, the angular separation bins.
It stores the following variables:
theta
: the mean separation value in the binnpairs
: the number of pairs in the binweightavg
: the average weight value in the bin; each pair
contributes the product of the individual weight valuesnbodykit.algorithms.
CylindricalGroups
(source, rankby, rperp, rpar, flat_sky_los=None, periodic=False, BoxSize=None)[source]¶Compute groups of objects using a cylindrical grouping method. We identify all satellites within a given cylindrical volume around a central object.
Results are computed when the object is inititalized, and the result is
stored in the groups
attribute; see the documenation of
run()
.
Input parameters are stored in the attrs
attribute dictionary.
Parameters: |
|
---|
References
Okumura, Teppei, et al. “Reconstruction of halo power spectrum from redshift-space galaxy distribution: cylinder-grouping method and halo exclusion effect”, arXiv:1611.04165, 2016.
Methods
run () |
Compute the cylindrical groups, saving the results to the |
run
()[source]¶Compute the cylindrical groups, saving the results to the
groups
attribute
groups
¶ArrayCatalog
– a catalog holding the result of the grouping. The length of the
catalog is equal to the length of the input size, i.e., the length
is equal to the size
attribute. The relevant fields are: