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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Prev Previous commit
Next Next commit
fix as_boolen option for the pcmdi method
  • Loading branch information
lee1043 committed Feb 28, 2024
commit 1259bf029c7216fc6cd28aa67a75da3447a78fdf
13 changes: 6 additions & 7 deletions pcmdi_metrics/utils/create_land_sea_mask.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,21 +77,20 @@ def create_land_sea_mask(
land_sea_mask = land_mask.mask(lon, lat=lat)

if not as_boolean:
# Convert the land-sea mask to a boolean mask
# Convert the boolean land-sea mask to a 0/1 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)

if as_boolean:
land_sea_mask = xr.where(land_sea_mask==1, True, False)

# Convert the 0/1 land-sea mask to a boolean mask
land_sea_mask = xr.where(land_sea_mask == 1, True, False)

else:
raise ValueError("Unknown method '%s'. Please choose 'regionmask' or 'pcmdi'")



return land_sea_mask


Expand Down Expand Up @@ -369,7 +368,7 @@ def generate_land_sea_mask__pcmdi(
mask = mask.rename(maskname)

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

return mask

Expand Down