Include AncillaryVariables and restructure Cube metadata.#3422
Include AncillaryVariables and restructure Cube metadata.#3422pp-mo merged 7 commits intoSciTools:masterfrom
Conversation
|
Hi @lbdreyer For convenience, I suggest you could get myself or @stephenworsley to do that, as we have both been in that area recently, and it's a bit involved. BTW maybe that shouldn't be in |
|
@pp-mo Are you available to review this? |
lib/iris/coords.py
Outdated
| A dictionary containing other cf and user-defined attributes. | ||
|
|
||
| """ | ||
| super(AncillaryVariable, self).__init__( |
There was a problem hiding this comment.
An awful lot of your 'super' calls can be replaced by Python 3 argumentless ones, I think.
I.E. super(SelfClass, self) --> super().
Much nicer I think !
Applies a lot here, and in Coord.
| values = values.copy() | ||
|
|
||
| # If the metadata is a coordinate and it has bounds, repeat the above | ||
| # with the bounds. |
There was a problem hiding this comment.
The comment in the former Coord code here also added "This will not realise lazy data."
I think that is still a useful hint + could usefully be added back.
lib/iris/cube.py
Outdated
| ancillary_variable_summary, cube_header = vector_summary( | ||
| [], cube_header, max_line_offset, | ||
| ancillary_variables=vector_ancillary_variables) | ||
| summary += '\n Ancillary Datasets:\n' |
There was a problem hiding this comment.
For the sake of consistency, the 'D' in Datasets should be lower case. This also applies to the 'M' in Measures in the above summary += '\n Cell Measures:\n'.
There was a problem hiding this comment.
I'd argue it should go the other way; we should update the other section headings (Dimension coordinates -> Dimension Coordinates) since they are headings and so should be capitalised
There was a problem hiding this comment.
FWIW I lean toward @lbdreyer here : "All Title Case" makes sense to me.
There was a problem hiding this comment.
Should this say Ancillary Variables?
After some extensive discussion ! I observed that the worst of the 'mixed' approach is that, where a Coord method "extends" the _DimensionalMetadata method to do "the same thing to the bounds", we have code which is effectively copied from one class to the other : This not only breaks DRY but puts the 'copy' a long way away where it is not obvious ! I think we should either
Comparison of "separate" to "combine": |
* Merge bounds handling into _DimensionalMetadata class. * Fix cube arithmetic bug. * Code style fix.
|
Hi @lbdreyer, and anyone else watching. So, I'm happy that there are at least some tests to exercise all the new methods.
The problem of cube summary getting the dimension mappings wrong I demonstrated like this: Something like this should be in the above test. |
It seems a considerable number of cube operations don't handle ancillary variables as they should do, of which the most worrying are ...
So right now, if a cube contains AVS, cube.copy() is clearly different (and prints differently) but it tests equal ! But none of this will affect cubes that *don't * contain AVs, so in the interests of progress I think we'd better ignore this for now + defer all those problems to a new issue to tidy up the cube operations later. |
|
@pp-mo I have added a test for ancillary variables in cube.summary (Note! we have very minimal testing for cube.summary in place! we should address, possibly if we also get a change to improve the html repr) The tests for concatenate/merge made me realise that it wasn't being handled correctly (and consequently CellMeasures are also handled incorrectly when merging/concatenating). Unfortunately the work to get this done seems substantial and not something we will achieve in the next few hours. I have decided to back out the changes I previously made to _concatenate.py and _merge.py and instead fit that work into #3483 |
|
I think what's done here is ok, though a lot remains to be dealt with. |
This includes the functionality to represent CF Ancillary variables on a cube.
This PR also includes a restructuring of dimensional metadata objects (coords, cell measures and ancillary dataset) in a hope to avoid code duplication.
Below is a rough diagram of the new structure:
