Attention
This repository has been archived. Please use xarray.DataTree instead.
datatree.DataTree.interp_like#
- DataTree.interp_like(other: T_Xarray, method: InterpOptions = 'linear', assume_sorted: bool = False, kwargs: Mapping[str, Any] | None = None, method_non_numeric: str = 'nearest') Self[source]#
Interpolate this object onto the coordinates of another object, filling the out of range values with NaN.
If interpolating along a single existing dimension,
scipy.interpolate.interp1dis called. When interpolating along multiple existing dimensions, an attempt is made to decompose the interpolation into multiple 1-dimensional interpolations. If this is possible,scipy.interpolate.interp1dis called. Otherwise,scipy.interpolate.interpn()is called.- Parameters:
other (
DatasetorDataArray) – 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", "polynomial", "barycentric", "krogh", "pchip", "spline", "akima"}, default:"linear") – String indicating which method to use for interpolation:‘linear’: linear interpolation. Additional keyword arguments are passed to
numpy.interp()‘nearest’, ‘zero’, ‘slinear’, ‘quadratic’, ‘cubic’, ‘polynomial’: are passed to
scipy.interpolate.interp1d(). Ifmethod='polynomial', theorderkeyword argument must also be provided.‘barycentric’, ‘krogh’, ‘pchip’, ‘spline’, ‘akima’: use their respective
scipy.interpolateclasses.
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 passed to scipy’s interpolator.method_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.
See also
Dataset.interp,Dataset.reindex_like