-
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
Improve the exception when attempting to partially collapse a multidimensional coordinate #291
Comments
We've also hit this problem so I'm interested in your solution (and example!). Are you implying we have to remove the auxiliary coordinates before collapsing? Are there any plans for being able to collapse auxiliary coordinates in the future? Thanks |
There is nothing in the pipeline AFAIK.
Yes - |
OK, so in general we could loop over all those auxiliary coordinates with dimensions greater than one and remove them. Sorry, I could check the code, but would I also have to remove derived coordinates? |
It's OK, I've convinced myself you would have to - since the derived coordinate would be derived from one of the auxiliaries! |
Unless all or none the dimensions they span are to be collapsed... I think that is how it works. |
Yeah OK, that makes sense. I'm a little surprised this isn't implemented, I guess usually if you're doing a zonal mean (for example) you will have collapsed the altitude component. Presumably it would be pretty straightforward to just collapse the offending coordinate in the same way the data is? Perhaps with a warning that this is happening? |
I'm looking to implement this in CIS, but it would be nicer within Iris I think - if it fits. I've taken a quick look and it seems like passing an aggregator to coord.collapse() would be one way of doing this. Here's a very rough first stab just to give you an idea of my proposed approach. If you think it would be useful I'll carry on, but if not I'll just work around it in CIS! |
That is a neat idea @duncanwp. What would you do with the aggregated coordinates though? Does your workflow look something like:
? Or have I completely mis-understood? |
That's exactly right. I needed something working quickly so I've actually implemented this myself in CIS: https://github.com/cedadev/cis/blob/master/cis/aggregation/aggregator.py#L111 (and associated methods). It works quite nicely, but one of the remaining difficulties is that Iris (or any other tool for that matter) has no way of knowing that the Aux coordinate used be a function of that collapsed dimension, so you can't easily merge cubes back together having aggregated them. For cubes you use scalar coordinates (and cell methods) to identify this, but it wasn't immediately obvious how you might do that for a multi-dimensional coordinate. It's not a big deal, and perhaps it's useful as it is, in which case I'll happily put together a pull request. |
There's a note about this in the docs now; see #1819. |
#3319 removed the out of date comment, so I think this issue is done. |
Example:
Output:
Consider being explicit about removing the coordinate (and an example?) in the actual exception.
This issue is a direct result of a question I was asked offline by a frequent user of Iris.
The text was updated successfully, but these errors were encountered: