Skip to content

cornerpoint⚓︎

Common functionality for visualization of corner-point grids.

import pyresito.grid.cornerpoint as cp

bounding_box(corn, filtr) ⚓︎

Calculate the bounding box of the grid.

This function assumes that the grid is aligned with the geographical axes.

Parameters:

Name Type Description Default
corn ndarray

Coordinate values for each corner. This matrix can be constructed with the corner_coordinates function. Shape: (3, nk*2*nj*2*ni*2)

required
filtr ndarray

Active corners; use scatter of ACTNUM if no filtering. Shape: (nk, 2, nj, 2, ni, 2), dtype: numpy.bool

required

Returns:

Type Description
ndarray

Bottom front right corner and top back left corner. Since the matrix is returned with C ordering, it is specified the opposite way of what is natural for mathematical matrices. Shape: (2, 3), dtype: numpy.float64

Examples:

>>> corn = corner_coordinates(grid['COORD'], grid['ZCORN'])
>>> bbox = bounding_box(corn, scatter(grid['ACTNUM']))
>>> p, q = bbox[0, :], bbox[1, :]
>>> diag = np.sqrt(np.dot(q - p, q - p))

cell_filter(grid, func) ⚓︎

Create a filter for a specific grid.

Parameters:

Name Type Description Default
grid dict

Grid structure that should be filtered.

required
func Callable[(int, int, int), bool]

Lambda function that takes i, j, k indices (one-based) and returns boolean for whether the cells should be included or not. The function should be vectorized.

required

Returns:

Name Type Description
layr ndarray

Filtered grid layer.

Examples:

>>> layr = cell_filter(grid, lambda i, j, k: np.greater_equal(k, 56))

corner_coordinates(coord, zcorn) ⚓︎

Generate (x, y, z) coordinates for each corner-point.

Parameters:

Name Type Description Default
coord ndarray

Pillar geometrical information. Shape: (nj+1, ni+1, 2, 3)

required
zcorn ndarray

Depth values along each pillar. Shape: (nk, 2, nj, 2, ni, 2)

required

Returns:

Type Description
ndarray

Coordinate values for each corner. Shape: (3, nk*2*nj*2*ni*2)

cp_cells(grid, face) ⚓︎

Make a cell array from a cornerpoint grid. The cells will be in the same order as the Cartesian enumeration of the grid.

Parameters:

Name Type Description Default
grid dict

Pillar coordinates and corner depths. Must contain 'coord' and 'zcorn' properties.

required
face Face enum

Which face that should be extracted, e.g. Face.UP.

required

Returns:

Type Description
dict

Set of geometrical objects that can be sent to rendering. Contains: - 'points': ndarray, shape (nverts, 3) - 'cells': ndarray, shape (nelems, ncorns), where ncorns is either 8 (hexahedron volume) or 4 (quadrilateral face), depending on the face parameter.

elem_vtcs_ndcs(nk, nj, ni) ⚓︎

List zcorn indices used by every element in an nk*nj*ni grid.

Parameters:

Name Type Description Default
nk int

Number of layers in Z direction.

required
nj int

Number of elements in the Y direction.

required
ni int

Number of elements in the X direction.

required

Returns:

Type Description
ndarray

Zero-based indices for the hexahedral element corners, with shape (nk*nj*ni, 8) and dtype int.

face_coords(grid) ⚓︎

Get (x, y, z) coordinates for each corner-point.

Parameters:

Name Type Description Default
grid dict

Cornerpoint-grid.

required

Returns:

Type Description
ndarray

Coordinate values for each corner. Use the Face enum to index the first dimension, k, j, i coordinates to index the next three, and Dim enum to index the last dimension. Note that the first point in a face is not necessarily the point that is closest to the origin of the grid. Shape = (8, nk, nj, ni, 3).

Examples:

>>> import numpy as np
>>> import pyresito.io.ecl as ecl
>>> import pyresito.grid.cornerpoint as cp
>>> case = ecl.EclipseCase("FOO")
>>> coord_fijkd = cp.face_coords(case.grid())
>>> # get the midpoint of the upper face in each cell
>>> up_mid = np.average(coord_fijkd[cp.Face.UP, :, :, :, :], axis=0)

horizon(grid, layer=0, top=True) ⚓︎

Extract the points that are in a certain horizon and average them so that the result is per cell and not per pillar.

