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
orDataArray
) – 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 usemethod_non_numeric (
{"nearest", "pad", "ffill", "backfill", "bfill"}
, optional) – Method for non-numeric types. Passed on toDataset.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:
- Interpolation along one dimension of 1D data (`method=’linear’`)
Uses
numpy.interp()
, unless fill_value=’extrapolate’ is provided via kwargs.
- 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 ofnumpy.interp()
(as in the case of method=’linear’ for 1D data).
If method=’polynomial’, the order keyword argument must also be provided.
- Special interpolants for interpolation along one dimension of N-dimensional data (N ≥ 1)
- Depending on the method, the following interpolants from
scipy.interpolate
are used: “pchip”:
scipy.interpolate.PchipInterpolator
“barycentric”:
scipy.interpolate.BarycentricInterpolator
“krogh”:
scipy.interpolate.KroghInterpolator
- “akima” or “makima”:
scipy.interpolate.Akima1dInterpolator
(makima is handled by passing the makima flag).
- “akima” or “makima”:
- Depending on the method, the following interpolants from
- Interpolation along multiple dimensions of multi-dimensional data
- Uses
scipy.interpolate.interpn()
for methods {“linear”, “nearest”, “slinear”, “cubic”, “quintic”, “pchip”}.
- Uses