xarray.Dataset.interp_like

xarray.Dataset.interp_like#

Dataset.interp_like(other, method='linear', assume_sorted=False, kwargs=None, method_non_numeric='nearest')[source]#

Interpolate this object onto the coordinates of another object.

Performs univariate or multivariate interpolation of a Dataset onto new coordinates, utilizing either NumPy or SciPy interpolation routines.

Out-of-range values are filled with NaN, unless specified otherwise via kwargs to the numpy/scipy interpolant.

Parameters:
  • other (Dataset or DataArray) – Object with an ‘indexes’ attribute giving a mapping from dimension names to an 1d array-like, which provides coordinates upon which to index the variables in this dataset. Missing values are skipped.

  • method ({"linear", "nearest", "zero", "slinear", "quadratic", "cubic", "quintic", "polynomial", "pchip", "barycentric", "krogh", "akima", "makima"}) – Interpolation method to use (see descriptions above).

  • assume_sorted (bool, default: False) – If False, values of coordinates that are interpolated over can be in any order and they are sorted first. If True, interpolated coordinates are assumed to be an array of monotonically increasing values.

  • kwargs (dict, optional) – Additional keyword arguments passed to the interpolator. Valid options and their behavior depend which interpolant is use

  • method_non_numeric ({"nearest", "pad", "ffill", "backfill", "bfill"}, optional) – Method for non-numeric types. Passed on to Dataset.reindex(). "nearest" is used by default.

Returns:

interpolated (Dataset) – Another dataset by interpolating this dataset’s data along the coordinates of the other object.

Notes

  • scipy is required.

  • If the dataset has object-type coordinates, reindex is used for these

    coordinates instead of the interpolation.

  • When interpolating along multiple dimensions with methods linear and nearest,

    the process attempts to decompose the interpolation into independent interpolations along one dimension at a time.

  • The specific interpolation method and dimensionality determine which

    interpolant is used:

    1. Interpolation along one dimension of 1D data (`method=’linear’`)
      • Uses numpy.interp(), unless fill_value=’extrapolate’ is provided via kwargs.

    2. Interpolation along one dimension of N-dimensional data (N ≥ 1)
      • Methods {“linear”, “nearest”, “zero”, “slinear”, “quadratic”, “cubic”, “quintic”, “polynomial”}

        use scipy.interpolate.interp1d(), unless conditions permit the use of numpy.interp() (as in the case of method=’linear’ for 1D data).

      • If method=’polynomial’, the order keyword argument must also be provided.

    3. Special interpolants for interpolation along one dimension of N-dimensional data (N ≥ 1)
    4. Interpolation along multiple dimensions of multi-dimensional data