nbodykit.source.mesh.field.FieldMesh(field)[source]¶Bases: nbodykit.base.mesh.MeshSource
A MeshSource initialized from an in-memory Field object, either a
pmesh.pm.RealField or pmesh.pm.ComplexField.
Note
The original field object is never modified by this source.
| Parameters: |
|
|---|
Attributes
actions |
A list of actions to apply to the density field when interpolating to the mesh. |
attrs |
A dictionary storing relevant meta-data about the MeshSource. |
Methods
apply(func[, kind, mode]) |
Return a view of the mesh, with actions updated to |
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. |
save(output[, dataset, mode]) |
Save the mesh as a BigFileMesh on disk, either in real or complex space. |
to_complex_field() |
Return a copy of the (possibly re-sampled) input ComplexField |
to_field([mode, out]) |
Return the mesh as a pmesh Field object, either in Fourier space or configuration space, based on mode. |
to_real_field() |
Return a copy of the (possibly re-sampled) input RealField |
view() |
Return a “view” of the MeshSource, in the spirit of numpy’s ndarray view. |
__len__()¶Length of a mesh source is zero
actions¶A list of actions to apply to the density field when interpolating to the mesh.
This stores tuples of (mode, func, kind); see apply()
for more details.
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 on mode
| Parameters: |
|
|---|---|
| Returns: | a view of the mesh object with the |
| Return type: |
attrs¶A dictionary storing relevant meta-data about the MeshSource.
logger = <logging.Logger object>¶paint(mode='real', Nmesh=None)¶Paint the density on the mesh and apply
any transformation functions specified in actions.
The return type of the pmesh Field object is specified by
mode. This calls to_field() to convert the mesh to a Field.
See the documentation on painting for more details on painting catalogs to a mesh.
| Parameters: | |
|---|---|
| Returns: | either a RealField of ComplexField, with the functions in
|
| Return type: |
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 |
save(output, dataset='Field', mode='real')¶Save the mesh as a BigFileMesh
on disk, either in real or complex space.
| Parameters: |
|---|
to_field(mode='real', out=None)¶Return the mesh as a pmesh Field object, either in Fourier
space or configuration space, based on mode.
This will call to_real_field() or to_complex_field()
based on mode.
| 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()¶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.