Grids¶
Grids define where a model computes. Model plugins subclass BaseGrid for their own grid types.
BaseGrid
pydantic-model
¶
BaseGrid(**data: Any)
Bases: RompyBaseModel
Representation of a grid in geographic space.
This is the base class for all Grid objects. The minimum representation of a grid are two NumPy array's representing the vertices or nodes of some structured or unstructured grid, its bounding box and a boundary polygon. No knowledge of the grid connectivity is expected.
Fields:
bbox
¶
bbox(buffer=0.0) -> Bbox
Returns a bounding box for the spatial grid
This function returns a list [ll_x, ll_y, ur_x, ur_y] where ll_x, ll_y (ur_x, ur_y) are the lower left (upper right) x and y coordinates bounding box of the model domain
boundary
¶
Returns the convex hull boundary polygon from the grid.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tolerance
|
Simplify polygon shape based on maximum distance from original geometry, see https://shapely.readthedocs.io/en/stable/manual.html#object.simplify. |
0.2
|
Returns:
| Name | Type | Description |
|---|---|---|
polygon |
Polygon
|
See https://shapely.readthedocs.io/en/stable/manual.html#Polygon |
boundary_points
¶
boundary_points(spacing=None, tolerance=0.2) -> tuple
Returns array of coordinates from boundary polygon.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tolerance
|
Simplify polygon shape based on maximum distance from original geometry, see https://shapely.readthedocs.io/en/stable/manual.html#object.simplify. |
0.2
|
|
spacing
|
If specified, points are returned evenly spaced along the boundary at the specified spacing, otherwise all points are returned. |
None
|
Returns:
points: tuple Tuple of x and y coordinates of the boundary points.
plot
¶
Plot the grid
check_for_typos
classmethod
¶
Suggest the closest field name for an unknown input key.
A field can be given by its name or, like in pydantic, by its alias.
RegularGrid
pydantic-model
¶
RegularGrid(**data: Any)
Bases: BaseGrid
Regular grid in geographic space.
This object provides an abstract representation of a regular grid in some geographic space.
Fields:
-
grid_type(Literal['regular']) -
x0(Optional[float]) -
y0(Optional[float]) -
rot(Optional[float]) -
dx(Optional[float]) -
dy(Optional[float]) -
nx(Optional[int]) -
ny(Optional[int])
Validators:
grid_type
pydantic-field
¶
grid_type: Literal['regular'] = 'regular'
Type of grid, must be 'regular'
generate
pydantic-validator
¶
generate() -> RegularGrid
Generate the grid from the provided parameters.
check_for_typos
classmethod
¶
Suggest the closest field name for an unknown input key.
A field can be given by its name or, like in pydantic, by its alias.
bbox
¶
bbox(buffer=0.0) -> Bbox
Returns a bounding box for the spatial grid
This function returns a list [ll_x, ll_y, ur_x, ur_y] where ll_x, ll_y (ur_x, ur_y) are the lower left (upper right) x and y coordinates bounding box of the model domain
boundary
¶
Returns the convex hull boundary polygon from the grid.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tolerance
|
Simplify polygon shape based on maximum distance from original geometry, see https://shapely.readthedocs.io/en/stable/manual.html#object.simplify. |
0.2
|
Returns:
| Name | Type | Description |
|---|---|---|
polygon |
Polygon
|
See https://shapely.readthedocs.io/en/stable/manual.html#Polygon |
boundary_points
¶
boundary_points(spacing=None, tolerance=0.2) -> tuple
Returns array of coordinates from boundary polygon.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tolerance
|
Simplify polygon shape based on maximum distance from original geometry, see https://shapely.readthedocs.io/en/stable/manual.html#object.simplify. |
0.2
|
|
spacing
|
If specified, points are returned evenly spaced along the boundary at the specified spacing, otherwise all points are returned. |
None
|
Returns:
points: tuple Tuple of x and y coordinates of the boundary points.
plot
¶
Plot the grid