discretize.utils.active_from_xyz

discretize.utils.active_from_xyz(mesh, xyz, grid_reference='CC', method='linear')[source]

Returns an active cell index array below a surface

Get active cells in the mesh that are below the surface create by interpolating over the last dimension of the input points. This method will uses scipy’s interpolation routine to interpolate between input points. This will use a nearest neighbour interpolation for cell values outside the convex hull of points.

For grid_reference=’CC’, this will check if the center of a given cell in the mesh is below the interpolation surface to determine if that cell is active.

For grid_reference=’N’, this will check if every node of a given cell in the mesh is below the interpolation surface.

For the

Parameters
meshTensorMesh or TreeMesh or CylMesh

Mesh object, (if CylMesh: mesh must be symmetric).

xyznumpy.ndarray

Points coordinates shape (*, mesh.dim).

grid_reference{‘CC’, ‘N’}

Use cell coordinates from cells-center ‘CC’ or nodes ‘N’.

method{‘linear’, ‘nearest’}

Interpolation method for the xyz points.

Returns
activenumpy.ndarray

1D mask array of bool for the active cells below xyz.

Examples

import matplotlib.pyplot as plt
import numpy as np
from discretize import TensorMesh
from discretize.utils import active_from_xyz

mesh = TensorMesh([5, 5])
topo_func = lambda x: -3*(x-0.2)*(x-0.8)+.5
topo_points = np.linspace(0, 1)
topo_vals = topo_func(topo_points)

active_cc = active_from_xyz(mesh, np.c_[topo_points, topo_vals], grid_reference='CC')
ax = plt.subplot(121)
mesh.plotImage(active_cc, ax=ax)
mesh.plotGrid(centers=True, ax=ax)
ax.plot(np.linspace(0,1), topo_func(np.linspace(0,1)), color='C3')
ax.set_title("CC")

active_n = active_from_xyz(mesh, np.c_[topo_points, topo_vals], grid_reference='N')
ax = plt.subplot(122)
mesh.plotImage(active_n, ax=ax)
mesh.plotGrid(nodes=True, ax=ax)
ax.plot(np.linspace(0,1), topo_func(np.linspace(0,1)), color='C3')
ax.set_title("N")
plt.show()

(Source code, png, pdf)

../../_images/discretize-utils-active_from_xyz-1.png