Skip to content

Commit

Permalink
Time dimension attributes added to set_ds_time
Browse files Browse the repository at this point in the history
  • Loading branch information
bdestombe committed Oct 19, 2023
1 parent 7b72aec commit 6ed4225
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions nlmod/dims/attributes_encodings.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import numpy as np

dim_attrs = {
"time": dict(
name="Time",
description="End time of the stress period",
),
"botm": dict(
name="Bottom elevation",
description="Bottom elevation for each model cell",
Expand Down
5 changes: 4 additions & 1 deletion nlmod/dims/time.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import xarray as xr
from xarray import IndexVariable

from attributes_encodings import dim_attrs

logger = logging.getLogger(__name__)


Expand Down Expand Up @@ -168,7 +170,7 @@ def set_ds_time(
----------
ds : xarray.Dataset
model dataset
start : int, float, str or pandas.Timestamp, optional
start : int, float, str or pandas.Timestamp
model start. When start is an integer or float it is interpreted as the number
of days of the first stress-period. When start is a string or pandas Timestamp
it is the start datetime of the simulation.
Expand Down Expand Up @@ -250,6 +252,7 @@ def set_ds_time(
raise ValueError(msg)

ds = ds.assign_coords(coords={"time": time})
ds.coords["time"].attrs = dim_attrs["time"]

# add steady, nstp and tsmult to dataset
if isinstance(steady, bool):
Expand Down

0 comments on commit 6ed4225

Please sign in to comment.