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

ESMF regrid fails when there is more than one variable on an axis #216

Closed
nhsavage opened this issue Oct 17, 2022 · 2 comments
Closed

ESMF regrid fails when there is more than one variable on an axis #216

nhsavage opened this issue Oct 17, 2022 · 2 comments
Labels
New: Issue Highlight a new community raised "generic" issue Type: Bug

Comments

@nhsavage
Copy link

nhsavage commented Oct 17, 2022

🐛 Bug Report

When using Iris ESMF-regid to regrid data such as rotated pole data that includes auxiliary coords of true longitude two coords are returned not a single one

How To Reproduce

Steps to reproduce the behaviour:

  1. load CORDEX data on rotated pole grid wtih lat and lon 2D coords e.g cube = iris.load_cube('pr_AFR-22_NCC-NorESM1-M_historical_r1i1p1_CLMcom-KIT-CCLM5-0-15_v1_day_19500101-19501231.nc')
  2. outcube2 = cube.regrid(newcube, ESMFAreaWeighted())

Expected behaviour

the aux coord should be ignored in favour of the dim coord

Screenshots

Environment

  • MO VDI RHEL7
  • esmf_regrid version:'0.4.0'

Additional context

Click to expand this section...

We believe this can be resolved by having iris-esmf-regrid search Coords using dim_coord=True in these searches:

https://github.com/SciTools-incubator/iris-esmf-regrid/blob/7d6f568e8659109b5c8226f53dd27f5a5dd31f51/esmf_regrid/schemes.py#L184-L187

It should also fall back on the current implementation by using a try-except block.

The only scenario producing an error would then be no DimCoords and multiple AuxCoords on the same axis, which is truly ambiguous and would need the user to help by massaging the input.

See here for further details.

@nhsavage nhsavage added New: Issue Highlight a new community raised "generic" issue Type: Bug labels Oct 17, 2022
@sloosvel
Copy link

Example of the error message:

  File "/home/b/b381943/mambaforge/envs/coretool26rc4/lib/python3.10/site-packages/iris/cube.py", line 4359, in regrid
    regridder = scheme.regridder(self, grid)
  File "/home/b/b381943/mambaforge/envs/coretool26rc4/lib/python3.10/site-packages/esmf_regrid/schemes.py", line 338, in regridder
    return ESMFAreaWeightedRegridder(src_grid, tgt_grid, mdtol=self.mdtol)
  File "/home/b/b381943/mambaforge/envs/coretool26rc4/lib/python3.10/site-packages/esmf_regrid/schemes.py", line 367, in __init__
    regrid_info = _regrid_rectilinear_to_rectilinear__prepare(src_grid, tgt_grid)
  File "/home/b/b381943/mambaforge/envs/coretool26rc4/lib/python3.10/site-packages/esmf_regrid/schemes.py", line 186, in _regrid_rectilinear_to_rectilinear__prepare
    src_x = src_grid_cube.coord(axis="x")
  File "/home/b/b381943/mambaforge/envs/coretool26rc4/lib/python3.10/site-packages/iris/cube.py", line 1908, in coord
    raise iris.exceptions.CoordinateNotFoundError(emsg)
iris.exceptions.CoordinateNotFoundError: 'Expected to find exactly 1 coordinate, but found 2. They were: projection_x_coordinate, longitude.'


@stephenworsley
Copy link
Contributor

This should be closed by #217

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
New: Issue Highlight a new community raised "generic" issue Type: Bug
Projects
None yet
Development

No branches or pull requests

3 participants