nbodykit.base.catalogmesh

Classes

CatalogMesh(*args, **kwargs) A view of a CatalogSource object which knows how to create a MeshSource object from itself.
class nbodykit.base.catalogmesh.CatalogMesh(*args, **kwargs)[source]

A view of a CatalogSource object which knows how to create a MeshSource object from itself.

The original CatalogSource object is stored as the base attribute.

Parameters:
  • source (CatalogSource) – the input catalog that we are viewing as a mesh
  • BoxSize – the size of the box
  • Nmesh (int, 3-vector) – the number of cells per mesh side
  • dtype (str) – the data type of the values stored on mesh
  • weight (str) – column in source that specifies the weight value for each particle in the source to use when gridding
  • value (str) – column in source that specifies the field value for each particle; the mesh stores a weighted average of this column
  • selection (str) – column in source that selects the subset of particles to grid to the mesh
  • position (str, optional) – column in source specifying the position coordinates; default is Position
  • interlaced (bool, optional) – use the interlacing technique of Sefusatti et al. 2015 to reduce the effects of aliasing on Fourier space quantities computed from the mesh
  • compensated (bool, optional) – whether to correct for the window introduced by the grid interpolation scheme
  • window (str, optional) – the string specifying which window interpolation scheme to use; see pmesh.window.methods

Attributes

Index The attribute giving the global index rank of each particle in the list.
actions The actions to apply to the interpolated density field, optionally included the compensation correction.
attrs A dictionary storing relevant meta-data about the CatalogSource.
columns All columns in the CatalogSource, including those hard-coded into the class’s defintion and override columns provided by the user.
compensated Boolean flag to indicate whether to correct for the windowing kernel introduced when interpolating the discrete particles to a continuous field.
csize The total, collective size of the CatalogSource, i.e., summed across all ranks.
hardcolumns A list of the hard-coded columns in the CatalogSource.
interlaced Whether to use interlacing when interpolating the density field.
size The number of objects in the CatalogSource on the local rank.
use_cache If set to True, use the built-in caching features of dask to cache data in memory.
window String specifying the name of the interpolation kernel when gridding the density field.

Methods

CompensateCIC(w, v) Return the Fourier-space kernel that accounts for the convolution of
CompensateCICAliasing(w, v) Return the Fourier-space kernel that accounts for the convolution of
CompensateTSC(w, v) Return the Fourier-space kernel that accounts for the convolution of the gridded field with the TSC window function in configuration space.
CompensateTSCAliasing(w, v) Return the Fourier-space kernel that accounts for the convolution of
Selection() A boolean column that selects a subset slice of the CatalogSource.
Value() When interpolating a CatalogSource on to a mesh, the value of this array is used as the Value that each particle contributes to a given mesh cell.
Weight() The column giving the weight to use for each particle on the mesh.
apply(func[, kind, mode]) Return a view of the mesh, with actions updated to
compute(*args, **kwargs) Our version of dask.compute() that computes multiple delayed dask collections at once.
copy() Return a shallow copy of self.
get_hardcolumn(col) Construct and return a hard-coded column.
gslice(start, stop[, end, redistribute]) Execute a global slice of a CatalogMesh.
make_column(array) Utility function to convert an array-like object to a dask.array.Array.
paint([mode, Nmesh]) Paint the density on the mesh and apply any transformation functions specified in actions.
preview([axes, Nmesh, root]) Gather the mesh into as a numpy array, with (reduced) resolution.
read(columns) Return the requested columns as dask arrays.
save(output[, dataset, mode]) Save the mesh as a BigFileMesh on disk, either in real or complex space.
sort(keys[, reverse, usecols]) Sort the CatalogMesh object globally across all MPI ranks in ascending order by the input keys.
to_complex_field([out]) Convert the mesh source to the Fourier-space field, returning a pmesh.pm.ComplexField object.
to_field([mode, out]) Return the mesh as a pmesh Field object, either in Fourier space or configuration space, based on mode.
to_mesh([Nmesh, BoxSize, dtype, interlaced, …]) Convert the CatalogSource to a MeshSource, using the specified parameters.
to_real_field([out, normalize]) Paint the density field, by interpolating the position column on to the mesh.
view([type]) Return a “view” of the CatalogSource object, with the returned type set by type.
static CompensateCIC(w, v)[source]

Return the Fourier-space kernel that accounts for the convolution of the gridded field with the CIC window function in configuration space

Note

see equation 18 (with p=2) of Jing et al 2005

Parameters:
  • w (list of arrays) – the list of “circular” coordinate arrays, ranging from \([-\pi, \pi)\).
  • v (array_like) – the field array
