Skip to content

Commit f269cd9

Browse files
Generalising _is_coordinate_in_degrees
By looking at whether a version of "degrees" is present in units. Before this, "degrees_east" was for example not recognised
1 parent 622cf93 commit f269cd9

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

src/parcels/_core/fieldset.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -556,12 +556,11 @@ def _is_agrid(ds: xr.Dataset) -> bool:
556556

557557

558558
def _is_coordinate_in_degrees(da: xr.DataArray) -> bool:
559-
match da.attrs.get("units"):
560-
case None:
561-
raise ValueError(
562-
f"Coordinate {da.name!r} of your dataset has no 'units' attribute - we don't know what the spatial units are."
563-
)
564-
case "degrees":
565-
return True
566-
case _:
567-
return False
559+
units = da.attrs.get("units")
560+
if units is None:
561+
raise ValueError(
562+
f"Coordinate {da.name!r} of your dataset has no 'units' attribute - we don't know what the spatial units are."
563+
)
564+
if isinstance(units, str) and "degree" in units.lower():
565+
return True
566+
return False

0 commit comments

Comments
 (0)