nbodykit.source.mesh.catalog¶
Functions
|
Return the Fourier-space kernel that accounts for the convolution of the gridded field with the CIC window function in configuration space |
|
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 to the first order |
|
Return the Fourier-space kernel that accounts for the convolution of the gridded field with the PCS window function in configuration space. |
|
Return the Fourier-space kernel that accounts for the convolution of the gridded field with the PCS window function in configuration space, as well as the approximate aliasing correction to first order |
|
Return the Fourier-space kernel that accounts for the convolution of the gridded field with the TSC window function in configuration space. |
|
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 to the first order |
|
Return the compensation function, which corrects for the windowing kernel. |
Classes
|
A mesh generated by resampling a Catalog with the given parameters. |
-
class
nbodykit.source.mesh.catalog.
CatalogMesh
(source, Nmesh, BoxSize, Position, dtype='f4', resampler='cic', compensated=False, interlaced=False, Value=None, Selection=None, Weight=None, **kwargs)[source]¶ A mesh generated by resampling a Catalog with the given parameters.
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 (array_like, Column, None) – column that specifies the weight value for each particle in the
source
to use when griddingValue (array_like, Column, None) – column that specifies the field value for each particle; the mesh stores a weighted average of this column
Selection (array_like, Column, None) – column that selects the subset of particles to grid to the mesh
Position (array_like, Column, None) – column in
source
specifying the position coordinates; default isPosition
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
‘Weight’, ‘Value’, ‘Selection’, ‘Position’ are items of the collection that can be reassigned after the creation of the object.
- 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
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.
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[, out, normalize])Paint the density field, by interpolating the position column on to the mesh.
view
(self)Return a “view” of the MeshSource, in the spirit of numpy’s ndarray view.
paint
-
__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
-
__len__
(self)¶ Length of a mesh source is zero
-
property
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
-
property
attrs
¶ A dictionary storing relevant meta-data 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
(self, 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
(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
-
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
(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, 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:- Nint
the (unweighted) total number of objects painted to the mesh
- Wfloat
the weighted number of total objects, equal to the collective sum of the ‘weight’ column
- shotnoisefloat
the Poisson shot noise, equal to the volume divided by
N
- num_per_cellfloat
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
-
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.
-
nbodykit.source.mesh.catalog.
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
-
nbodykit.source.mesh.catalog.
CompensateCICShotnoise
(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 to the first order
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
-
nbodykit.source.mesh.catalog.
CompensatePCS
(w, v)[source]¶ Return the Fourier-space kernel that accounts for the convolution of the gridded field with the PCS window function in configuration space.
Note
see equation 18 (with p=4) 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
-
nbodykit.source.mesh.catalog.
CompensatePCSShotnoise
(w, v)[source]¶ Return the Fourier-space kernel that accounts for the convolution of the gridded field with the PCS window function in configuration space, as well as the approximate aliasing correction to first order
Note
YF: I derived this by fitting the result to s ** 3 according to the form given in equation 20 of Jing et al. It must be possible to derive this manually.
- Parameters
w (list of arrays) – the list of “circular” coordinate arrays, ranging from \([-\pi, \pi)\).
v (array_like) – the field array
-
nbodykit.source.mesh.catalog.
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
-
nbodykit.source.mesh.catalog.
CompensateTSCShotnoise
(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 to the first order
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
-
nbodykit.source.mesh.catalog.
get_compensation
(interlaced, resampler)[source]¶ Return the compensation function, which corrects for the windowing kernel.
The compensation function is computed as:
if
interlaced = True
: -CompensateCIC()
if using CIC window -CompensateTSC()
if using TSC window -CompensatePCS()
if using PCS windowif
interlaced = False
: -CompensateCICShotnoise()
if using CIC window -CompensateTSCShotnoise()
if using TSC window -CompensatePCSShotnoise()
if using PCS window