WaterMask#
- class fridom.framework.grid.water_mask.WaterMask[source]#
Bases:
objectWater mask for the grid cells (for boundary conditions).
Description#
Let’s consider the following staggered grid with periodic boundaries:
-----e---------e---------e----- | | | | | x o x o x o | | | | -----e---------e---------e----- | | | | | (x) o (x) o x o | | | | -----e---------e---------e----- | | | | | (x) o x o x o | | | | -------------------------------
where x represents the cell center and o and e represent the cell faces. Grid cells denoted with (x) are the cells with land. The water mask is a boolean array that indicates whether a cell is water (1) or land (0). For the above grid, the water masks would be:
[1, 1, 1] [1, 1, 1] [0, 1, 1] x = [0, 0, 1] o = [0, 0, 0] e = [0, 0, 1] [0, 1, 1] [0, 1, 0] [0, 0, 1]
Methods
__init__()create_mask_at_position(position)Create a water mask at the given position.
get_mask(position)Get the water mask at the given position.
setup(mset)shift_mask_along_axis(mask, axis, axpos)Shift the mask along the given axis to the new position.
Attributes
Get the water mask.
- setup(mset: ModelSettingsBase) None[source]#
- create_mask_at_position(position: Position) ndarray[source]#
Create a water mask at the given position.
- shift_mask_along_axis(mask: ndarray, axis: int, axpos: AxisPosition) ndarray[source]#
Shift the mask along the given axis to the new position.
Description#
Let’s say we have a mask given at the cell centers, denoted with x below. And we want to shift the mask to the right, denoted with | below. The overline represents the position of land in the mask.
_______ _______ x | x | x | x | x | x |
Hence the water mask would be:
[0, 1, 1, 0, 1, 1]
The new mask at the right position is only water if both neighboring cells are water. Hence the new mask at the right cell faces would be:
[0, 1, 0, 0, 1, ?]
where ? depends on the neighboring cells. To find the new mask algorithmically, we first determine the left and right cell centers of the corresponding cell face. And then we check if both neighboring cells are water by multiplying the left and right cell centers. Finally we synchronize the mask across the processors and fill the halo cells with land.
Parameters#
- maskndarray
The mask to shift (located at the center at the given axis)
- axisint
The axis along which the mask should be shifted
- axposfr.grid.AxisPosition
The new position of the mask along the axis
- property water_mask: ndarray#
Get the water mask.