Make dataless cubes work with cube operations
Related: #4447 and #6303
✨ Feature Request
With #6253, Iris will be able to create dataless cubes, but not much else.
Currently, some of the biggest things that are yet to be implemented are cube operations such as Collapse, Extract etc.
I propose:
- For single cube operations, such as
collapse,extractandaggregate, that if the cube is dataless, these functions should ignore data altogether, and instead perform the functions on the shape, (and coords, metadata etc.). - For multi cube operations:
- If all cubes involved are dataless, they should follow the above approach, ignore data and change shape instead.
- If it's a mix of dataless and with-data cubes, it should either:
- Raise an error, and commit to not doing this.
- Convert dataless cubes into normal cubes, by creating a fully masked array in the shape of the cube. I'm yet to investigate, but I think this could be a relatively straightforward function for either
DataManagerorCube. This may muddy the waters of what dataless means, but could add convenience for interoperability between dataless and with-data, generally.
@bjlittle thoughts?
I hadn't thought much about collapsing a dataless Cube but it would be pretty cool. The scalar coordinates and cell methods are useful information in their own right, and don't need data to be present.
This should also include load/save round tripping, to allow for longer term regridding targets
Discussed in @SciTools/peloton.
- Saving dataless cubes would not be CF-Compliant. This would mean saving it to .netcdf using our current loaders would not work.
- A potential solution for this would be to create a dataless saver, with a special NetCDF variable which would bypass CF checker when loading.
- There is also the question of future usecases; if other usecases are found, the way we approach this might be slightly different.