nbodykit.source.mesh.field¶
Classes
|
A MeshSource initialized from an in-memory Field object, either a |
-
class
nbodykit.source.mesh.field.
FieldMesh
(field)[source]¶ A MeshSource initialized from an in-memory Field object, either a
pmesh.pm.RealField
orpmesh.pm.ComplexField
.Note
The original field object is never modified by this source.
- Parameters
- Attributes
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)Return a copy of the (possibly re-sampled) input ComplexField
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)Return a copy of the (possibly re-sampled) input RealField
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
¶ A list of actions to apply to the density field when interpolating to the mesh.
This stores tuples of
(mode, func, kind)
; seeapply()
for more details.
-
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.
-
compute
(self, mode='real', Nmesh=None)¶ Compute / Fetch the mesh object into memory as a RealField or ComplexField object.
-
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
-
save
(self, output, dataset='Field', mode='real')¶ Save the mesh as a
BigFileMesh
on disk, either in real or complex space.
-
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
-
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.