diff --git a/tests/test_regrid.py b/tests/test_regrid.py index 7b8a2569..b2f65c35 100644 --- a/tests/test_regrid.py +++ b/tests/test_regrid.py @@ -438,6 +438,26 @@ def test_regrid(self): assert "lon_bnds" in output assert "time_bnds" in output + @pytest.mark.parametrize( + "name,value,attr_name", + [ + ("periodic", True, "_periodic"), + ("extrap_method", "inverse_dist", "_extrap_method"), + ("extrap_method", "nearest_s2d", "_extrap_method"), + ("extrap_dist_exponent", 0.1, "_extrap_dist_exponent"), + ("extrap_num_src_pnts", 10, "_extrap_num_src_pnts"), + ("ignore_degenerate", False, "_ignore_degenerate"), + ], + ) + def test_flags(self, name, value, attr_name): + ds = self.ds.copy() + + options = {name: value} + + regridder = xesmf.XESMFRegridder(ds, self.new_grid, "bilinear", **options) + + assert getattr(regridder, attr_name) == value + def test_no_variable(self): ds = self.ds.copy() diff --git a/xcdat/regridder/xesmf.py b/xcdat/regridder/xesmf.py index 13f40cff..ac57618d 100644 --- a/xcdat/regridder/xesmf.py +++ b/xcdat/regridder/xesmf.py @@ -124,6 +124,7 @@ def __init__( self._extrap_method = extrap_method self._extrap_dist_exponent = extrap_dist_exponent self._extrap_num_src_pnts = extrap_num_src_pnts + self._ignore_degenerate = ignore_degenerate self._regridder: xe.XESMFRegridder = None self._extra_options = options @@ -178,6 +179,7 @@ def horizontal(self, data_var: str, ds: xr.Dataset) -> xr.Dataset: extrap_method=self._extrap_method, extrap_dist_exponent=self._extrap_dist_exponent, extrap_num_src_pnts=self._extrap_num_src_pnts, + ignore_degenerate=self._ignore_degenerate, **self._extra_options, )