Skip to content

Conversation

stephenworsley
Copy link
Contributor

@stephenworsley stephenworsley commented Dec 16, 2019

Depends on either #3566 or #3583 changing the metadata structure of CellMeasure and AncillaryVariable.

The purpose of this pull request is to provide a simple workaround for cases where cubes can't merge properly because there are AuxCoords, CellMeasures or AncillaryVariables which ought to be merged in the final cube. In such a case, the function iris.util.new_axis is applied to all cubes and they are then concatenated. All AuxCoords, CellMeasures or AncillaryVariables which are to be merged in the final will be promoted by iris.util.new_axis by specifying them with the keywords promoted_aux, promoted_cm or promoted_av. This allows a greater degree of control than is possible with merge, since it will be possible to decide which AuxCoords, CellMeasures or AncillaryVariables should be merged (increasing their dimension) and which should be conserved (preserving their dimension).

I think this extra functionality could help simplify a lot of potentially fiddly or unstable user code (iris.util.new_axis accounts for a lot of nasty edge cases). The workaround for merge would only have to be a couple extra lines, eg.

mcube = cubes.merge_cube()

vs

cubes = CubeList(
    [new_axis(cube, scalar_coord="y", promoted_av=["ancil"]) for cube in cubes]
)
ccube = cubes.concatenate_cube()

In addition, Ancillary Variables and Cell Measures are no longer thrown away by new_axis.

@pp-mo
Copy link
Member

pp-mo commented Dec 16, 2019

👍 for the principle.

I really want to bank the elements of #3566 before considering this, so no review yet.

How will this play out if we wait for #3566 or #3583
- will it go easier before or after those ?

@stephenworsley
Copy link
Contributor Author

@pp-mo It will definitely go easier after #3566 or #3583. Currently this code won't work unless the metadata in iris.coords is edited, and it's probably not a great idea do do that in three parallel pull requests.
I would also like to put in an integration test with new_axis and concatenation working together when I get around to writing tests. I agree that this makes sense to be completed and reviewed after #3566.

@stephenworsley
Copy link
Contributor Author

Replaced by #4896.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants