Regridding schemes#

Iris natively supports data regridding with its iris.cube.Cube.regrid() method and a set of predefined regridding schemes provided in the analysis module (further details are given on this page). Here, further regridding schemes are provided that are compatible with iris.cube.Cube.regrid().

Example:

from esmvalcore.preprocessor.regrid_schemes import ESMPyAreaWeighted

regridded_cube = cube.regrid(target_grid, ESMPyAreaWeighted())

Regridding schemes.

Classes:

ESMPyAreaWeighted([mask_threshold])

ESMPy area-weighted regridding scheme.

ESMPyLinear([mask_threshold])

ESMPy bilinear regridding scheme.

ESMPyNearest([mask_threshold])

ESMPy nearest-neighbor regridding scheme.

ESMPyRegridder(src_cube, tgt_cube[, method, ...])

General ESMPy regridder.

GenericFuncScheme(func, **kwargs)

Regridding with a generic function.

GenericRegridder(src_cube, tgt_cube, func, ...)

Generic function regridder.

UnstructuredNearest()

Unstructured nearest-neighbor regridding scheme.

class esmvalcore.preprocessor.regrid_schemes.ESMPyAreaWeighted(mask_threshold: float = 0.99)[source]#

ESMPy area-weighted regridding scheme.

This class can be used in iris.cube.Cube.regrid().

Does not support lazy regridding.

Methods:

regridder(src_cube, tgt_cube)

Get regridder.

Parameters:

mask_threshold (float) –

regridder(src_cube: Cube, tgt_cube: Cube) ESMPyRegridder#

Get regridder.

Parameters:
  • src_cube (Cube) – Cube defining the source grid.

  • tgt_cube (Cube) – Cube defining the target grid.

Returns:

Regridder instance.

Return type:

ESMPyRegridder

class esmvalcore.preprocessor.regrid_schemes.ESMPyLinear(mask_threshold: float = 0.99)[source]#

ESMPy bilinear regridding scheme.

This class can be used in iris.cube.Cube.regrid().

Does not support lazy regridding.

Methods:

regridder(src_cube, tgt_cube)

Get regridder.

Parameters:

mask_threshold (float) –

regridder(src_cube: Cube, tgt_cube: Cube) ESMPyRegridder#

Get regridder.

Parameters:
  • src_cube (Cube) – Cube defining the source grid.

  • tgt_cube (Cube) – Cube defining the target grid.

Returns:

Regridder instance.

Return type:

ESMPyRegridder

class esmvalcore.preprocessor.regrid_schemes.ESMPyNearest(mask_threshold: float = 0.99)[source]#

ESMPy nearest-neighbor regridding scheme.

This class can be used in iris.cube.Cube.regrid().

Does not support lazy regridding.

Methods:

regridder(src_cube, tgt_cube)

Get regridder.

Parameters:

mask_threshold (float) –

regridder(src_cube: Cube, tgt_cube: Cube) ESMPyRegridder#

Get regridder.

Parameters:
  • src_cube (Cube) – Cube defining the source grid.

  • tgt_cube (Cube) – Cube defining the target grid.

Returns:

Regridder instance.

Return type:

ESMPyRegridder

class esmvalcore.preprocessor.regrid_schemes.ESMPyRegridder(src_cube: Cube, tgt_cube: Cube, method: str = 'linear', mask_threshold: float = 0.99)[source]#

General ESMPy regridder.

Parameters:
  • src_cube (Cube) – Cube defining the source grid.

  • tgt_cube (Cube) – Cube defining the target grid.

  • method (str) – Regridding algorithm. Must be one of linear, area_weighted, nearest.

  • mask_threshold (float) – Threshold used to regrid mask of input cube.

class esmvalcore.preprocessor.regrid_schemes.GenericFuncScheme(func: Callable, **kwargs)[source]#

Regridding with a generic function.

This class can be used in iris.cube.Cube.regrid().

Does support lazy regridding if func does.

Parameters:
  • func (Callable) – Generic regridding function with signature f(src_cube: Cube, grid_cube: Cube, **kwargs) -> Cube.

  • **kwargs – Keyword arguments for the generic regridding function.

Methods:

regridder(src_cube, tgt_cube)

Get regridder.

regridder(src_cube: Cube, tgt_cube: Cube) GenericRegridder[source]#

Get regridder.

Parameters:
  • src_cube (Cube) – Cube defining the source grid.

  • tgt_cube (Cube) – Cube defining the target grid.

Returns:

Regridder instance.

Return type:

GenericRegridder

class esmvalcore.preprocessor.regrid_schemes.GenericRegridder(src_cube: Cube, tgt_cube: Cube, func: Callable, **kwargs)[source]#

Generic function regridder.

Parameters:
  • src_cube (Cube) – Cube defining the source grid.

  • tgt_cube (Cube) – Cube defining the target grid.

  • func (Callable) – Generic regridding function with signature f(src_cube: Cube, grid_cube: Cube, **kwargs) -> Cube.

  • **kwargs – Keyword arguments for the generic regridding function.

class esmvalcore.preprocessor.regrid_schemes.UnstructuredNearest[source]#

Unstructured nearest-neighbor regridding scheme.

This class is a wrapper around iris.analysis.UnstructuredNearest that removes any additional X or Y coordinates prior to regridding if necessary. It can be used in iris.cube.Cube.regrid().

Methods:

regridder(src_cube, tgt_cube)

Get regridder.

regridder(src_cube: Cube, tgt_cube: Cube) UnstructuredNearestNeigbourRegridder[source]#

Get regridder.

Parameters:
  • src_cube (Cube) – Cube defining the source grid.

  • tgt_cube (Cube) – Cube defining the target grid.

Returns:

Regridder instance.

Return type:

UnstructuredNearestNeigbourRegridder