From 6ed4225f1cf07c640435d9546eda878ba0ccf478 Mon Sep 17 00:00:00 2001 From: Bas des Tombe Date: Thu, 19 Oct 2023 13:02:17 +0200 Subject: [PATCH] Time dimension attributes added to set_ds_time --- nlmod/dims/attributes_encodings.py | 4 ++++ nlmod/dims/time.py | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/nlmod/dims/attributes_encodings.py b/nlmod/dims/attributes_encodings.py index 9857d4d2..449d624b 100644 --- a/nlmod/dims/attributes_encodings.py +++ b/nlmod/dims/attributes_encodings.py @@ -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", diff --git a/nlmod/dims/time.py b/nlmod/dims/time.py index 697b5bbe..c2fdfc47 100644 --- a/nlmod/dims/time.py +++ b/nlmod/dims/time.py @@ -7,6 +7,8 @@ import xarray as xr from xarray import IndexVariable +from attributes_encodings import dim_attrs + logger = logging.getLogger(__name__) @@ -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. @@ -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):