pycsa.core.delaunay¶
Delaunay decomposition and land-cell selection.
Partitions a lat-lon topography domain into Delaunay triangles whose
vertices sit on a coarse regular grid (get_decomposition()), and
selects the subset of triangles that contain enough above-threshold
topography to be treated as land cells (get_land_cells()). The
scipy.spatial.Delaunay object returned by get_decomposition()
is augmented in place with .tri_lat_verts / .tri_lon_verts (and
centroid arrays) that downstream consumers, including
get_land_cells(), rely on.
Functions
|
Partitions a lat-lon domain into a number of coarser but regularly spaced points that comprises the vertices of the Delaunay triangles. |
|
Land cell selector based on how much of a grid cell contains topography of a certain elevation. |
- pycsa.core.delaunay.get_decomposition(topo, xnp=11, ynp=6, padding=0)¶
Partitions a lat-lon domain into a number of coarser but regularly spaced points that comprises the vertices of the Delaunay triangles.
- Parameters:
topo (array-like) – 2D topography data
xnp (int, optional) – number of points in the first horizontal direction, by default 11
ynp (int, optional) – number of points in the second horizontal direction, by default 6
padding (int, optional) – number of grid points to include as a boundary (padded) region, by default 0
- Returns:
scipy Delaunay triangulation instance, augmented in place with
tri_lat_verts/tri_lon_verts(per-triangle vertex coordinates) andtri_clats/tri_clons(centroids).- Return type:
scipy.spatial.Delaunayinstance
- pycsa.core.delaunay.get_land_cells(tri, topo, height_tol=0.5, percent_tol=0.95)¶
Land cell selector based on how much of a grid cell contains topography of a certain elevation.
- Parameters:
tri (
scipy.spatial.Delaunay) – Triangulation as returned byget_decomposition(). Must carry the.tri_lat_verts/.tri_lon_vertsper-triangle vertex-coordinate arrays thatget_decomposition()attaches.topo (array-like) – 2D topographic data
height_tol (float, optional) – elevation above height_tol is considered land, by default 0.5 [m]
percent_tol (float, optional) – Maximum fraction of a cell that may sit at or below height_tol before the cell is rejected as ocean, by default 0.95. The cell is dropped when more than percent_tol of its grid points are at or below height_tol (
(topo <= height_tol).sum() / size > percent_tol) and kept as a land cell otherwise.
- Returns:
list of land cell indices. Only even-indexed triangles (
range(n_tri)[::2]) are evaluated; odd-indexed triangles are skipped because each grid quad is split into two triangles and the pair shares the same topography footprint.- Return type: