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:
- cell_centroids¶
Centroids of cells.
- cell_volumes¶
Volumes of 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:
- Returns:
res – Matrix of active neighbors and matrix of distances if ‘calculate_distances’.
- Return type:
misc
- 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:
- 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:
- downscale(factors=(2, 2, 2))[source]¶
Downscale grid according to factors given.
- 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:
- 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:
- 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.
- 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:
- 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:
- 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.