endas.localization.grid.Grid2d¶
-
class
endas.localization.grid.Grid2d(nx, ny, extent, cs, mask=None, block_size=1, padding=0)¶ Bases:
endas.localization.domain.StateSpacePartitioningOrganizes 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. IfNoneis passed, a region defined byBBox((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.CoordinateSystemandcs.ndimmust be 2 - mask – Flat array of indexes identifying grid cells included in the state vector. If
Noneis 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
maskarray 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 elementmask[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. IfmaskisNone, 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:
Masking grid cells and their mapping to the state vector. Grid cells selected by the
maskarray 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
maskarray must always be given, even if the grid is dense.