2.23.4.3. pycsamt.format.regrid#
Regridding of unstructured meshes onto 2D grids.
The implementation lives in the standalone pcsf package
(pcsf.algorithms.regrid), the reference implementation of the
format. This module re-exports it under its pyCSAMT name, so that
existing imports keep working and pyCSAMT objects are the pcsf objects
themselves.
See also
pcsf.algorithms.regridImplementation.
- pycsamt.format.regrid.mesh_to_grid2d(model, *, nx=200, nz=150)
Sample a triangular-mesh model on a regular
grid2d.- Parameters:
model (PCSFModel) – Model of kind
mesh_unstructuredin plane"xz"with per-triangle resistivity of shape(n_triangles,). A per-region array must first be expanded onto each triangle’s region id.nx (int, default 200 and 150) – Number of grid points along x and z. A mesh has no natural rectilinear resolution, so these are explicit, bounded defaults.
nz (int, default 200 and 150) – Number of grid points along x and z. A mesh has no natural rectilinear resolution, so these are explicit, bounded defaults.
- Returns:
New
grid2dmodel withnzbynxcells spanning the mesh bounding box. Points outside the triangulation are NaN.source_backend,created_by,crsandsurveyare carried over;descriptionandmetadata(keyssynthesized,regridded_from,regrid_nx,regrid_nz) record that the model is synthesized.- Return type:
- Raises:
GeometryError – If model is not
mesh_unstructured, its plane is not"xz", or its resistivity is not per triangle.
See also
pcsf.algorithms.sample_log10Sample at arbitrary points.
Notes
Each grid point \(\mathbf{p}_{ij}\) takes the resistivity of the triangle \(t(\mathbf{p}_{ij})\) that contains it; no value is interpolated or extrapolated, so contrasts across region boundaries stay sharp at the cost of staircase edges of one grid step. The source values and the per-region table do not apply to the grid and are dropped.
Examples
>>> import numpy as np >>> import pcsf >>> from pcsf.algorithms import mesh_to_grid2d >>> geometry = pcsf.UnstructuredMeshGeometry( ... nodes=np.array([[0.0, 0.0], [1.0, 0.0], [0.0, 1.0], ... [1.0, 1.0]]), ... connectivity=np.array([[0, 1, 2], [1, 3, 2]]), ... region_ids=np.array([0, 1]), ... ) >>> model = pcsf.PCSFModel(geometry=geometry, ... resistivity=np.array([10.0, 20.0])) >>> grid = mesh_to_grid2d(model, nx=5, nz=5) >>> grid.kind, grid.resistivity.shape ('grid2d', (5, 5)) >>> grid.metadata["synthesized"] True