Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Landsea mask generation: add PCMDI method as an option #1063

Merged
merged 7 commits into from
Feb 29, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
clean up
  • Loading branch information
lee1043 committed Feb 28, 2024
commit 816eee8c0a78af7c3e5dfd3f3b9fe894f3f154ba
12 changes: 7 additions & 5 deletions pcmdi_metrics/utils/create_land_sea_mask.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,17 @@ def create_land_sea_mask(
# Mask the land-sea mask to match the dataset's coordinates
land_sea_mask = land_mask.mask(lon, lat=lat)

if not as_boolean:
# Convert the land-sea mask to a boolean mask
land_sea_mask = xr.where(land_sea_mask, 0, 1)

elif method.lower() == "pcmdi":
# Use the PCMDI method developed by Taylor and Doutriaux (2000)
land_sea_mask = generate_land_sea_mask__pcmdi(obj)
else:
raise ValueError("Unknown method '%s'. Please choose 'regionmask' or 'pcmdi'")

if not as_boolean:
# Convert the land-sea mask to a boolean mask
land_sea_mask = xr.where(land_sea_mask, 0, 1)


return land_sea_mask

Expand Down Expand Up @@ -363,9 +365,9 @@ def generate_land_sea_mask__pcmdi(
mask = mask.rename(maskname)

# Reverse the values (0 to 1 and 1 to 0)
reversed_mask = xr.where(mask == 0, 1, 0)
#mask = xr.where(mask == 0, 1, 0)

return reversed_mask
return mask


def _create_surrounds(ds, data_var="sftlf", debug=False):
Expand Down
Loading