pygetm.rivers module
- class pygetm.rivers.GlobalRiver(name: str, x: int | float, y: int | float, coordinate_type: CoordinateType = CoordinateType.IJ, **attrs)[source]
Bases:
objectSingle river in the global domain.
- Parameters:
name – unique name for this river
x – x coordinate of river
y – y coordinate of river
coordinate_type – coordinate type of x and y (LONLAT spherical, XY for Cartesian coordinates)
**attrs – additional attributes for this river
- locate(locator: Locator)[source]
If this river position is specified by (lon, lat) or (x, y), map it to the nearest non-masked grid cell.
- to_local_grid(grid: Grid) LocalRiver | None[source]
Map river to local subdomain.
- Parameters:
grid – local grid
- Returns:
local river instance, or None if the river falls outside the local subdomain
- class pygetm.rivers.GlobalRiverCollection(nx: int, ny: int, default_coordinate_type: CoordinateType, logger: Logger)[source]
Bases:
Mapping[str,GlobalRiver]Collection of rivers in the global domain.
It acts as a mapping from river names to
GlobalRiverinstances.- add_by_index(name: str, i: int, j: int, **kwargs) GlobalRiver[source]
Add a river at a location specified by the indices of a tracer point
- Parameters:
name – river name
i – global domain index in x-direction (0-based)
j – global domain index in y-direction (0-based)
**kwargs – additional keyword arguments passed to
add_by_location()
- Returns:
river instance
- add_by_location(name: str, x: int | float, y: int | float, coordinate_type: CoordinateType | None = None, zl: float | None = None, zu: float | None = None, vertical_position: VerticalPosition = VerticalPosition.DistanceFromSurface, **attrs) GlobalRiver[source]
Add a river at a location specified by the nearest coordinates.
By default, the river will spread over the entire water column. Distance limits zl and zu can be specified to control the vertical extent of river penetration. They can be identical, in which case the river will only affect a single layer. For instance, use zl=zu=0.0 to have the river enter the surface layer, or zl=zu=0.0 with
vertical_position=VerticalPosition.DistanceFromBottomto have the river enter the bottom layer. If zu and/or zl exceed the current water depth, they will be clipped to that water depth.- Parameters:
name – river name
x – x coordinate of river
y – y coordinate of river
coordinate_type – coordinate type of x and y (
CoordinateType.LONLATfor spherical,CoordinateType.XYfor Cartesian coordinates,CoordinateType.IJfor 0-based indices into the global tracer grid). If not provided, the default coordinate type of the domain will be used.zl – lower limit (deepest point) of river penetration (m; >=0). This is the distance from the surface or bottom, depending on vertical_position. Its default value corresponds to the position of the bottom.
zu – upper limit of river penetration (m; >=0). This is the distance from the surface or bottom, depending on vertical_position. Its default value corresponds to the position of the water surface.
vertical_position – whether depth limits zl and zu are distances from the surface or from the bottom. If set to
VerticalPosition.DistanceFromSurface, then zl must be >= zu. If set toVerticalPosition.DistanceFromBottom, then zl must be <= zu.**attrs – additional attributes for this river
- Returns:
river instance
- initialize(grid: Grid) LocalRiverCollection[source]
Return a collection of only those rivers that fall within the local subdomain.
- class pygetm.rivers.LocalRiver(grid: Grid, name: str, i: int, j: int, zl: float, zu: float, vertical_position: VerticalPosition, **attrs)[source]
Bases:
Mapping[str,RiverTracer]Single river in the local subdomain.
It acts as a mapping from tracer names to
RiverTracerinstances, allowing you to access and control the value of each tracer in this river.
- class pygetm.rivers.LocalRiverCollection(grid: Grid, rivers: Iterable[LocalRiver], logger: Logger)[source]
Bases:
Mapping[str,LocalRiver]Collection of rivers that fall within the local subdomain.
It acts as a mapping from river names to
LocalRiverinstances
- class pygetm.rivers.RiverTracer(grid: Grid, river_name: str, tracer_name: str, value: ndarray, follow: ndarray, **kwargs)[source]
Bases:
ArraySingle tracer in a single river.
Call
pygetm.core.Array.set()on this object to prescribe the tracer value in the river, or set thefollow_target_cellattribute to True to take the river’s tracer value from the model cell it flows into.If you prescribe the tracer value, the
follow_target_cellattribute will automatically be set to False.If you do not prescribe the tracer value and
follow_target_cellis False, the tracer value will default to 0.0.