Meshing#
Mesh#
Tools for turning data into meshes, then writing them to file.
Works with and assumes all polyhedra cells (and polygon faces).
Requires building a reasonably recent version of Exodus to get the associated exodus.py wrappers in python3.
Note that this is typically done in your standard ATS installation, assuming you have built your Amanzi TPLs with shared libraries (the default through bootstrap).
In that case, simply ensure that ${AMANZI_TPLS_DIR}/SEACAS/lib is in your PYTHONPATH.
- class watershed_workflow.mesh.LabeledSet(name: str, setid: int, entity: str, ent_ids: List[Any], to_extrude: bool = False)[source]#
A generic collection of entities.
- class watershed_workflow.mesh.Mesh2D(coords, conn, labeled_sets: List[LabeledSet] = NOTHING, crs: CRS | None = None, eps: float = 0.001, check_handedness: bool = True, validate: bool = False, cell_data: DataFrame | None = None)[source]#
A 2D mesh class.
- Parameters:
coords (np.ndarray(NCOORDS,NDIMS)) – Array of coordinates of the 2D mesh.
conn (list(lists)) – List of lists of indices into coords that form the cells.
labeled_sets (list(LabeledSet), optional) – List of labeled sets to add to the mesh.
crs (CRS) – Keep this as a property for future reference.
eps (float, optional=0.01) – A small measure of length between coords.
check_handedness (bool, optional=True) – If true, ensure all cells are oriented so that right-hand rule ordering of the vertices points up.
validate (bool, optional=False) – If true, validate coordinates and connections post-construction.
Note ((coords, conn) may be output provided by a)
call. (watershed_workflow.triangulation.triangulate())
- property boundary_edges#
Return edges in the boundary of the mesh, ordered around the boundary.
- cell_edges(conn: List[int])[source]#
Generator for edges of a cell.
- Parameters:
conn (List[int]) – Cell connectivity (vertex indices).
- Yields:
Tuple[int, int] – Edge as a tuple of vertex indices.
- property centroids#
Calculate surface mesh centroids.
- checkHandedness() None [source]#
Ensures all cells are oriented via the right-hand-rule, i.e. in the +z direction.
- clearGeometryCache() None [source]#
If coordinates are changed, any computed, cached geometry must be recomputed. It is the USER’s responsibility to call this function if any coords are changed!
- computeCentroid(c) ndarray [source]#
Computes, based on coords, the centroid of a cell with ID c.
Note this ALWAYS recomputes the value, not using the cache.
- property conn#
Note that conn is immutable because changing this breaks all the other properties, which may be cached. To change topology, one must construct a new mesh!
- property dim: int#
Spatial dimension of the mesh.
- Returns:
Number of spatial dimensions.
- Return type:
int
- static edge_hash(i: int, j: int) Tuple[int, int] [source]#
Hashes edges in a direction-independent way.
- Parameters:
i (int) – First vertex index.
j (int) – Second vertex index.
- Returns:
Sorted tuple of vertex indices.
- Return type:
Tuple[int, int]
- classmethod from_Transect(x, z, width=1, **kwargs)[source]#
Creates a 2D surface strip mesh from transect data
- property num_cells: int#
Number of cells in the mesh.
- Returns:
Number of cells.
- Return type:
int
- property num_edges: int#
Number of edges in the mesh.
- Returns:
Number of edges.
- Return type:
int
- property num_vertices: int#
Number of vertices in the mesh.
- Returns:
Number of vertices.
- Return type:
int
- plot(facecolors=None, ax=None, cmap=None, vmin=None, vmax=None, norm=None, colorbar=True, **kwargs) PolyCollection [source]#
Plot the flattened 2D mesh.
- to_dual()[source]#
Creates a 2D surface mesh from a primal 2D triangular surface mesh.
- Returns:
dual_vertices (np.ndarray)
dual_conn (list(lists)) – The vertices and cell_to_vertex_conn of a 2D, polygonal, nearly Voronoi mesh that is the truncated dual of self. Here we say nearly because the boundary triangles (see note below) are not Voronoi.
dual_from_primal_mapping (np.array( (len(dual_conn),), ‘i’)) – Mapping from a dual cell to the primal vertex it is based on. Without the boundary, this would be simply arange(0,len(dual_conn)), but beacuse we added triangles on the boundary, this mapping is useful.
Note
Vertices of the dual are on circumcenters of the primal triangles.
Centers of the dual are numbered by vertices of the primal mesh, modulo the boundary.
At the boundary, the truncated dual polygon may be non-convex. To avoid this issue, we triangulate boundary polygons.
We do not simply construct a mesh because likely the user needs to elevate, generate material IDs, labeled sets, etc, prior to mesh construction.
- class watershed_workflow.mesh.Mesh3D(coords, face_to_vertex_conn, cell_to_face_conn, labeled_sets: List[LabeledSet] = NOTHING, side_sets: List[SideSet] = NOTHING, material_ids: List[ndarray] = NOTHING, crs: CRS | None = None, eps: float = 0.001, validate: bool = False)[source]#
A 3D mesh class.
- Parameters:
coords (np.ndarray(NCOORDS,3)) – Array of coordinates of the 3D mesh.
face_to_vertex_conn (list(lists)) – List of lists of indices into coords that form the faces.
cell_to_face_conn (list(lists)) – List of lists of indices into face_to_vertex_conn that form the cells.
side_sets (list(SideSet), optional) – List of side sets to add to the mesh.
labeled_sets (list(LabeledSet), optional) – List of labeled sets to add to the mesh.
material_ids (np.array((len(cell_to_face_conn),),'i'), optional) – Array of length num_cells that specifies material IDs
crs (CRS) – Keep the coordinate system for reference.
eps (float, optional=0.01) – A small measure of length between coords.
(coords (Note that)
a (conn) may be output provided by)
call. (watershed_workflow.triangulation.triangulate())
- classmethod extruded_Mesh2D(mesh2D, layer_types, layer_data, ncells_per_layer, mat_ids)[source]#
Uniformly extrude a 2D mesh to make a 3D mesh.
Layers of potentially multiple sets of cells are extruded downward in the vertical. The cell dz is uniform horizontally and vertically through the layer in all but the ‘snapped’ case, where it is uniform vertically but not horizontally.
- Parameters:
mesh2D (Mesh2D) – The 2D mesh to extrude
layer_types (str, list[str]) – One of [‘snapped’, ‘function’, ‘vertex’, ‘cell’,] or a list of these strings, describing the extrusion method for each layer. If only a single string is supplied, all layers are of this type. See layer_data below.
layer_data (list[data]) –
Data required, one for each layer. The data is specific to the layer type:
’constant’ : float, layer thickness
’snapped’ : float, the bottom z-coordinate of the layer. Cells are extruded uniformly to whatever thickness required to match this bottom coordinate.
’function’ : function, layer_thickness = func(x,y)
’vertex’ : np.array((mesh2D.num_vertices,), float) layer thickness for each vertex
’cell’ : np.array((mesh2D.num_cells,), float) interpolates nodal layer thickness from neighboring cell thicknesses
ncells_per_layer (int, list[int]) – Either a single integer (same number of cells in all layers) or a list of number of cells in each layer
mat_ids (int, list[int], np.ndarray((num_layers, mesh2D.num_cells), dtype=int)) – Material ID for each cell in each layer. If an int, all cells in all layers share thesame material ID. If a list or 1D array, one material ID per layer. If a 2D array, provides all material IDs explicitly.
- Returns:
The extruded, 3D mesh.
- Return type:
- static summarizeExtrusion(layer_types, layer_data, ncells_per_layer, mat_ids, surface_cell_id=0) None [source]#
Summarizes extruded data by printing info to log file.
This is useful in rapidly debugging and understanding the layering before you do the extrusion process.
- class watershed_workflow.mesh.SideSet(name: str, setid: int, cell_list: list[int], side_list: list[int])[source]#
A collection of faces in cells.
- watershed_workflow.mesh.cache(func: Callable[[Any], Any]) Callable[[Any], Any] [source]#
A caching decorator for instance methods.
This decorator caches the result of a method call in an instance attribute. Note: Only works with __dict__ classes, not slotted classes.
- Parameters:
func (Callable[[Any], Any]) – The function to cache.
- Returns:
The wrapped function with caching.
- Return type:
Callable[[Any], Any]
- watershed_workflow.mesh.computeTelescopeFactor(ncells: int, dz: float, layer_dz: float) float [source]#
Calculates a telescoping factor to fill a given layer.
Calculates a constant geometric factor, such that a layer of thickness layer_dz is perfectly filled by ncells in the vertical, where the top cell is dz in thickness and each successive cell grows by a factor of that factor.
- Parameters:
ncells (int) – Number of cells (in the vertical) needed.
dz (float) – Top cell’s thickness in the vertical.
layer_dz (float) – Thickness of the total layer.
- Returns:
The telescoping factor.
- Return type:
float
- watershed_workflow.mesh.createSubmesh(m2: Mesh2D, shp: BaseGeometry) Tuple[Dict[int, int], Dict[int, int], Mesh2D] [source]#
Given a shape that contains some cells of m2, create the submesh.
- watershed_workflow.mesh.mergeMeshes(meshes: List[Mesh2D]) Mesh2D [source]#
Combines multiple 2D meshes into a single mesh.
It is assumed that the meshes to be combined have common vertices on the shared edge (no steiner points). labeledsets should be added after merging the mesh. Option of merging pre-existing labeledsets in the to-be-merged meshes will be added soon
- Parameters:
meshes (list(mesh.Mesh2D)) – The list of meshes to be merged
- Returns:
combined mesh
- Return type:
River-aligned Mesh#
creates river mesh using quad, pentagon and hexagon elements
- watershed_workflow.river_mesh.adjustHUCsToRiverMesh(hucs: SplitHUCs, river: River, coords: ndarray) None [source]#
Adjust HUC segments that touch reach endpoints to match the corridor coordinates.
- watershed_workflow.river_mesh.computeLine(p1: ndarray, p2: ndarray) Tuple[float, float, float] [source]#
Compute line coefficients (Ax + By + C = 0) for a line defined by two points.
- Parameters:
p1 (np.ndarray) – First point coordinates.
p2 (np.ndarray) – Second point coordinates.
- Returns:
Line coefficients (A, B, C) such that Ax + By + C = 0.
- Return type:
Tuple[float, float, float]
- watershed_workflow.river_mesh.createRiverMesh(river: River, computeWidth: Callable[[River], float], elems_gid_start: int = 0)[source]#
Returns list of elems and river corridor polygons for a given list of river trees
Parameters:#
- rivers: list(River object)
List of river tree along which river meshes are to be created
- widths: float or dict or callable or boolean
Width of the quads, either a float or a dictionary providing a {StreamOrder : width} mapping. Or a function (callable) that computer width using node properties Or boolean, where True means, width for each reach is explicitely provided properties as “width”
- enforce_convexity: boolean
If true, enforce convexity of the pentagons/hexagons at the junctions.
- axmatplotlib Axes object, optional
For debugging – plots troublesome reaches as quad elements are generated to find tricky areas.
- labelbool, optional = True
If true and ax is provided, animates the debugging plot with reach ID labels as the user hovers over the plot. Requires a widget backend for matplotlib.
- returns:
corrs (list(shapely.geometry.Polygon)) – List of river corridor polygons, one per river, storing the coordinates used in elems.
elems (list(list)) – List of river elements, each element a list of indices into corr.coords.
- watershed_workflow.river_mesh.createRiversMesh(hucs: SplitHUCs, rivers: List[River], computeWidth: Callable[[River], float], ax: Axes | None = None) Tuple[ndarray, List[List[int]], List[Polygon], List[Point], GeoDataFrame | None] [source]#
Create meshes for each river and merge them.
- Parameters:
- Returns:
Tuple containing coordinates, elements, corridors, hole points, and intersections dataframe.
- Return type:
Tuple[np.ndarray, List[List[int]], List[shapely.geometry.Polygon], List[shapely.geometry.Point], gpd.GeoDataFrame | None]
- watershed_workflow.river_mesh.createWidthFunction(arg: Dict[int, float] | Callable[[River], float] | float) Callable[[River], float] [source]#
Create a width function from various argument types.
- Parameters:
arg (Dict[int, float] | Callable[[int], float] | float) – Width specification - can be a constant, dictionary mapping stream order to width, or callable function.
- Returns:
Function that computes width for a given reach.
- Return type:
Callable[[int], float]
- watershed_workflow.river_mesh.findIntersection(line1: Tuple[float, float, float], line2: Tuple[float, float, float], debug: bool = False) ndarray | None [source]#
Find the intersection point of two lines given by coefficients.
- Parameters:
line1 (Tuple[float, float, float]) – First line coefficients (A, B, C).
line2 (Tuple[float, float, float]) – Second line coefficients (A, B, C).
debug (bool, optional) – Whether to print debug information, by default False.
- Returns:
Intersection point coordinates, or None if lines are parallel.
- Return type:
np.ndarray | None
- watershed_workflow.river_mesh.fixConvexity(reach: River, e_coords: ndarray, computeWidth: Callable[[River], float]) ndarray [source]#
Snap element coordinates onto the convex hull while respecting upstream stream width.
- watershed_workflow.river_mesh.projectJunction(reach: River, child_idx: int, computeWidth: Callable[[River], float], debug: bool = False) ndarray [source]#
Find points around the junction between reach and its children.
- Parameters:
- Returns:
Junction point coordinates.
- Return type:
np.ndarray
- watershed_workflow.river_mesh.projectOne(p_up: ndarray, p: ndarray, width: float) ndarray [source]#
Find a point p_out that is width away from p and such that p_up –> p is right-perpendicular to p –> p_out.
- Parameters:
p_up (np.ndarray) – Upstream point coordinates.
p (np.ndarray) – Reference point coordinates.
width (float) – Distance to project perpendicular to the line.
- Returns:
Projected point coordinates.
- Return type:
np.ndarray
- watershed_workflow.river_mesh.projectTwo(p_up: ndarray, p: ndarray, p_dn: ndarray, width1: float, width2: float, debug: bool = False) ndarray [source]#
Find a point that is perpendicular to the linestring p_up –> p –> p_dn.
Projects by intersecting two lines, one parallel to p_up –> p and width1 away, and one parallel to p –> p_dn and width2 away.
- Parameters:
p_up (np.ndarray) – Upstream point coordinates.
p (np.ndarray) – Middle point coordinates.
p_dn (np.ndarray) – Downstream point coordinates.
width1 (float) – Width for upstream segment.
width2 (float) – Width for downstream segment.
debug (bool, optional) – Whether to print debug information, by default False.
- Returns:
Projected point coordinates.
- Return type:
np.ndarray
- watershed_workflow.river_mesh.translateLinePerpendicular(line: Tuple[float, float, float], distance: float) Tuple[float, float, float] [source]#
Translate a line by a specified distance in the direction perpendicular to the line.
- Parameters:
line (Tuple[float, float, float]) – Tuple of line coefficients (A, B, C).
distance (float) – Scalar distance to translate the line.
- Returns:
Tuple of new line coefficients (A, B, C).
- Return type:
Tuple[float, float, float]
Triangulation#
Triangulates polygons
- class watershed_workflow.triangulation.Nodes(decimals: int = 3)[source]#
A collection of nodes that are indexed in the order they are added.
Note this uses round() for an efficient solution, which is potentially fragile if numbers were not generated consistently. In this use case, however, it should be safe – numbers were originally rounded (in watershed_workflow.config), and then any function which inserted new points or moved points were always careful to ensure that all duplicates were always assigned the identical values – i.e. all math was done BEFORE assignment. So duplicates have identical representations in floating point. This suggests we shouldn’t have to round here at all, but we do anyway to keep things cleaner.
- class watershed_workflow.triangulation.NodesEdges(objlist: List[LineString | Polygon] | None = None)[source]#
A collection of nodes and edges.
- watershed_workflow.triangulation.connectOnewayTrip(inds: List[int]) List[Tuple[int, int]] [source]#
Connect indices in edges in a oneway fashion
- watershed_workflow.triangulation.connectRoundTrip(inds: List[int]) List[Tuple[int, int]] [source]#
Connect indices in edges in a round-trip fashion
- watershed_workflow.triangulation.orient(e: Tuple[int, int]) Tuple[int, int] | None [source]#
Orient an edge consistently.
- Parameters:
e (Tuple[int, int]) – Edge as tuple of two vertex indices.
- Returns:
Oriented edge or None if vertices are identical.
- Return type:
Optional[Tuple[int, int]]
- watershed_workflow.triangulation.refineByMaxArea(max_area)[source]#
Returns a refinement function based on max area, for use with Triangle.
- watershed_workflow.triangulation.refineByMaxEdgeLength(edge_length)[source]#
Returns a refinement function based on max edge length, for use with Triangle.
- watershed_workflow.triangulation.refineByPolygons(polygons, areas)[source]#
Returns a graded refinement function based upon polygon area limits, for use with Triangle.
Triangle area must be smaller than the area limit for the polygon when the triangle centroid is within the polygon.
- watershed_workflow.triangulation.refineByRiverDistance(near_distance, near_area, away_distance, away_area, rivers)[source]#
Returns a graded refinement function based upon a distance function from rivers, for use with Triangle.
Triangle area must be smaller than near_area when the triangle centroid is within near_distance from the river network. Area must be smaller than away_area when the triangle centroid is at least away_distance from the river network. Area must be smaller than a linear interpolant between near_area and away_area when between near_distance and away_distance from the river network.
- watershed_workflow.triangulation.triangulate(hucs: SplitHUCs, internal_boundaries: List[LineString] | None = None, hole_points: List[Point] | None = None, tol: float = 1.0, **kwargs) Tuple[ndarray, ndarray] [source]#
Triangulates HUCs and rivers.
Note, refinement of a given triangle is done if any of the provided criteria is met.
- Parameters:
hucs (SplitHUCs) – A split-form HUC object from, e.g., get_split_form_hucs()
internal_boundaries (list, optional) – List of shapely objects or RiverTrees or other iterable collections of coordinates used as internal boundaries that must be included in the mesh.
hole_points (list(shapely.Point), optional) – List of points inside the polygons to be left as holes/voids (excluded from mesh).
tol (float, optional) – Set tolerance for minimum distance between two nodes. The unit is the same as that of the watershed’s CRS. The default is 1.
meshpy.triangle.build() (Additional keyword arguments include all options for)
Condition#
- watershed_workflow.condition.burnInRiver(river: River, network_burn_in_depth: float | Dict[int, float] | Callable[[River], float]) None [source]#
Reduce reach elevations by a float or function.
- watershed_workflow.condition.conditionRiverMesh(m2: Mesh2D, river: River, smooth: bool = False, use_parent: bool = False, lower: bool = False, bank_integrity_elevation: float = 0.0, depress_headwaters_by: float | None = None, network_burn_in_depth: float | Dict[int, float] | Callable[[River], float] | None = None, known_depressions: List[int] | None = None) None [source]#
Condition, IN PLACE, the elevations of stream-corridor elements to ensure connectivity throgh culverts, skips ponds, maintain monotonicity, or otherwise enforce depths of constructed channels.
- m2: watershed_workflow.mesh.Mesh2D object
2D mesh with 3D coordinates.
- river: watershed_workflow.river_tree.River object
River tree with reach[‘elems’] added for quads
- smooth: boolean, optional
If true, smooth the profile of each reach using a gaussian filter (mainly to pass through railroads and avoid reservoirs).
- lower: boolean, optional
If true, lower the smoothed bed profile to match the lower points on the raw bed profile. This is useful particularly for narrow ag. ditches where NHDPLus flowlines often do not coincide with the DEM depressions and so stream-elements intermitently fall into them.
- bank_integrity_elevation: float, optional
Where the river is passing right next to the reservoir or NHDline is misplaced into the reservoir, banks may fall into the reservoir. If true, this will enforce that the bank vertex is at a higher elevation than the stream bed elevation.
- depress_headwaters_by: float, optional
If the depression is not captured well in the DEM, the river-mesh elements (streambed) headwater reaches may be lowered by this number. The effect is propogated downstream only up to where it is needed to maintain topographic gradients on the network scale in the network sweep step.
- network_burn_in_depth: float, dict, or function
Like depress_headwaters_by, this also lowers river-mesh elements by this value, but this variant lowers all reaches. The depth may be provided as a float (uniform lowering), dictionary {stream order : depth to depress by}, or as a function of drainage area.
- known_depressions: list, optional
If provided, a list of IDs to not be burned in via the network sweep.
- watershed_workflow.condition.conditionRiverMeshes(m2: Mesh2D, rivers: List[River], *args, **kwargs) None [source]#
For multiple rivers, condition, IN PLACE, the elevations of stream-corridor elements to ensure connectivity throgh culverts, skips ponds, maintain monotonicity, or otherwise enforce depths of constructed channels.
- watershed_workflow.condition.distributeProfileToMesh(m2: Mesh2D, river: River) None [source]#
Take reach profile elevations and move them out to the mesh vertices.
- watershed_workflow.condition.enforceBankIntegrity(m2: Mesh2D, river: River, bank_integrity_elevation: float) None [source]#
Forces banks at least bank_integrity_elevation higher than the channel elevation.
- watershed_workflow.condition.enforceLocalMonotonicity(reach: River, moving: Literal['downstream', 'upstream'] = 'downstream') None [source]#
Ensures that the streambed-profile elevations are monotonically increasing as we move upstream, or decreasing as we move downstream.
- watershed_workflow.condition.enforceMonotonicity(river: River, depress_headwaters_by: float | None = None, known_depressions: List[int] | None = None) None [source]#
Sweep the river network from each headwater reach (leaf node) to the watershed outlet (root node), removing aritificial obstructions in the river mesh and enforcing depths of constructed channels.
- watershed_workflow.condition.fillPits(m2: Mesh2D, outletID: int | None = None, algorithm: int = 3) None [source]#
Conditions a mesh, IN PLACE, by removing pits.
Starts at outlet and works through all coordinates in the mesh, ensuring that there is a path to all vertices of the mesh from the outlet that monotonically increases in elevation.
- Available algorithms (likely all should be equivalent):
1: original, 2-pass algorithm 2: refactored single-pass algorithm based on sorted lists 3: boundary marching method. Should be the fastest.
- Parameters:
m2 (mesh.Mesh2D object) – The mesh to condition.
outletID (int, optional) – If provided, the ID of the point to start conditioning from. If not provided, will use the boundary vertex with minimal elevation.
algorithm (int) – See above, defaults to 3.
- watershed_workflow.condition.fillPits1(points: Dict[int, _Point], outletID: int) None [source]#
This is the origional, 2-pass algorithm, and is likely inefficient.
- watershed_workflow.condition.fillPits2(points: Dict[int, _Point], outletID: int) None [source]#
This is a refactored, single pass algorithm that leverages a sorted list.
- watershed_workflow.condition.fillPits3(points: Dict[int, _Point], outletID: int) None [source]#
This algorithm is based on a boundary marching method
- watershed_workflow.condition.fillPitsDual(m2: Mesh2D, is_waterbody: ndarray | None = None, outlet_edge: Tuple[int, int] | None = None, eps: float = 0.001) None [source]#
Conditions the dual of the mesh, IN PLACE, by filling pits.
This ensures the property that, starting with an outlet cell, there is a path to every cell by way of faces that is monotonically increasing in elevation (except in cells which are a part of waterbodies).
- Parameters:
m2 (mesh.Mesh2D object) – The mesh to condition.
is_waterbody (np.ndarray(int, shape=ncells), optional) – A boolean/integer mask of length m2.num_cells, with True values indicating that the given cell is a part of a waterbody that may be a depression. This is important for reservoirs/lakes/etc where bathymetry is known and pits are physical.
outlet_edge ((int,int), optional) – If provided, the point to start conditioning from. If not provided, will use the edge on the boundary of m2 with the lowest elevation.
eps (float, optional=1e-3) – A small vertical displacement for soft tolerances.
- watershed_workflow.condition.identifyLocalMinima(m2: Mesh2D) ndarray [source]#
For all cells, identify if their centroid elevation is lower than the elevation of all neighbors.
- Parameters:
m2 (mesh.Mesh2D object) – The mesh to check.
- Returns:
Array of 0s and 1s, where 1 indicates a local minima.
- Return type:
np.array
Regions#
This namespace hosts functions to add labelsets to define regions
- watershed_workflow.regions.addPolygonalRegions(m2: Mesh2D, polygons: SplitHUCs | List[Tuple[Polygon, str]], volume: bool = False) List[List[int]] [source]#
Label m2 with region(s) for each polygon.
Always adds a surface region; if volume also adds a volume region for extrusion in 3D.
- Parameters:
m2 (mesh.Mesh2D) – The mesh to label.
polygons (SplitHUCs | List[shapely.Polygon]) – The polygons covering each watershed.
volume (bool, optional) – If true, also add the volumetric region below the polygon that will be extruded in a 3D mesh eventually.
- Returns:
partitions – A list of length polygons, each entry of which is the list of cell indices in that polygon.
- Return type:
List[List[int]]
- watershed_workflow.regions.addReachIDRegions(m2: Mesh2D, river: River)[source]#
Add labeled sets to m2 for reaches of each stream order .
Parameters:#
- m2: Mesh2D
2D mesh elevated on DEMs
- river: watershed_workflow.river_tree.RiverTree
List of rivers used to create the river corridors.
- reaches: list(str)
list of NHDID IDs to be labeled.
- watershed_workflow.regions.addRiverCorridorRegions(m2: Mesh2D, rivers: List[River], labels: List[str] | None = None)[source]#
Add labeled sets to m2 for each river corridor.
Parameters:#
- m2: Mesh2D
2D mesh elevated on DEMs
- rivers: list(watershed_workflow.river_tree.RiverTree)
List of rivers used to create the river corridors.
- labels: list(str), optional
List of names, one per river.
- watershed_workflow.regions.addStreamOrderRegions(m2: Mesh2D, rivers: List[River]) None [source]#
Add labeled sets to m2 for reaches of each stream order .
Parameters:#
- m2: Mesh2D
2D mesh elevated on DEMs
- riversList[watershed_workflow.river_tree.River]
River used to create the river corridors.
- watershed_workflow.regions.addSurfaceRegions(m2: Mesh2D, column: str = 'land_cover', names: dict[int, str] | None = None)[source]#
Add labeled sets to a mesh – one per unique color.
- Parameters:
m2 (mesh.Mesh2D) – The mesh to label.
names (dict, optional) – Dictionary mapping colors to color name.
- watershed_workflow.regions.addWatershedAndOutletRegions(m2: Mesh2D, hucs: SplitHUCs, outlet_width: float = 300, exterior_outlet=True)[source]#
Add four labeled sets to m2 for each polygon:
cells in the polygon, to be extruded
cells in the polygon, to be kept as faces upon extrusion
boundary of the polygon (edges, kept as faces)
outlet of the polygon (edges, kept as faces, within outlet width of the outlet)
- Parameters:
m2 (mesh.Mesh2D) – The mesh to label.
hucs (iterable[shapely.Polygon] or SplitHUCs) – Watershed polygons.
outlet_width (float, optional) – How wide should the outlet region be? Note this should include not just the river width, but more realistically the best resolved floodplain, or 1-2 face-widths, whichever is bigger.
exterior_outlet (bool, optional) – If true, find the outlet point that intersects the boundary and include regions around that outlet as well.