iris
iris copied to clipboard
2D guess bounds
✨ Feature Request
Adopt a method for guessing the bounds of 2D coordinates.
Motivation
The guess_bounds method is currently only available for 1D coordinates. There are cases where only the 2D coordinates exist and it is not possible to determine the coordinate system of the 1D coordinates from which they derive. In this case, it would be useful to be able to guess the bounds so that functions wich require such bounds can be used.
Additional context
Guessing bounds becomes significantly more complex in 2 dimensions, especially when taking into account spherical geometry. A naive approach whish treats coordinates as if they existed in flat space could be easier to program, but it may lead to unusual behaviour near the pole. There is not (at least to me) an obvious algorithm to use to guess these bounds or an obvious answer as to which is the correct bound to guess. We would have to resolve the following questions:
- Is it acceptible to treat coordinates as if they were flat?
- Should there be special behaviour at the poles to ensure sensible choices of points?
- Should behaviour of
guess_boundsbe invariant in different rotational frames? - Is there a sensible method for guessing bounds which lie on the edge of the grid?
- Should "degenerate bounds" be specifically avoided? (e.g. in the case where two cell centers on the edge of the grid are on or are very close to a pole)
- Is it reasonable to expect that, for 2D coordinates generated from 1d coords with a rotated pole coordinate system, their guessed bounds should match?
Ping @nhsavage
Some downstream code that might need to change:
https://github.com/SciTools/iris/blob/5c18504eaecfd92651c3e408ce14c1cba9caf47a/lib/iris/mesh/components.py#L2896-L2904
There is a bit of code in ESMValCore for guessing bounds of 2D coordinates here, but I have some doubts about how well that works because the results of area weighted regridding with these guessed bounds do not look so good https://github.com/ESMValGroup/ESMValCore/issues/2405#issuecomment-2121968753.
There is a bit of code in ESMValCore for guessing bounds of 2D coordinates here, but I have some doubts about how well that works because the results of area weighted regridding with these guessed bounds do not look so good ESMValGroup/ESMValCore#2405 (comment).
@bouweandela correct me if I'm misreading, but it looks like this code requires there to be existing DimCoords on the cube to derive from. It looks like what's required here is a way to guess 2D bounds without refering to the 1D bounds.
If the DimCoords are missing they get added here.