Parameters:

Name Type Description Default
grid dict

Grid structure.

required
layer int

The K index of the horizon. Default is the layer at the top.

0
top bool

Whether the top face should be exported. If this is False, then the bottom face is exported instead.

True

Returns:

Type Description
array

Depth at the specified horizon for each cell center, with shape (nk, nj, ni) and dtype numpy.float64.

horizon_pillars(grid, layer=0, top=True) ⚓︎

Extract heights where a horizon crosses the pillars.

Parameters:

Name Type Description Default
grid dict

Grid structure, containing both COORD and ZCORN properties.

required
layer int

The K index of the horizon. Default is the layer at the top.

0
top bool

Whether the top face should be exported. If False, then the bottom face is exported instead.

True

Returns:

Type Description
ndarray

Heights of the horizon at each pillar, in the same format as the COORD matrix. Shape: (nj+1, ni+1, 2, 3)

inner_dup(pillar_field) ⚓︎

Duplicate all inner items in both dimensions.

Use this method to duplicate values associated with each pillar to the corners on each side(s) of the pillar; four corners for all interior pillars, two corners for all pillars on the rim and only one (element) corner for those pillars that are on the grid corners.

Parameters:

Name Type Description Default
pillar_field ndarray

Property per pillar in the grid, shape = (m+1, n+1)

required

Returns:

Type Description
ndarray

Property per corner in a grid plane, shape = (2*m, 2*n)

Examples:

>>> inner_dup(np.array([[1, 2, 3],
                        [4, 5, 6],
                        [7, 8, 9]]))
array([[1, 2, 2, 3],
       [4, 5, 5, 6],
       [4, 5, 5, 6],
       [7, 8, 8, 9]])

mass_center(corn, filtr) ⚓︎

Mass center of the grid.

This function will always assume that the density is equal throughout the field.

Parameters:

Name Type Description Default
corn ndarray

Coordinate values for each corner. This matrix can be constructed with the corner_coordinates function. Shape = (3, nk*2*nj*2*ni*2).

required
filtr ndarray

Active corners; use scatter of ACTNUM if no filtering. Shape = (nk, 2, nj, 2, ni, 2), dtype = numpy.bool.

required

Returns:

Type Description
ndarray

Center of mass. This should be the focal point of the grid. Shape = (3,), dtype = np.float64.

Examples:

>>> corn = cp.corner_coordinates(grid['COORD'], grid['ZCORN'])
>>> focal_point = cp.mass_center(corn, cp.scatter(grid['ACTNUM']))

scatter(cell_field) ⚓︎

Duplicate all items in every dimension.

Use this method to duplicate values associated with each cell to each of the corners in the cell.

Parameters:

Name Type Description Default
cell_field ndarray

Property per cell in the grid, shape = (nk, nj, ni)

required

Returns:

Type Description
ndarray

Property per corner in the cube, shape = (nk, 2, nj, 2, ni, 2)

Examples:

>>> scatter(np.array([[[1, 2],
                       [3, 4]],
                      [[5, 6],
                       [7, 8]]]))
array([[[[[[1, 1], [2, 2]],
          [[1, 1], [2, 2]]],
         [[[3, 3], [4, 4]],
          [[3, 3], [4, 4]]]],
    [[[[1, 1], [2, 2]],
      [[1, 1], [2, 2]]],
     [[[3, 3], [4, 4]],
      [[3, 3], [4, 4]]]]],

   [[[[[5, 5], [6, 6]],
      [[5, 5], [6, 6]]],
     [[[7, 7], [8, 8]],
      [[7, 7], [8, 8]]]],

    [[[[5, 5], [6, 6]],
      [[5, 5], [6, 6]]],
     [[[7, 7], [8, 8]],
      [[7, 7], [8, 8]]]]]])

snugfit(grid) ⚓︎

Create coordinate pillars that match exactly the top and bottom horizon of the grid cells.

This version assumes that the pillars in the grid are all strictly vertical, i.e., the x- and y-coordinates will not be changed.

Parameters:

Name Type Description Default
grid dict

Grid structure, containing both COORD and ZCORN properties.

required

Returns:

Type Description
ndarray

Pillar coordinates, in the same format as the COORD matrix. Note that a new matrix is returned, the original grid is not altered/updated. Shape: (nj+1, ni+1, 2, 3)