nbodykit.source.mesh.species¶
Classes

A subclass of 
 class nbodykit.source.mesh.species.MultipleSpeciesCatalogMesh(source, Nmesh, BoxSize, dtype, selection, position, weight, value, interlaced, compensated, resampler)[source]¶
A subclass of
CatalogMesh
designed to paint the density field from a sum of multiple types of particles.The
compute()
function paints the density field summed over all particle species. Parameters
source (CatalogSource) – the input catalog that we wish to interpolate to a mesh
BoxSize – the size of the box
Nmesh (int, 3vector) – 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 thesource
to use when griddingvalue (str) – column in
source
that specifies the field value for each particle; the mesh stores a weighted average of this columnselection (str) – column in
source
that selects the subset of particles to gridposition (str, optional) – column in
source
specifying the position coordinates; default isPosition
 Attributes
actions
The actions to apply to the interpolated density field, optionally included the compensation correction.
attrs
A dictionary storing relevant metadata about the CatalogSource.
compensated
Boolean flag to indicate whether to correct for the windowing kernel introduced when interpolating the discrete particles to a continuous field.
interlaced
Whether to use interlacing when interpolating the density field.
resampler
String specifying the name of the interpolation kernel when gridding the density field.
 window
Methods
apply
(func[, kind, mode])Return a view of the mesh, with
actions
updated to apply the specified function, either in Fourier space or configuration space, based onmode
compute
([mode, Nmesh])Compute / Fetch the mesh object into memory as a RealField or ComplexField object.
preview
([axes, Nmesh, root])Gather the mesh into as a numpy array, with (reduced) resolution.
save
(output[, dataset, mode])Save the mesh as a
BigFileMesh
on disk, either in real or complex space.to_complex_field
([out])Convert the mesh source to the Fourierspace 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 onmode
.to_real_field
([normalize])Paint the density field holding the sum of all particle species, returning a
RealField
object.view
()Return a "view" of the MeshSource, in the spirit of numpy's ndarray view.
paint
 __finalize__(other)¶
Finalize the creation of a MeshSource object by copying over attributes from a second MeshSource.
 Parameters
other (MeshSource) – the second MeshSource to copy over attributes from
 __getitem__(key)[source]¶
If indexed by a species name, return a CatalogMesh object holding only the data columns for that species with the same parameters as the current object.
If not a species name, this has the same behavior as
CatalogSource.__getitem__()
.
 __len__()¶
Length of a mesh source is zero
 property actions¶
The actions to apply to the interpolated density field, optionally included the compensation correction.
 apply(func, kind='wavenumber', mode='complex')¶
Return a view of the mesh, with
actions
updated to apply the specified function, either in Fourier space or configuration space, based onmode
 Parameters
func (callable or a
MeshFilter
object) – func(x, y) where x is a list ofr
(k
) values that broadcasts into a full array, whenmode
is ‘real’ (‘complex’); the value of x depends onkind
.y
is the value of the mesh field on the corresponding locations.kind (string, optional) –
if a MeshFilter object is given as func, this is ignored. The kind of value in x.
When
mode
is ‘complex’:’wavenumber’ means wavenumber from [ 2 pi / L * N / 2, 2 pi / L * N / 2).
’circular’ means circular frequency from [ pi, pi).
’index’ means [0, Nmesh )
When
mode
is ‘real’:’relative’ means distance from [0.5 Boxsize, 0.5 BoxSize).
’index’ means [0, Nmesh )
mode ('complex' or 'real', optional) – if a MeshFilter object is given as func, this is ignored. whether to apply the function to the mesh in configuration space or Fourier space
 Returns
a view of the mesh object with the
actions
attribute updated to include the new action Return type
 property attrs¶
A dictionary storing relevant metadata about the CatalogSource.
 property 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.
 compute(mode='real', Nmesh=None)¶
Compute / Fetch the mesh object into memory as a RealField or ComplexField object.
 property 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
 preview(axes=None, Nmesh=None, root=0)¶
Gather the mesh into as a numpy array, with (reduced) resolution. The result is broadcast to all ranks, so this uses \(\mathrm{Nmesh}^3\) per rank.
 Parameters
 Returns
out – An numpy array holding the real density field.
 Return type
array_like
 property resampler¶
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.resampler.methods
 save(output, dataset='Field', mode='real')¶
Save the mesh as a
BigFileMesh
on disk, either in real or complex space.
 to_complex_field(out=None)¶
Convert the mesh source to the Fourierspace field, returning a
pmesh.pm.ComplexField
object.Not implemented in the base class, unless object is a view.
 to_field(mode='real', out=None)¶
Return the mesh as a
pmesh
Field object, either in Fourier space or configuration space, based onmode
.This will call
to_real_field()
orto_complex_field()
based onmode
. Parameters
mode ('real' or 'complex') – the return type of the field
 Returns
either a RealField of ComplexField, storing the value of the field on the mesh
 Return type
RealField
,ComplexField
 to_real_field(normalize=True)[source]¶
Paint the density field holding the sum of all particle species, returning a
RealField
object.Metadata computed for each particle is stored in the
attrs
attribute of the returned RealField, with keys that are prefixed by the species name. In particular, the total shot noise for the mesh is defined as:\[P_\mathrm{shot} = \sum_i (W_i/W_\mathrm{tot})^2 P_{\mathrm{shot},i},\]where the sum is over all species in the catalog,
W_i
is the sum of theWeight
column for the \(i^\mathrm{th}\) species, and \(W_\mathrm{tot}\) is the sum of \(W_i\) across all species. Parameters
normalize (bool, optional) – if
True
, normalize the density field as \(1+\delta\), dividing by the total mean number of objects per cell, as given by thenum_per_cell
metadata value inattrs
 Returns
the RealField holding the painted density field, with a
attrs
dictionary attribute holding the metadata Return type
RealField
 view()¶
Return a “view” of the MeshSource, in the spirit of numpy’s ndarray view.
This returns a new MeshSource whose memory is owned by
self
.Note that for CatalogMesh objects, this is overidden by the
CatalogSource.view
function.