diff --git a/src/anemoi/datasets/create/functions/sources/xarray/coordinates.py b/src/anemoi/datasets/create/functions/sources/xarray/coordinates.py index 8e92b0e6..f08a00f7 100644 --- a/src/anemoi/datasets/create/functions/sources/xarray/coordinates.py +++ b/src/anemoi/datasets/create/functions/sources/xarray/coordinates.py @@ -30,7 +30,7 @@ def extract_single_value(variable): if np.issubdtype(variable.values.dtype, np.datetime64): if len(shape) == 0: return to_datetime(variable.values) # Convert to python datetime - assert False, (shape, variable.values) + assert False, (shape, variable.values[:2]) if np.issubdtype(variable.values.dtype, np.timedelta64): if len(shape) == 0: diff --git a/src/anemoi/datasets/create/functions/sources/xarray/metadata.py b/src/anemoi/datasets/create/functions/sources/xarray/metadata.py index 471fc6bc..877045b8 100644 --- a/src/anemoi/datasets/create/functions/sources/xarray/metadata.py +++ b/src/anemoi/datasets/create/functions/sources/xarray/metadata.py @@ -100,7 +100,9 @@ def _get(self, key, **kwargs): else: return kwargs.get("default", None) - key = self._mapping.from_user(key) + if self._mapping is not None: + key = self._mapping.from_user(key) + return super()._get(key, **kwargs) diff --git a/src/anemoi/datasets/create/functions/sources/xarray/time.py b/src/anemoi/datasets/create/functions/sources/xarray/time.py index eb2e2eaa..65c97165 100644 --- a/src/anemoi/datasets/create/functions/sources/xarray/time.py +++ b/src/anemoi/datasets/create/functions/sources/xarray/time.py @@ -91,8 +91,8 @@ def __init__(self, date_coordinate, step_coordinate): self.step_coordinate = step_coordinate def fill_time_metadata(self, time, metadata): - metadata["date"] = self.date_coordinate.single_value.strftime("%Y%m%d") - metadata["time"] = self.date_coordinate.single_value.strftime("%H%M") - hours = self.step_coordinate.total_seconds() / 3600 + metadata["date"] = time.strftime("%Y%m%d") + metadata["time"] = time.strftime("%H%M") + hours = metadata[self.step_coordinate.name].total_seconds() / 3600 assert int(hours) == hours metadata["step"] = int(hours)