Grids

Grid

class Grid(*args, **kwargs)[source]

Bases: SpatialComponent

Basic grid class.

bounding_box

Pair of diagonal corner points for grid’s bounding box.

calculate_neighbours_distances(connectivity=1, fill_value=-1, neighbours_matrix=None)[source]

Calculate distances between neighbors for all active cells.

Parameters:
  • connectivity (int, optional) – Maximum number of orthogonal hops to consider a cell is as a neighbor., by default 1.

  • fill_value (int, optional) – Value to fill indices of inactive or absent neighbors, by default -1.

  • neighbours_matrix (numpy.ndarray, optional) – Matrix with indices of neighbors in unraveled form.

Returns:

Matrix of distances.

Return type:

numpy.ndarray

cell_centroids

Centroids of cells.

cell_volumes

Volumes of cells.

crop_minimal_cube()[source]

Crop to minimal cube containing active cells.

property ex

Unit vector along grid X axis.

property ey

Unit vector along grid Y axis.

get_neighbors_matrix(connectivity=1, fill_value=-1, ravel_index=False)[source]

Get indices of neighbors for all active cells.

Parameters:
  • connectivity (int, optional) – Maximum number of orthogonal hops to consider a cell is as a neighbor, by default 1.

  • fill_value (int, optional) – Value to fill indices of inactive or absent neighbors, by default -1.

  • ravel_index (bool, optional) – Indices in raveled form, by default False.

Returns:

res – Matrix of active neighbors and matrix of distances if ‘calculate_distances’.

Return type:

misc

minimal_active_slices()[source]

Get minimal cube slice that contains all active cells.

property origin

Grid axes origin relative to the map coordinates.

pad_na(attr, fill_na=0.0, inplace=True)[source]

Add dummy cells into the state vector in the positions of non-active cells if necessary.

Parameters:
  • attr (str, array-like) – Attributes to be padded with non-active cells.

  • actnum (array-like of type bool) – Vector representing a mask of active and non-active cells.

  • fill_na (float) – Value to be used as filler.

  • inplace (bool) – Modify сomponent inplace.

Returns:

output

Return type:

component if inplace else padded attribute.

xyz

Cell coordinates.

Orthogonal uniform grid

class OrthogonalUniformGrid(**kwargs)[source]

Bases: Grid

Orthogonal uniform grid.

as_corner_point

Creates CornerPoint representation of the current grid.

bounding_box

Pair of diagonal corner points for grid’s bounding box.

cell_centroids

Centroids of cells.

property cell_size

Cell size.

cell_volumes

Volumes of cells.

crop_minimal_cube()[source]

Crop to minimal cube containing active cells.

Returns:

(grid, min_slices) – New grid and slices for active cube.

Return type:

tuple

downscale(factors=(2, 2, 2))[source]

Downscale grid according to factors given.

Parameters:

factors (tuple, int) – Scale factors along each axis. If int, factors are the same for each axis.

Returns:

grid – Downscaled grid.

Return type:

OrthogonalUniformGrid

to_corner_point()[source]

Convert to corner point grid.

Returns:

grid

Return type:

CornerPointGrid

upscale(factors=(2, 2, 2), actnum_upscale='vote')[source]

Upscale grid according to factors given.

Parameters:
  • factors (tuple, int) – Scale factors along each axis. If int, factors are the same for each axis.

  • actnum_upscale (str) – Method to actnum upscaling. If ‘vote’, upscaled cell is active if majority of finer cells are active. If ‘any’, upscaled cell is active if any of finer cells is active. Default to ‘vote’.

Returns:

grid – Upscaled grid.

Return type:

OrthogonalUniformGrid

property xyz

Cells’ vertices coordinates.

Corner-point grid

class CornerPointGrid(*args, **kwargs)[source]

Bases: Grid

Corner point grid.

property as_corner_point

Returns itself.

bounding_box

Pair of diagonal corner points for grid’s bounding box.

cell_bases(cell_indices)[source]

Calculate basis vectors of coordinate systems connected to cells.

Parameters:

cells_indices (List[np.ndarray]) – Indices of the cells.

Returns:

Basis vectors of coordinate systems connected to cells.

Return type:

np.ndarray

cell_centroids

Centroids of cells.

cell_sizes(cell_indices)[source]

Calculate approximate sizes of cells.

Parameters:

cells_indices (List[np.ndarray]) – Indices of the cells.

Returns:

Sizes of cells.

Return type:

np.ndarray

cell_volumes

Volumes of cells.

crop_minimal_cube()[source]

Crop to minimal cube containing active cells.

Returns:

(grid, min_slices) – New grid and slices for active cube.

Return type:

tuple

crop_minimal_grid(nz, fillna=None)[source]

Create a new grid in a region between upper and bottom surfaces enclosing active cells. Actnum tranfer should be made separately.

Parameters:
  • nz (int) – Third dimension of the cunstructed grid.

  • fillna (scalar) – Filling value for nan coordinates.

Returns:

(grid, grid_mask, z_top, z_bottom)

Return type:

tuple

faces_centers(cells_indices)[source]

Calculate coordinates of cell faces centers.

Parameters:

cells_indices (List[np.ndarray]) – Indices of the cells.

Returns:

coordinates of cell faces centers.

Return type:

np.ndarray

map_grid()[source]

Map pillars (COORD) to axis defined by `MAPAXES’.

Returns:

Grid with updated COORD and MAPAXES fields.

Return type:

CornerPointGrid

minimal_active_bounds()[source]

Get z coordinates of top and bottom bounds of active cells.

property origin

Grid axes origin relative to the map coordinates.

orthogonalize(dimens, only_active=False)[source]

Construct orthogonal uniform grid. Actnum tranfer should be made separately.

upscale(factors=(2, 2, 2), actnum_upscale='vote')[source]

Upscale grid according to factors given.

Parameters:
  • factors (tuple, int) – Scale factors along each axis. If int, factors are the same for each axis.

  • actnum_upscale (str) – Method to actnum upscaling. If ‘vote’, upscaled cell is active if majority of finer cells are active. If ‘any’, upscaled cell is active if any of finer cells is active. Default to ‘vote’.

Returns:

grid – Upscaled grid.

Return type:

CornerPointGrid

xyz

x, y, z coordinates of cells vertices.

xyz_max

Maximums of x, y, z coordinates of cells vertices.

xyz_min

Minimums of x, y, z coordinates of cells vertices.