pcmdi_metrics.utils.regrid

pcmdi_metrics.utils.regrid(ds, data_var, target_grid, regrid_tool='regrid2', regrid_method='bilinear', fill_zero=False)[source]

Regrid the dataset to a given grid.

Parameters:
  • ds (xr.Dataset) – Dataset to regrid.

  • data_var (str) – Variable in the dataset.

  • target_grid (xr.Dataset) – Grid to interpolate to.

  • regrid_tool (str, optional) – Regrid option: “regrid2” or “xesmf”. Default is “regrid2”.

  • regrid_method (str, optional) – Regrid method option that is required for xesmf regridder. Default is “bilinear”.

  • fill_zero (bool, optional) – Fill NaN value with zero if exists. Default is False.

Returns:

xr.Dataset – Regridded dataset.

Examples

>>> from pcmdi_metrics.utils import regrid