Interpolation
- interpolate(values, in_grid=None, out_grid=None, method='linear')
Interpolate the
valuesfrom thein_gridonto theout_grid.- Parameters:
values (ndarray, fieldlist) – the input data. It has to be an ndarray representing a single field defined on the
in_grid. Alternatively, an earthkit-data GRIB fieldlist can be used, but this only works ifout_gridis a global regular latitude-longitude grid.in_grid (dict) – the gridspec describing the grid that
valuesare defined on. Whenvaluesis a fieldlist the input grid is automatically detected ifin_gridis not specified.out_grid (dict) – the gridspec describing the target grid that
valueswill be interpolated ontomethod (str) – the interpolation method. Possible values are
linearandnearest-neighbour. Fornearest-neighbourthe following aliases are also supported:nn,nearest-neighbor.
- Returns:
The same type of data as
valuescontaining the interpolated values.- Return type:
ndarray, fieldlist
- Raises:
ValueError – if a pre-generated interpolation matrix is not available
ValueError – if
in_gridis specified for a fieldlist input
The interpolation only works when a pre-generated interpolation matrix is available for the given
in_grid,out_gridandmethodcombination.The interpolation matrix is automatically downloaded and stored in a local cache (at
"~/.cache/earthkit-regrid") and when it is needed again the cached version is used.Once the matrix is available the interpolation is performed by multiplying the
valuesvector with it.
Note
Please see the inventory for the list of available matrices.