-
Notifications
You must be signed in to change notification settings - Fork 283
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
problem with aggregated_by and mdtol and masks with iris2.1 and numpy1.15 #3190
Comments
Hi @mcguirepatr - thanks for raising this issue report! As it happens I was just looking at your post on Google Groups; apologies that no-one has responded to your post there as yet. I've successfully reproduced the issue you report here, and I think you're spot on in looking at NumPy as the cause of this issue, so we'll try and dig in and see if we can get a fix in place. In fact, your note about removing the mask update lines is very helpful for pointing towards a fix for this as it points to what the origins of the problem likely are. There are two:
By the way, you don't need to call P.S. I edited your initial post as there was some odd styling going on. |
This is explained by #3129. |
Thanks for your help with this, Mr. Killick! |
as supporting info, I confirm that the example given appears CORRECTLY in OSGeoLive 12.0
Ubuntu 1804; Python 2.7; iris_3190_bug_example.nc 21MB |
I'm also having this problem on the same system as Patrick - I think it's happening when one or more of the elements are masked after applying the aggregating function but before using mdtol. Is there a work-around? Thanks! Example 1:
Example 2:
|
This is what I've come up with so far as a work-around for Patrick's original example but it's pretty convoluted - there must be a better way! :)
|
I've reproduced the errors from @mcguirepatr's and @kwilliams-mo's examples with latest master branch (almost v3). However, I note that the problem goes away if the cube's input data is lazy (lazy aggregated_by was introduced at Iris v2.4). So one way to fix this would be to implement #2418. |
This is now fixed ready for Iris v3.3 (due out in the summer). Sorry it took so long and thanks for your efforts in digging into the problem @mcguirepatr and @kwilliams-mo! |
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:
The 20MB example.nc NETCDF file is available here:
https://drive.google.com/open?id=1hZNWXs7wOtBq2dXWM1zbAJnVMjy_DXc7
I have tracked this down I think.
I could get test_fluxnet_evaluation.py to work if I comment out the three lines below from the _Aggregator(object).aggregate method in iris/analysis/init.py (near line 514) of a copy of iris2.1.
The result.mask below was not defined for some reason even though ma.isMaskedArray(result) is true.
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.
But then when I downgrade only Iris2.2 -> Iris.1.13, keeping the updated dependencies, the bug persists.
But then when I downgrade only Iris2.2 -> Iris.1.13 and numpy1.15->numpy1.12.1, keeping the updated dependencies, the bug goes away.
So I think it's something in numpy.
When it works with Iris1.13 and numpy1.12.1, Aggregrate (with iris.analysis.Mean) function tries to override the (non-array) mask value for the day, and it can do this, because the mask is writeable. But when it doesn't work with iris2.1 and numpy1.15, this function fails because this mask is not writeable.
2)A quick perusal of the numpy1.15 documentation suggests that they changed the mask behavior: https://docs.scipy.org/doc/numpy/release.html
"np.ma.masked is no longer writeable:
Attempts to mutate the masked constant now error, as the underlying arrays are marked readonly. In the past, it was possible to get away with...".
I am not sure if this is the change which is affecting us or not.
Can someone fix this problem in iris? Should I just maintain a separate iris branch (with those three lines commented out) for my own purposes till this is fixed? Or does anybody have a better solution? I am not sure if I should downgrade numpy or not.
Thanks,
Patrick McGuire
Department of Meteorology and Department of Geography & Environmental Science
University of Reading
Personal Web Page: http://www.personal.reading.ac.uk/~gn916173
The text was updated successfully, but these errors were encountered: