JiaweiZhuang / xESMF

Universal Regridder for Geospatial Data
http://xesmf.readthedocs.io/
MIT License
269 stars 49 forks source link

Implement ESMPy.Regrid extrapolation and ESMPy masking functionalities #93

Open RondeauG opened 4 years ago

RondeauG commented 4 years ago

Related to Issue #22.

As of ESMPy 8.0.0, multiple new parameters have been added to ESMPy.Regrid (doc). I am mostly interested in regridding while avoiding NaNs, which is now possible with "extrap_method", "extrap_num_src_pnts" and "extrap_dist_exponent".

If this is my source image

and this is my destination grid image

This is what I obtain with bilinear interpolation using xESMF: image

while this is what I can get using ESMPy-compatible masks (on both grids) and "extrap_method": image

RondeauG commented 4 years ago

I will try to work on a PR in the coming weeks.

RondeauG commented 4 years ago

I've managed to implement masks, but extrapolation is impossible if the weights are written on disk, as the function ESMP_FieldRegridStoreFile in ESMPy is deprecated and does not include the latest extrapolation options.

I will explore further by keeping the weights in memory (PR #91)

Edit: It immediately worked with PR #91. I will try to submit a PR in a couple days once I've cleaned up my edits.

Plantain commented 4 years ago

This functionality looks great and is definitely going to be an improvement for my usecases.