From c21275fd962ec7fbf48ec28c70b422a5bb37da11 Mon Sep 17 00:00:00 2001 From: Ag Stephens Date: Mon, 6 Sep 2021 09:50:23 +0000 Subject: [PATCH] Modified use of `ds.mean()` to overcome dask error: - Error was: NotImplementedError: Computing the mean of an array containing cftime.datetime objects is not yet implemented on dask arrays - Solution was to force loading of the Dataset, with `ds.load().mean()` - See: https://github.com/roocs/clisops/issues/185 --- clisops/core/average.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/clisops/core/average.py b/clisops/core/average.py index e3d9d4ba..5ca8ccb5 100644 --- a/clisops/core/average.py +++ b/clisops/core/average.py @@ -176,6 +176,11 @@ def average_over_dims( # The mean will be carried out on a Dataset or DataArray # Calculate the mean, skip missing values and retain original attributes - ds_averaged_over_dims = ds.mean(dim=dims_to_average, skipna=True, keep_attrs=True) + + # Short-term solution to error: "NotImplementedError: Computing the mean of an " ... + # "array containing cftime.datetime objects is not yet implemented on dask arrays." + # See GITHUB ISSUE: https://github.com/roocs/clisops/issues/185 + # The fix is simply to force `ds.load()` before processing + ds_averaged_over_dims = ds.load().mean(dim=dims_to_average, skipna=True, keep_attrs=True) return ds_averaged_over_dims