Skip to content

Commit

Permalink
Merge pull request #337 from gwmod/cache-small-change
Browse files Browse the repository at this point in the history
Small change to cache
  • Loading branch information
OnnoEbbens committed Apr 19, 2024
2 parents 68ee919 + c41f7af commit 98392f9
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions nlmod/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,7 @@ def ds_contains(ds, coords_2d=False, coords_3d=False, coords_time=False, datavar
if coords_2d or coords_3d:
coords.append("x")
coords.append("y")
datavars.append("area")
attrs.append("extent")

if "gridtype" in ds.attrs:
Expand All @@ -649,16 +650,16 @@ def ds_contains(ds, coords_2d=False, coords_3d=False, coords_time=False, datavar
attrs.append("time_units")

# User-friendly error messages
if "northsea" in datavars and "northsea" not in ds.datavars:
if "northsea" in datavars and "northsea" not in ds.data_vars:
raise ValueError("Northsea not in dataset. Run nlmod.read.rws.add_northsea() first.")

if "time" in coords and "time" not in ds.coords:
raise ValueError("time not in dataset. Run nlmod.time.set_ds_time() first.")

# User-unfriendly error messages
for datavar in datavars:
if datavar not in ds.datavars:
raise ValueError(f"{datavar} not in dataset.datavars")
if datavar not in ds.data_vars:
raise ValueError(f"{datavar} not in dataset.data_vars")

for coord in coords:
if coord not in ds.coords:
Expand Down

0 comments on commit 98392f9

Please sign in to comment.