Skip to content

Commit

Permalink
Fix: dimension_labels return list, datetimes are ISO formatted
Browse files Browse the repository at this point in the history
  • Loading branch information
m-mohr authored Jan 3, 2024
1 parent 4a011c4 commit 03037f9
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions openeo_processes_dask/process_implementations/cubes/general.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from typing import Optional

import numpy as np
import xarray as xr
from numpy.typing import ArrayLike
from openeo_pg_parser_networkx.pg_schema import *

from openeo_processes_dask.process_implementations.data_model import RasterCube
Expand Down Expand Up @@ -28,12 +30,17 @@ def create_raster_cube() -> RasterCube:
return xr.DataArray()


def dimension_labels(data: RasterCube, dimension: str) -> RasterCube:
def dimension_labels(data: RasterCube, dimension: str) -> ArrayLike:
if dimension not in data.dims:
raise DimensionNotAvailable(
f"Provided dimension ({dimension}) not found in data.dims: {data.dims}"
)
return data.coords[dimension]

coords = data.coords[dimension]
if np.issubdtype(coords.dtype, np.datetime64):
return np.datetime_as_string(coords, timezone="UTC")
else:
return np.array(data.coords[dimension])


def add_dimension(
Expand Down

0 comments on commit 03037f9

Please sign in to comment.