I've just started using xesmf to regrid WRF data (lambert conformal projection, non-rectangular) to a rectangular grid. It's fine when I use the 'bilinear' method, but I'm having trouble with the lat/lon bounds when I use 'conservative'
import numpy as np
import xarray as xr
import xesmf as xe
################
#sample dataset
################
nx, ny = 100, 50
lon_values = np.linspace(-180, 180, nx) + np.random.normal(scale=1, size=nx)
lat_values = np.linspace(-90, 90, ny) + np.random.normal(scale=0.5, size=ny)
lon_mesh, lat_mesh = np.meshgrid(lon_radians, lat_radians)
temperature_data = np.random.rand(ny, nx)
ds = xr.Dataset({"temperature": (["y", "x"], temperature_data)},coords={"lon": (["y", "x"], lon_mesh),"lat": (["y", "x"], lat_mesh)})
ds_coarse = xe.util.grid_global(30, 20)
xe.Regridder(ds,ds_coarse,'conservative')
But I get the error KeyError: 'lon_b'. I've tried adding lat_b and lon_b manually, but I don't really understand what the correct bands are (or what they're used for in the conservative mapping). It seems they have to have the sizes nx+1 and ny+1, but I don't see how I'd add these to the dataset. Many thanks for any help.