pygetm.rivers module

class pygetm.rivers.GlobalRiver(name: str, x: int | float, y: int | float, coordinate_type: CoordinateType = CoordinateType.IJ, **attrs)[source]

Bases: object

Single 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 GlobalRiver instances.

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.DistanceFromBottom to 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.LONLAT for spherical, CoordinateType.XY for Cartesian coordinates, CoordinateType.IJ for 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 to VerticalPosition.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.

map_to_grid(locator: Locator)[source]

Map rivers to cell centers. This can only be called on MPI nodes that have the full domain (typically the root node only).

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 RiverTracer instances, 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 LocalRiver instances

flag_prescribed_tracers()[source]
get_active_part_of_layers(h: ndarray) → ndarray[source]

For each layer of each river cell, get the part (m) affected by the river

Parameters:

h – layer thicknesses for each river cell (shape: nz x nrivers)

Returns:

nz x nrivers)

Return type:

part of each layer affected by the river (shape

class pygetm.rivers.RiverTracer(grid: Grid, river_name: str, tracer_name: str, value: ndarray, follow: ndarray, **kwargs)[source]

Bases: Array

Single tracer in a single river.

Call pygetm.core.Array.set() on this object to prescribe the tracer value in the river, or set the follow_target_cell attribute 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_cell attribute will automatically be set to False.

If you do not prescribe the tracer value and follow_target_cell is False, the tracer value will default to 0.0.

property follow_target_cell: bool

Whether to take the tracer value in the river from the model cell it flows into.

class pygetm.rivers.VerticalPosition(*values)[source]

Bases: Enum

DistanceFromBottom = 2
DistanceFromSurface = 1