Open
Description
This GitHub issue comment in the xESMF repo reveals that cf_xarray.bounds_to_vertices
has an issue where it produces incorrect results when bounds are descending, which cascades to incorrect results when regridding with xESMF.
Minimum Example
import xarray as xr
import cf_xarray as cfxr
bounds = xr.DataArray([[50.5, 50. ], [51., 50.5], [51.5, 51. ], [52., 51.5], [52.5, 52.]], dims=('lat', 'bounds'))
cfxr.bounds_to_vertices(bounds, "bounds")
yields
<xarray.DataArray (lat_vertices: 6)> Size: 48B
array([50.5, 51. , 51.5, 52. , 52.5, 52. ])
Dimensions without coordinates: lat_vertices
instead of starting at 50 and ending at 52.5.
Expected Result (I think)
<xarray.DataArray (lat_vertices: 5)> Size: ?
array([50., 50.5. , 51, 51.5. , 52])
Dimensions without coordinates: lat_vertices
@aulemahal mentioned here that he contributed to this portion of cf-xarray
and he expects the fix to be a simple transpose.
Unless somebody gets to it before me, I will try to take a look at the code whenever I have time since this is a somewhat high priority for a few projects I work on that use xESMF for regridding.
Metadata
Metadata
Assignees
Labels
No labels