static CompensateCICAliasing(w, v)[source]

Return the Fourier-space kernel that accounts for the convolution of the gridded field with the CIC window function in configuration space, as well as the approximate aliasing correction

Note

see equation 20 of Jing et al 2005

Parameters:
  • w (list of arrays) – the list of “circular” coordinate arrays, ranging from \([-\pi, \pi)\).
  • v (array_like) – the field array
static CompensateTSC(w, v)[source]

Return the Fourier-space kernel that accounts for the convolution of the gridded field with the TSC window function in configuration space.

Note

see equation 18 (with p=3) of Jing et al 2005

Parameters:
  • w (list of arrays) – the list of “circular” coordinate arrays, ranging from \([-\pi, \pi)\).
  • v (array_like) – the field array
static CompensateTSCAliasing(w, v)[source]

Return the Fourier-space kernel that accounts for the convolution of the gridded field with the TSC window function in configuration space, as well as the approximate aliasing correction

Note

see equation 20 of Jing et al 2005

Parameters:
  • w (list of arrays) – the list of “circular” coordinate arrays, ranging from \([-\pi, \pi)\).
  • v (array_like) – the field array
__finalize__(other)[source]

Finalize the creation of a CatalogMesh object by copying over attributes from a second CatalogMesh.

This also copies over the relevant MeshSource attributes via a call to MeshSource.__finalize__().

Parameters:obj (CatalogMesh) – the second CatalogMesh to copy over attributes from
__slice__(index)[source]

Return a slice of a CatalogMesh object.

This slices the CatalogSource object stored as the base attribute, and then views that sliced object as a CatalogMesh.

Parameters:index (array_like) – either a dask or numpy boolean array; this determines which rows are included in the returned object
Returns:the particle source with the same meta-data as self, and with the sliced data arrays
Return type:subset
actions

The actions to apply to the interpolated density field, optionally included the compensation correction.

compensated

Boolean flag to indicate whether to correct for the windowing kernel introduced when interpolating the discrete particles to a continuous field.

See the documentation for further details.

copy()[source]

Return a shallow copy of self.

Note

No copy of data is made.

Returns:a new CatalogMesh that holds all of the data columns of self
Return type:CatalogMesh
gslice(start, stop, end=1, redistribute=True)[source]

Execute a global slice of a CatalogMesh.

Note

After the global slice is performed, the data is scattered evenly across all ranks.

As CatalogMesh objects are views of a CatalogSource, this simply globally slices the underlying CatalogSource.

Parameters:
  • start (int) – the start index of the global slice
  • stop (int) – the stop index of the global slice
  • step (int, optional) – the default step size of the global size
  • redistribute (bool, optional) – if True, evenly re-distribute the sliced data across all ranks, otherwise just return any local data part of the global slice
interlaced

Whether to use interlacing when interpolating the density field. See the documentation for further details.

See also: Section 3.1 of Sefusatti et al. 2015

save(output, dataset='Field', mode='real')[source]

Save the mesh as a BigFileMesh on disk, either in real or complex space.

Parameters:
  • output (str) – name of the bigfile file
  • dataset (str, optional) – name of the bigfile data set where the field is stored
  • mode (str, optional) – real or complex; the form of the field to store
sort(keys, reverse=False, usecols=None)[source]

Sort the CatalogMesh object globally across all MPI ranks in ascending order by the input keys.

Sort columns must be floating or integer type.

As CatalogMesh objects are views of a CatalogSource, this simply sorts the underlying CatalogSource.

Parameters:
  • *keys – the names of columns to sort by. If multiple columns are provided, the data is sorted consecutively in the order provided
  • reverse (bool, optional) – if True, perform descending sort operations
  • usecols (list, optional) – the name of the columns to include in the returned CatalogSource
to_real_field(out=None, normalize=True)[source]

Paint the density field, by interpolating the position column on to the mesh.

This computes the following meta-data attributes in the process of painting, returned in the attrs attributes of the returned RealField object:

  • N : int
    the (unweighted) total number of objects painted to the mesh
  • W : float
    the weighted number of total objects, equal to the collective sum of the ‘weight’ column
  • shotnoise : float
    the Poisson shot noise, equal to the volume divided by N
  • num_per_cell : float
    the mean number of weighted objects per cell

Note

The density field on the mesh is normalized as \(1+\delta\), such that the collective mean of the field is unity.

See the documentation on painting for more details on painting catalogs to a mesh.

Returns:real – the painted real field; this has a attrs dict storing meta-data
Return type:pmesh.pm.RealField
window

String specifying the name of the interpolation kernel when gridding the density field.

See the documentation for further details.

Note

Valid values must be in pmesh.window.methods