Skip to content

Commit

Permalink
Make separate function for mask generation
Browse files Browse the repository at this point in the history
  • Loading branch information
NoraLoose committed Nov 4, 2024
1 parent 6ee18cc commit 9445437
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions roms_tools/setup/topography.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ def _add_topography_and_mask(
# Mask
if verbose:
start_time = time.time()
# Mask is obtained by finding locations where ocean depth is positive
mask = xr.where(hraw > 0, 1.0, 0.0)

mask = _infer_mask(hraw)
# fill enclosed basins with land
mask = _fill_enclosed_basins(mask.values)
# adjust mask boundaries by copying values from adjacent cells
Expand Down Expand Up @@ -151,6 +151,14 @@ def _make_raw_topography(data, target_coords, verbose) -> np.ndarray:
return hraw


def _infer_mask(hraw):
"""Mask is obtained by finding locations where ocean depth is positive."""

mask = xr.where(hraw > 0, 1.0, 0.0)

return mask


def _smooth_topography_globally(hraw, factor) -> xr.DataArray:
# since GCM-Filters assumes periodic domain, we extend the domain by one grid cell in each dimension
# and set that margin to land
Expand Down

0 comments on commit 9445437

Please sign in to comment.