# Regridding problem using xesmf with masks

**URL:** <https://discourse.pangeo.io/t/regridding-problem-using-xesmf-with-masks/2686>\
**Category:** Science\
**Created:** [August 24, 2022, 12:07pm UTC](https://discourse.pangeo.io/t/regridding-problem-using-xesmf-with-masks/2686 "2022-08-24T12:07:13Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![laure\_coquart](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pangeo.io/laure_coquart/32/1797_2.png) [@laure\_coquart](https://discourse.pangeo.io/u/laure_coquart)\
**Post date:** [August 24, 2022, 12:07pm UTC](https://discourse.pangeo.io/t/regridding-problem-using-xesmf-with-masks/2686/1 "2022-08-24T12:07:13Z")

</div>

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,  
Laure

---

<div class="post-metadata">

**Author:** ![dcherian](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pangeo.io/dcherian/32/2235_2.png) [@dcherian](https://discourse.pangeo.io/u/dcherian)\
**Post date:** [August 24, 2022, 3:30pm UTC](https://discourse.pangeo.io/t/regridding-problem-using-xesmf-with-masks/2686/2 "2022-08-24T15:30:00Z")

</div>

You should get a quicker answer here: [Discussions · pangeo-data/xESMF · GitHub](https://github.com/pangeo-data/xESMF/discussions)

---

<div class="post-metadata">

**Author:** ![keewis](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pangeo.io/keewis/32/1106_2.png) [@keewis](https://discourse.pangeo.io/u/keewis)\
**Post date:** [August 24, 2022, 3:32pm UTC](https://discourse.pangeo.io/t/regridding-problem-using-xesmf-with-masks/2686/3 "2022-08-24T15:32:38Z")

</div>

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:

```bash
pip install xesmf

```

you would need to use

```bash
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.

---

<div class="post-metadata">

**Author:** ![laure\_coquart](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pangeo.io/laure_coquart/32/1797_2.png) [@laure\_coquart](https://discourse.pangeo.io/u/laure_coquart)\
**Post date:** [August 24, 2022, 4:41pm UTC](https://discourse.pangeo.io/t/regridding-problem-using-xesmf-with-masks/2686/4 "2022-08-24T16:41:25Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![rsignell](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pangeo.io/rsignell/32/447_2.png) [@rsignell](https://discourse.pangeo.io/u/rsignell)\
**Post date:** [August 25, 2022, 7:07pm UTC](https://discourse.pangeo.io/t/regridding-problem-using-xesmf-with-masks/2686/5 "2022-08-25T19:07:38Z")

</div>

Just a heads up that @rabernat mentioned on the [Pangeo Weekly Checkin yesterday](https://docs.google.com/document/d/e/2PACX-1vRerhoxG-wOvh-wQTj7F8HPYve75l8pAtL-tgtzY_3YLqVUsaMSEgE4K70HgMt5S91FMwSu8EIizewy/pub) 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! 🙂

---

<div class="post-metadata">

**Author:** ![laure\_coquart](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pangeo.io/laure_coquart/32/1797_2.png) [@laure\_coquart](https://discourse.pangeo.io/u/laure_coquart)\
**Post date:** [October 31, 2022, 5:14pm UTC](https://discourse.pangeo.io/t/regridding-problem-using-xesmf-with-masks/2686/6 "2022-10-31T17:14:20Z")

</div>

Hi,  
Finally I used pangeo-xesmf and I succeeded to use the _extrap\_method=“nearest\_s2d”_ of xesmf for masked cases for all remapping methods.

---

<div class="post-metadata">

**Author:** ![laure\_coquart](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pangeo.io/laure_coquart/32/1797_2.png) [@laure\_coquart](https://discourse.pangeo.io/u/laure_coquart)\
**Post date:** [November 8, 2022, 5:47pm UTC](https://discourse.pangeo.io/t/regridding-problem-using-xesmf-with-masks/2686/7 "2022-11-08T17:47:45Z")

</div>

Hi,

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 ?

Thanks
