xESMF icon indicating copy to clipboard operation
xESMF copied to clipboard

use cf to calculate 2d lat lon bounds

Open jmineau opened this issue 1 year ago • 2 comments

I just ran into this issue while trying to regrid a curvilinear grid to rectilinear with the conservative method. This is my first pull request into a public project, so apologies if I'm doing something incorrectly.

Previously, when lat or lon was a 2D array, xesmf would throw key error when attempting to calculate bounds if they were not present. At the time, cf-xarray had no method of calculating new bounds from 2D coordinates, see #180.

However, this is no longer the case via https://github.com/xarray-contrib/cf-xarray/issues/71.

I have simply removed the conditional key error and updated the docs.

jmineau avatar Jul 29 '24 21:07 jmineau

Hi @jmineau , thanks for the PR!

I think the main reason we were hesitant to use cf-xarray's automatic 2D bounds computation is that it is still bugged in some cases : https://github.com/xarray-contrib/cf-xarray/issues/384 . I fear that in a regridding workflow this error would slide in completely silently and yield wrong weights, a bug that would be hard to diagnose or even detect after the fact.

What do the other maintainers think. @huard, @raphaeldussin ?

aulemahal avatar Jul 29 '24 21:07 aulemahal

I agree with @aulemahal, I'd avoid silently using the 2D bound generation logic until it is hardened.

huard avatar Aug 19 '24 14:08 huard

closing this PR until a fix is implemented in cf-xarray

raphaeldussin avatar Feb 07 '25 20:02 raphaeldussin