From 8901a1fde91ed2d21b0cc50a4adf11f40bdaf7d9 Mon Sep 17 00:00:00 2001 From: Daniel Wiesmann Date: Fri, 7 Feb 2025 13:41:19 +0000 Subject: [PATCH] Fix grouping operation --- scripts/groups.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/groups.py b/scripts/groups.py index 437767f..105b223 100644 --- a/scripts/groups.py +++ b/scripts/groups.py @@ -17,8 +17,8 @@ def rotate_group(): data = xr.open_zarr("data/sea_bass_average_with_shift.zarr") rotated = rotate_data(data.rename_dims({"quarter": "time"})) rotated = rotated.rename_dims({"time": "quarter"}) - rotated.to_zarr("data/sea_bass_average.zarr", mode="w") + rotated.to_zarr("data/sea_bass_average.zarr", mode="w") store = get_filesystem().get_mapper( "s3://destine-gfts-visualisation-data/groups/sea_bass_average.zarr" ) @@ -45,7 +45,12 @@ def create_groups(): if result is None: result = avg_by_quarter else: - result += avg_by_quarter + # Combine both datasets and sum by quarter + result = xr.concat( + [avg_by_quarter, result], + dim="quarter", + ) + result = result.groupby("quarter").sum("quarter") result = result.fillna(0) result = result.compute()