interpolate
- interpolate(values, in_grid=None, out_grid=None, matrix_source=None, method='linear')
Interpolate the
values
from thein_grid
onto theout_grid
.- Parameters:
values (ndarray, fieldlist) – the input data. It can be an ndarray or an earthkit-data GRIB fieldlist. ndarrays are assumed to be defined on the
in_grid
. The fieldlist support requires earthkit-data >= 0.6.0 and only works when theout_grid
is a regular latitude-longitude grid.in_grid (dict) – the gridspec describing the grid that
values
are defined on. Whenvalues
is a fieldlist the input grid is automatically detected andin_grid
cannot be specified.out_grid (dict) – the gridspec describing the target grid that
values
will be interpolated ontomethod (str) – the interpolation method. Possible values are
linear
andnearest-neighbour
. Fornearest-neighbour
the following aliases are also supported:nn
,nearest-neighbor
.matrix_source (str, None) – (experimental) the location of a user specified pre-generated matrix inventory. When it is None the default matrix inventory hosted on an ECMWF download server is used.
- Returns:
The same type of data as
values
containing the interpolated values.- Return type:
ndarray, fieldlist
- Raises:
ValueError – if a pre-generated interpolation matrix is not available
ValueError – if
in_grid
is specified for a fieldlist input
The interpolation only works when a pre-generated interpolation matrix is available for the given
in_grid
,out_grid
andmethod
combination.When
matrix_source
is None (default) the interpolation matrix is automatically downloaded and stored in a local cache and when it is needed again the cached version is used.Once the matrix is available the interpolation is performed by multiplying the
values
vector with it.
Note
Please see the inventory for the list of available matrices.