Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update aggregate_temporal #313

Merged
merged 2 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@ def aggregate_temporal(
f"The data cube contains multiple temporal dimensions: {temporal_dims}. The parameter `dimension` must be specified."
)
t = temporal_dims[0]
if isinstance(intervals, TemporalIntervals) or isinstance(intervals, list):
interval_str = []
for interval in intervals:
if isinstance(interval, TemporalInterval):
interval_0 = str(interval[0].root)
interval_1 = str(interval[1].root)
interval_str.append([interval_0, interval_1])
if interval_str:
intervals = interval_str

intervals_np = (
np.array(intervals, dtype=np.datetime64).astype("datetime64[s]").astype(float)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "openeo-processes-dask"
version = "2024.12.1"
version = "2025.1.1"
description = "Python implementations of many OpenEO processes, dask-friendly by default."
authors = ["Lukas Weidenholzer <[email protected]>", "Sean Hoyal <[email protected]>", "Valentina Hutter <[email protected]>"]
maintainers = ["EODC Staff <[email protected]>"]
Expand Down
34 changes: 31 additions & 3 deletions tests/test_aggregate.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
import pytest
import xarray as xr
import xvec
from openeo_pg_parser_networkx.pg_schema import ParameterReference, TemporalInterval
from openeo_pg_parser_networkx.pg_schema import (
ParameterReference,
TemporalInterval,
TemporalIntervals,
)

from openeo_processes_dask.process_implementations.cubes.aggregate import *
from openeo_processes_dask.process_implementations.cubes.reduce import reduce_dimension
Expand All @@ -27,7 +31,31 @@
],
["half-1", "half-2"],
2,
)
),
(
["2018-01-01T00:00:00", "2019-01-01T00:00:00"],
[
TemporalInterval.model_validate(
["2018-01-01T12:00:00", "2018-06-01T12:00:00"]
),
TemporalInterval.model_validate(
["2018-07-01T12:00:00", "2018-12-01T12:00:00"]
),
],
["half-1", "half-2"],
2,
),
(
["2018-01-01T00:00:00", "2019-01-01T00:00:00"],
TemporalIntervals.model_validate(
[
["2018-01-01T12:00:00", "2018-06-01T12:00:00"],
["2018-07-01T12:00:00", "2018-12-01T12:00:00"],
]
),
["half-1", "half-2"],
2,
),
],
)
def test_aggregate_temporal(
Expand All @@ -43,7 +71,7 @@ def test_aggregate_temporal(
input_cube = create_fake_rastercube(
data=random_raster_data,
spatial_extent=bounding_box,
temporal_extent=TemporalInterval.parse_obj(temporal_extent),
temporal_extent=TemporalInterval.model_validate(temporal_extent),
bands=["B02", "B03", "B04", "B08"],
)

Expand Down