Skip to content

Commit

Permalink
resolve bug (error occuring in case coords does not have axis attribu…
Browse files Browse the repository at this point in the history
…tes)
  • Loading branch information
lee1043 committed Oct 3, 2023
1 parent a0ff612 commit 7328874
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions pcmdi_utils/land_sea_mask.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,10 +472,16 @@ def generate_land_sea_mask__global_land_mask(ds, maskname="lsmask"):
"""

for key in list(ds.coords.keys()):
if key in ["lat", "latitude"] or ds[key].attrs["axis"] == "Y":
if key in ["lat", "latitude"]:
lat_key = key
elif key in ["lon", "longitude"] or ds[key].attrs["axis"] == "X":
elif key in ["lon", "longitude"]:
lon_key = key
else:
if "axis" in list(ds["latitude"].attrs.keys()):
if ds["latitude"].attrs["axis"] == "Y":
lat_key = key
elif ds["latitude"].attrs["axis"] == "X":
lon_key = key

lat = ds[lat_key].to_numpy()
lon = ds[lon_key].to_numpy()
Expand Down

0 comments on commit 7328874

Please sign in to comment.