Skip to content

Commit

Permalink
Modified use of ds.mean() to overcome dask error:
Browse files Browse the repository at this point in the history
- 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: #185
  • Loading branch information
agstephens committed Sep 6, 2021
1 parent d5615f6 commit c21275f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion clisops/core/average.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit c21275f

Please sign in to comment.