xugrid.Ugrid2d.from_structured_bounds#
- static Ugrid2d.from_structured_bounds(x_bounds: ndarray, y_bounds: ndarray, name: str = 'mesh2d', return_index: bool = False) Ugrid2d | Tuple[Ugrid2d, ndarray | slice] [source]#
Create a Ugrid2d topology from a structured topology based on 2D or 3D bounds.
The bounds contain the lower and upper cell boundary for each cell for 2D, and the four corner vertices in case of 3D bounds. The order of the corners in bounds_x and bounds_y must be consistent with each other, but may be arbitrary: this method ensures counterclockwise orientation for UGRID. Inactive cells are assumed to be marked with one or more NaN values for their corner coordinates. These coordinates are discarded and the cells are marked in the optionally returned index.
- Parameters:
x_bounds (np.ndarray of shape (M, 2) or (N, M, 4).) – x-coordinate bounds for N rows and M columns.
y_bounds (np.ndarray of shape (N, 2) or (N, M, 4).) – y-coordinate bounds for N rows and M columns.
name (str)
return_index (bool, default is False.)
- Returns:
grid (Ugrid2d)
index (np.ndarray of bool | slice) – Indicates which cells are part of the Ugrid2d topology. Provided if
return_index
is True.