nbodykit.meshtools

Functions

SlabIterator(coords[, axis, symmetry_axis])

Iterate over the specified dimension of the coordinate mesh, returning a MeshSlab for each iteration

Classes

MeshSlab(islab, coords, axis, symmetry_axis)

A convenience class to represent a specific slab of a mesh, which is denoted as a slab

class nbodykit.meshtools.MeshSlab(islab, coords, axis, symmetry_axis)[source]

A convenience class to represent a specific slab of a mesh, which is denoted as a slab

Attributes
hermitian_symmetric

Whether the slab is Hermitian-symmetric

hermitian_weights

Weights to be applied to quantities on the slab in order

index

Return an indexing list appropriate for selecting the slicing the

meshshape

Return the local shape of the mesh on this rank, as determined

nonsingular

The indices on the slab of the positive frequencies along the dimension specified by symmetry_axis.

shape

Return the shape of the slab

Methods

coords(i)

Return the coordinate array for dimension i on this slab,

mu(los)

The mu value defined at each point on the slab for the specified line-of-sight index

norm2()

The square of coordinate grid norm defined at each point on the slab.

__init__(islab, coords, axis, symmetry_axis)[source]
Parameters
  • islab (int, [0, x[0].shape[0]]) – the index of the slab, which indexes the first dimension of the mesh (the x coordinate), thus producing a y-z plane

  • coords (list of arrays) – the coordinate arrays of the mesh, with proper 3D shapes for easy broadcasting; if the mesh has size (Nx, Ny, Nz), then the shapes of x are: [(Nx, 1, 1), (1, Ny, 1), (1, 1, Nz)]

  • axis (int, {0, 1, 2}) – the index of the mesh axis to iterate over

  • symmetry_axis (int, optional) – if provided, the axis that has been compressed due to Hermitian symmetry

coords(i)[source]

Return the coordinate array for dimension i on this slab,

Note

The return value will be properly squeezed for easy broadcasting, i.e., if i is self.axis, then an array of shape (1,1) array is returned, otherwise, the shape is (N_i, 1) or (1, N_i)

Parameters

i (int, {0,1,2}) – the index of the desired dimension

Returns

the coordinate array for dimension i on the slab; see the note about the shape of the return array for details

Return type

array_like

property hermitian_symmetric

Whether the slab is Hermitian-symmetric

property hermitian_weights

Weights to be applied to quantities on the slab in order to account for Hermitian symmetry

These weights double-count the positive frequencies along the symmetry_axis.

property index

Return an indexing list appropriate for selecting the slicing the appropriate slab out of a full 3D array of shape (Nx, Ny, Nz)

property meshshape

Return the local shape of the mesh on this rank, as determined by the input coordinates array

mu(los)[source]

The mu value defined at each point on the slab for the specified line-of-sight index

Parameters

los (array_like,) – the direction of the line-of-sight, which mu is defined with respect to; must have a norm of 1.

Returns

the mu value at each point in the slab

Return type

array_like, (slab.shape)

property nonsingular

The indices on the slab of the positive frequencies along the dimension specified by symmetry_axis.

This takes advantage of the fact that pmesh.pm.ComplexField shifts the Nyquist frequencies to the negative halves. Therefore this ensures that the zero and Nyquist planes perpendicular to the symmetry axis have weight 1, whereas other modes have weight 2.

Returns

idx – Return a boolean array with the shape of the slab, with True elements giving the elements with positive freq along symmetry_axis

Return type

array_like, self.shape

norm2()[source]

The square of coordinate grid norm defined at each point on the slab.

This broadcasts the coordinate arrays along each dimension to compute the norm at each point in the slab.

Returns

the square of coordinate mesh at each point in the slab

Return type

array_like, (slab.shape)

property shape

Return the shape of the slab

nbodykit.meshtools.SlabIterator(coords, axis=0, symmetry_axis=None)[source]

Iterate over the specified dimension of the coordinate mesh, returning a MeshSlab for each iteration

Parameters
  • coords (list of arrays) – the coordinate arrays of the mesh, with proper 3D shapes for easy broadcasting; if the mesh has size (Nx, Ny, Nz), then the shapes of x3d should be: [(Nx, 1, 1), (1, Ny, 1), (1, 1, Nz)]

  • axis (int, optional) – the index of the mesh axis to iterate over

  • symmetry_axis (int, optional) – if provided, the axis that has been compressed due to Hermitian symmetry