Skip to content

Commit

Permalink
fix for reading heads using ds when no time has been set
Browse files Browse the repository at this point in the history
- default to float time index
- fix for minor error introduced in #375
  • Loading branch information
dbrakenhoff committed Oct 14, 2024
1 parent 37dc24a commit 84d04db
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion nlmod/mfoutput/mfoutput.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,18 @@ def _get_time_index(fobj, ds=None, gwf_or_gwt=None):
time_units=gwf_or_gwt.modeltime.time_units,
)
elif ds is not None:
if "time" in ds:
dtype = "float" if ds.time.dtype.kind in ["i", "f"] else "datetime"
else:
dtype = "float"
tindex = ds_time_idx(
fobj.get_times(),
start_datetime=(ds.time.attrs["start"] if "time" in ds else None),
time_units=(ds.time.attrs["time_units"] if "time" in ds else None),
dtype="float" if ds.time.dtype.kind in ["i", "f"] else "datetime",
dtype=dtype,
)
else:
raise ValueError("Provide either ds or gwf_or_gwt")
return tindex


Expand Down

0 comments on commit 84d04db

Please sign in to comment.