geossm.covmodel.buildMeshGrid2d¶
- geossm.covmodel.buildMeshGrid2d(points=None, domain=None, offset=None, nx=None, ny=None, lowrank=None, min_degree=3, tol=0.02, max_iter=25)[source]¶
Build a regular (structured) 2D triangular mesh: a lattice of nx by ny vertices spanning the bounding box of domain (or the convex hull of points if domain is not given), extended by offset. Grid cells lying entirely outside the (buffered) convex hull are dropped, so the mesh follows the shape of domain rather than just its bounding box. Any vertex left with fewer than min_degree mesh edges by that pruning (stray corners along the boundary “staircase”) is removed together with its triangles, repeated until the whole mesh satisfies min_degree; vertices left unused are dropped from the result.
The resolution can be set directly with nx/ny, or – when points and lowrank are given instead – solved for automatically so the final mesh has approximately
round(lowrank * len(points))vertices, mirroring buildMesh2d’s lowrank argument. Note the lattice stays regular: lowrank only controls its overall resolution here, not a spatially-varying density.- Parameters:
points (
(n,2) array_like, optional) – Observed locations. Used to derive domain (as their convex hull) when domain is not given, and as the basis for lowrank.domain (
shapely.geometry.Polygon, optional) – The scientific-interest domain the mesh must cover.offset (
float, optional) – Buffer added around domain so the lattice extends past the data. Defaults to 1/15 of the domain’s bounding-box diagonal.nx (
int, optional) – Number of vertices along the x- and y-axis of the underlying rectangular lattice (before pruning). Give both together, or give lowrank instead.ny (
int, optional) – Number of vertices along the x- and y-axis of the underlying rectangular lattice (before pruning). Give both together, or give lowrank instead.lowrank (
float, optional) – Value in (0, 1]. When given (with nx/ny left unset), the resolution is found automatically so the mesh has approximatelyround(lowrank * len(points))vertices. Requires points.min_degree (
int, default3) – Minimum number of mesh edges required at every vertex.tol (
float, default0.02) – Relative tolerance on the vertex-count target used by the lowrank search.max_iter (
int, default25) – Maximum number of mesh (re)generations used by the lowrank search.
- Returns:
mesh (
meshio.Mesh)convex_hull (
shapely.geometry.Polygon) – The (buffered) convex hull the mesh was built over – domain (or its default) extended by offset.