Grid#

class pisces.geometry.grids.base.Grid(coordinate_system: CoordinateSystem, *args, axes: str | tuple[str, ...] = 'all', fill_values: dict[str, Any] | None = None, units: dict[str, str | Unit] | None = None, **kwargs)[source]#

Base class for all grids in Pisces.

A grid represents a discretization of a coordinate system into a finite number of points or cells. This base class provides the common interface and functionality for all grid types, including structured and unstructured grids. For more details on grid structure, see the relevant documentation.

Methods

__init__(coordinate_system, *args[, axes, ...])

empty_like([dtype, element_shape])

Create an uninitialized array with the same shape as the grid.

from_hdf5(filename[, group])

Load a grid from an HDF5 file.

full_like(fill_value[, dtype, element_shape])

Create a filled array with the same shape as the grid.

get_axis_array(axis)

Return the full coordinate array for a single axis.

get_axis_arrays([axes])

Return 1D coordinate arrays for one or more axes.

get_axis_coordinate_array(axis, slc)

Return the coordinate values along a single axis for a given slice.

get_coordinate_dict([meshgrid])

Return coordinate arrays in dictionary form with axis names as keys.

get_coordinates_slice(*slcs[, axes])

Return coordinate values for a sliced region of the grid.

get_flat_coordinates()

Return a flattened array of coordinate vectors for all grid points.

get_index_arrays()

Return 1D arrays of grid indices for each active axis.

get_index_meshgrid([indexing])

Return a meshgrid of index values for each active axis.

get_meshgrid([axes, indexing])

Return the full meshgrid of coordinates for the specified axes.

get_meshgrid_slice(*slcs[, axes, indexing])

Return a meshgrid of coordinates for a sliced region of the grid.

ones_like([dtype, element_shape])

Create a one-filled array with the same shape as the grid.

to_hdf5(filename[, group, overwrite])

Save the grid to an HDF5 file.

zeros_like([dtype, element_shape])

Create a zero-filled array with the same shape as the grid.

Attributes

active_axes

Tuple of axis names that are active in the grid.

active_axes_mask

Boolean mask array indicating which axes are active in the grid.

bounding_box

The bounding box of the grid.

coordinate_system

The coordinate system associated with this grid.

dimensions

The number of grid points along each active axis.

fill_values

Dictionary of fill values for axes not active in the grid.

inactive_axes_mask

Boolean mask array indicating which axes are filled (not active) in the grid.

ndim

Total number of axes in the coordinate system.

ndim_active

Number of active axes in the grid.

ndim_inactive

Number of inactive (filled) axes in the grid.

shape

The shape of the grid.

size

The total number of grid points in the grid.

units

Dictionary mapping axis names to their units.