Closed ahuang11 closed 5 years ago
Thanks for the PR! However I've decided to stick to the two-step approach as explained in #9. This encourages people to reuse weights, which I believe is a good practice. But feel free to build your convenience wrapper!
PS: the handling of Dataset will be available in the next version by utilizing xr.apply_ufunc
Okay, continuing with the two-step approach, what are your thoughts on keeping a part of this PR, particularly just having a util to auto generate a grid with matching max and min coordinates of the current grid? Essentially, util.grid_2d without the need to pass in six arguments; just the original xr.DataArray and resolution?
def grid_2d_auto_detect(da, d_lon, d_lat=None):
if d_lat is None:
d_lat = d_lon
grid_out = grid_2d(da[LON].min(), da[LON].max(), d_lon,
da[LAT].min(), da[LAT].max(), d_lat)
return grid_out
Essentially creates
on the go (finds the min/max of the lon/lat) and regrids; just pass in the ds and d_lon.
If d_lat is None, d_lat will be set to d_lon.
This also handles xr.datasets.
Must have 'lon' and 'lat' as coordinate. If a variable does not have lon or lat, it'll raise a warning and skip, but keep it in the final dataset.
Test notebook: https://anaconda.org/ahuang11/test_xesmf_regrid_it