Skip to content
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

2D guess bounds #6097

Open
stephenworsley opened this issue Jul 29, 2024 · 4 comments
Open

2D guess bounds #6097

stephenworsley opened this issue Jul 29, 2024 · 4 comments
Assignees

Comments

@stephenworsley
Copy link
Contributor

stephenworsley commented Jul 29, 2024

✨ 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_bounds be 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

@trexfeathers
Copy link
Contributor

Some downstream code that might need to change:

# Reuse existing AuxCoord collapse logic, but with a custom
# mesh-specific warning.
message = (
"Collapsing a mesh coordinate - cannot check for contiguity."
f"Metadata may not be fully descriptive for '{self.name()}'."
)
warnings.warn(message, category=IrisVagueMetadataWarning)
with temp_suppress_warning():
collapsed_coord = aux_coord.collapsed(dims_to_collapse)

@bouweandela
Copy link
Member

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).

@stephenworsley
Copy link
Contributor Author

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.

@bouweandela
Copy link
Member

If the DimCoords are missing they get added here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

3 participants