Regridding problem using xesmf with masks

Hi all,

I am trying to use xesmf.Reggrider between two grids that have a mask.
I use the command in a jupyter notebook (found in the documentation):
regridder = xe.Regridder(afs_in_msks, aft_out_mskt, method=“patch”, periodic=True, extrap_method=“nearest_s2d”)
but I have an error message:
TypeError: Regridder.init() got an unexpected keyword argument ‘extrap_method’
If I can’t use some extrap_method, I do not know ho to manage target points that do not receive any value … Does any one know what is happening ?
Thanks for your help,

1 Like

You should get a quicker answer here: Discussions · pangeo-data/xESMF · GitHub

Just a quick guess, but how did you install xesmf, and which version did you install?

If you installed from PyPI: there’s unfortunately a old version on PyPI under the xesmf name (the sole maintainer of the original xesmf package is missing), so instead of:

pip install xesmf

you would need to use

pip install pangeo-xesmf

If you installed from conda-forge you won’t have that issue (but then it would still be interesting to know the version).

If that doesn’t help, you should definitely ask the maintainers directly.

Thanks for your rapid answer. I will try pangeo-esmf and let you know.

Just a heads up that @rabernat mentioned on the Pangeo Weekly Checkin yesterday that due to new capabilities in geopandas, it is efficient to do regridding only using geopandas and xarray, creating the weights through polygon geometry calculations.

He said he would soon post an example to Discourse so watch this space! :slight_smile:


Finally I used pangeo-xesmf and I succeeded to use the extrap_method=“nearest_s2d” of xesmf for masked cases for all remapping methods.

1 Like


I am now trying to remap tos from the 2D curvilinear Nemo 1° grid to a 2D rectilinear grid (the one of ERSSTv5 observation) using xesmf:

regridder = xe.Regridder(afs_in_msks, aft_out_mskt, method=“bilinear”, periodic=True, extrap_method=“nearest_s2d”)

I have an error in the PET0.ESMF_LogFile:
20220828 110201.851 ERROR PET0 degenerate elem. id=105705

This error does not exist when I use NCL interfaced with ESMF.

Does someone know if there is an option to avoid using degenerated cells with xesmf ?