Open
Description
I am evaluating interp()
against xESMF. Here's how xESMF would regrid the built-in 'rasm'
data to a regular lat-lon grid.
Seems like interp()
can convert rectilinear grids (1D coordinates) to curvilinear grids (2D coordinates), according to the last example. How about the reverse? Can it convert 2D coordinate to 1D, or to another 2D coordinate?
That's the test data:
dr = xr.tutorial.load_dataset('rasm')['Tair']
...
Coordinates:
* time (time) datetime64[ns] 1980-09-16T12:00:00 1980-10-17 ...
xc (y, x) float64 189.2 189.4 189.6 189.7 189.9 190.1 190.2 190.4 ...
yc (y, x) float64 16.53 16.78 17.02 17.27 17.51 17.76 18.0 18.25 ...
That's a simple destination grid:
lon = xr.DataArray(np.linspace(-180, 180, 120), dims=['lon'])
lat = xr.DataArray(np.linspace(-90, 90, 60), dims=['lat'])
I would expect a syntax like:
dr_out = dr.interp(xc=lon, yc=lat)
But I got ValueError: dimensions ['xc', 'yc'] do not exist
, becauseinterp()
only accepts dimensions (which must be 1D), not coordinates.
dr.interp(x=lon, y=lat)
runs but the result is not correct. This is expected because x
does not mean longitude in the original data.