xarray.Dataset.regridder.horizontal#

Dataset.regridder.horizontal(data_var, output_grid, tool='xesmf', **options)#

Apply horizontal regridding to data_var of the current xr.Dataset to output_grid.

When might Regrid2 be preferred over xESMF?

If performing conservative regridding from a high/medium resolution lat/lon grid to a coarse lat/lon target, Regrid2 may provide better results as it assumes grid cells with constant latitudes and longitudes while xESMF assumes the cells are connected by Great Circles [1].

Supported tools, methods and grids:

Parameters:
  • data_var (str) – Name of the variable in the xr.Dataset to regrid.

  • output_grid (xr.Dataset) – Dataset containing output grid.

  • tool (str) – Name of the regridding tool.

  • **options (Dict[str, Any]) – These options are passed to the tool being used for regridding. See specific regridder documentation for available options.

Returns:

xr.Dataset – With the data_var variable on the grid defined in output_grid.

Raises:

ValueError – If tool is not supported.

References

Examples

Create destination grid:

>>> output_grid = xcdat.create_uniform_grid(-90, 90, 4.0, -180, 180, 5.0)

Regrid variable using “xesmf”:

>>> ds.regridder.horizontal("ts", output_grid, tool="xesmf", method="bilinear")

Regrid variable using “regrid2”:

>>> ds.regridder.horizontal("ts", output_grid, tool="regrid2")

Use convenience methods:

>>> ds.regridder.horizontal_xesmf("ts", output_grid, method="bilinear")
>>> ds.regridder.horizontal_regrid2("ts", output_grid)