nbodykit.algorithms.convpower.catalogmesh¶
Classes
|
A subclass of |
-
class
nbodykit.algorithms.convpower.catalogmesh.
FKPCatalogMesh
(source, BoxSize, BoxCenter, Nmesh, dtype, selection, comp_weight, fkp_weight, nbar, value='Value', position='Position', interlaced=False, compensated=False, resampler='cic')[source]¶ A subclass of
MultipleSpeciesCatalogMesh
designed to paint aFKPCatalog
to a mesh.The multiple species here are
data
andrandoms
CatalogSource objects, whererandoms
is a catalog of randomly distributed objects with no instrinsic clustering that defines the survey volume.The position of the catalogs are re-centered to the
[-L/2, L/2]
whereL
is the size of the Cartesian box.- Parameters
source (CatalogSource) – the input catalog that we wish to interpolate to 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
selection (str) – column in
source
that selects the subset of particles to grid to the meshcomp_weight (str) – the completeness weight column name
fkp_weight (str) – the FKP weight column name
nbar (str) – the n(z) column name
position (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 meta-data 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
RecenteredPosition
(self, name)The Position of the objects, re-centered on the mesh to the range
[-BoxSize/2, BoxSize/2]
.TotalWeight
(self, name)The total weight for the mesh is the completenes weight times the FKP weight.
apply
(self, 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
(self[, mode, Nmesh])Compute / Fetch the mesh object into memory as a RealField or ComplexField object.
preview
(self[, axes, Nmesh, root])Gather the mesh into as a numpy array, with (reduced) resolution.
recenter_box
(self, BoxSize, BoxCenter)Re-center the box by applying the new box center to the column specified by
position
.save
(self, output[, dataset, mode])Save the mesh as a
BigFileMesh
on disk, either in real or complex space.to_complex_field
(self[, out])Convert the mesh source to the Fourier-space field, returning a
pmesh.pm.ComplexField
object.to_field
(self[, mode, out])Return the mesh as a
pmesh
Field object, either in Fourier space or configuration space, based onmode
.to_real_field
(self)Paint the FKP density field, returning a
RealField
.view
(self)Return a “view” of the MeshSource, in the spirit of numpy’s ndarray view.
weighted_total
(self, name)Compute the weighted total number of objects, using either the
data
orrandoms
source:paint
-
RecenteredPosition
(self, name)[source]¶ The Position of the objects, re-centered on the mesh to the range
[-BoxSize/2, BoxSize/2]
.This subtracts
BoxCenter
fromattrs
from the original position array.
-
TotalWeight
(self, name)[source]¶ The total weight for the mesh is the completenes weight times the FKP weight.
-
__finalize__
(self, 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__
(self, 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__
(self)¶ Length of a mesh source is zero
-
actions
¶ The actions to apply to the interpolated density field, optionally included the compensation correction.
-
apply
(self, 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
-
attrs
¶ A dictionary storing relevant meta-data 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.
See the documentation for further details.
-
compute
(self, mode='real', Nmesh=None)¶ Compute / Fetch the mesh object into memory as a RealField or ComplexField object.
-
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
(self, 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
-
recenter_box
(self, BoxSize, BoxCenter)[source]¶ Re-center the box by applying the new box center to the column specified by
position
.This ensures that the position column is always re-centered to
[-L/2,L/2]
whereL
is the BoxSize.
-
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
(self, output, dataset='Field', mode='real')¶ Save the mesh as a
BigFileMesh
on disk, either in real or complex space.
-
to_complex_field
(self, out=None)¶ Convert the mesh source to the Fourier-space field, returning a
pmesh.pm.ComplexField
object.Not implemented in the base class, unless object is a view.
-
to_field
(self, 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
(self)[source]¶ Paint the FKP density field, returning a
RealField
.Given the
data
andrandoms
catalogs, this paints:\[F(x) = w_\mathrm{fkp}(x) * [w_\mathrm{comp}(x)*n_\mathrm{data}(x) - \alpha * w_\mathrm{comp}(x)*n_\mathrm{randoms}(x)]\]This computes the following meta-data attributes in the process of painting, returned in the
attrs
attributes of the returned RealField object:- randoms.W, data.W :
the weighted sum of randoms and data objects; see
weighted_total()
- alphafloat
the ratio of
data.W
torandoms.W
- randoms.norm, data.normfloat
the power spectrum normalization; see
normalization()
- randoms.shotnoise, data.shotnoise: float
the shot noise for each sample; see
shotnoise()
- shotnoisefloat
the total shot noise, equal to the sum of
randoms.shotnoise
anddata.shotnoise
- randoms.num_per_cell, data.num_per_cellfloat
the mean number of weighted objects per cell for each sample
- num_per_cellfloat
the mean number of weighted objects per cell
For further details on the meta-data, see the documentation.
- Returns
the field object holding the FKP density field in real space
- Return type
-
view
(self)¶ 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.