regrid (array-level) with precomputed weights

regrid(date, in_grid=None, out_grid=None, interpolation='linear', backend='precomputed', inventory='ecmwf')

Regrid array data using precomputed weights.

Parameters:
  • data (ndarray) – The data to be regridded, represented as a NumPy array, defining a single field on the in_grid.

  • in_grid (dict) – The gridspec describing the grid that data are defined on.

  • out_grid (dict) – The gridspec describing the target grid that data will be interpolated onto

  • interpolation (str) – The interpolation method. Possible values are linear and nearest-neighbour. For nearest-neighbour the following aliases are also supported: nn, nearest-neighbor.

  • inventory (str) –

    the path to the inventory of the precomputed weights. The interpolation only works when the weights are available for the given in_grid, out_grid and interpolation combination. At present, two inventory types are available:

    • If inventory is “ecmwf” or None, the remote inventory managed by ECMWF is used. In this case the weights are automatically downloaded and stored in a local cache (at "~/.cache/earthkit-geo") and when it is needed again the cached version is used. See the inventory for the list of supported grid to grid combinations with this backend.

    • If inventory is a local path, a local inventory is used. Please note this an experimental feature only used for development purposes.

Returns:

Return a tuple with the interpolated values and the gridspec of the output grid.

Return type:

tuple of ndarray and dict

Raises:

ValueError – if the precomputed weights are not available

Notes

The interpolation only works when the weights are available for the given input grid (automatically determined from the data), target grid and interpolation combination. See the inventory for the available combinations with the “ecmwf” inventory.

The regridding is performed by multiplying the values vector with the interpolation weights, which forms a sparse matrix (sparse matrix) -vector multiplication).

Examples