Skip to content
Closed
Changes from 3 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
16 changes: 14 additions & 2 deletions fine/aggregations/spatialAggregation/aggregation.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,8 +435,20 @@ def _get_aggregation_mode(varname, comp=None, comp_ds=None):

return aggregation_mode, aggregation_weight

# Make a copy of xarray_dataset
aggregated_xr_dataset = deepcopy(xarray_datasets)
# Build output dict explicitly to avoid deepcopy of Shapely object-dtype arrays
# (which causes RecursionError in newer xarray versions).
# Only "Parameters".attrs needs a real deep copy — it contains mutable Python
# objects (set, pd.DataFrame) that are modified in-place below.
# "Geometry" and "Input" are fully replaced further down, so no copy is needed.
parameters_copy = xarray_datasets.get("Parameters").copy()
parameters_copy.attrs = deepcopy(xarray_datasets.get("Parameters").attrs)
aggregated_xr_dataset = {
"Parameters": parameters_copy,
"Input": {
comp_class: dict(comp_dict)
for comp_class, comp_dict in xarray_datasets.get("Input").items()
},
}

# update esM Parameters
parameters_dict = aggregated_xr_dataset.get("Parameters").attrs
Expand Down
Loading