When I run these commands in python2.7 with iris 2.1 and numpy 1.15, I get the error messages in traceback below.
----------------
PYTHON commands:
import iris
cube = iris.load_cube('example.nc')
#check to see if the data is there:
cube.data
cube = cube.aggregated_by(["year", "day_of_year"], iris.analysis.MEAN, mdtol=0.03)
----------------
The 20MB example.nc NETCDF file is available here:
https://drive.google.com/open?id=1hZNWXs7wOtBq2dXWM1zbAJnVMjy_DXc7
-----------------
Traceback (most recent call last):
File "test10.py", line 10, in <module>
cube = cube.aggregated_by(["year", "day_of_year"], iris.analysis.MEAN, mdtol=0.03)
File "/Users/pmcguire/fluxnet1/iris/cube.py", line 3414, in aggregated_by
**kwargs)
File "/Users/pmcguire/fluxnet1/iris/analysis/__init__.py", line 524, in aggregate
result.mask = result.mask | mask_update
File "/Users/pmcguire/.local/lib/python2.7/site-packages/numpy/ma/core.py", line 6339, in __setattr__
"attributes of {!r} are not writeable".format(self))
AttributeError: attributes of masked are not writeable
-------------------
I have tracked this down I think.
result = self.call_func(data, axis=axis, **kwargs)
if (mdtol is not None and ma.isMaskedArray(data)):
fraction_not_missing = data.count(axis=axis) / data.shape[axis]
mask_update = 1 - mdtol > fraction_not_missing
#if ma.isMaskedArray(result):
# result.mask = result.mask | mask_update
#else:
result = ma.array(result, mask=mask_update)
In version Iris1.13, this problem does not exist.
I can reproduce this problem if I upgrade from Iris1.13 to Iris2.2.0dev0, including all dependencies.
masked constant now error, as the underlying arrays are marked readonly. In the past, it was possible to get away with...".