endas.localization.grid.Grid2d

class endas.localization.grid.Grid2d(nx, ny, extent, cs, mask=None, block_size=1, padding=0)

Bases: endas.localization.domain.StateSpacePartitioning

Organizes state vector elements on a two-dimensional grid.

The grid can be sparse, i.e. not all grid cells must be included in the state vector. Both cartesian and polar coordinates can be used, the grid itself is not tied to any particular coordinate system.

Parameters:
  • nx – Number of cells in the grid along the x axis
  • ny – Number of cells in the grid along the y axis
  • extent – Extent of the grid given as BBox. If None is passed, a region defined by BBox((0, 0), (nx, ny)) is assumed (i.e. the grid starts at (0, 0) and cell size is 1.
  • cs – Coordinate system of the grid. Must be an instance of endas.localization.CoordinateSystem and cs.ndim must be 2
  • mask – Flat array of indexes identifying grid cells included in the state vector. If None is passed (this is the default), the grid is assumed to be dense.
  • block_size – Size of each local domain along each dimension. The default value 1 results in analysis being performed for each grid cell individually
  • padding – If greater than zero, each local domain will be padded by the given number of cells.

If not all cells in the grid are a part of the state, the mask array must be given to define which grid cells correspond to which state vector elements. The mask array is a flat array of the same length as the state vector, with each element mask[i] containing the index of the cell corresponding to state variable \(x_i\). Cells in the grid are indexed from top to bottom in row-major order. If mask is None, it is assumed that all cells are included in the state vector. How grid cells are mapped to the state vector via the mask array is shown below:

../../_images/loc_grid2d_masking.png

Masking grid cells and their mapping to the state vector. Grid cells selected by the mask array are shown with gray background.

Note

It is valid to map several state variables to a single grid cell, for example if they contain different quantities in a multivariate setting. In this case the mask array must always be given, even if the grid is dense.