xarray.DataArray.interp¶
-
DataArray.
interp
(coords: Optional[Mapping[Hashable, Any]] = None, method: str = 'linear', assume_sorted: bool = False, kwargs: Optional[Mapping[str, Any]] = None, **coords_kwargs) → xarray.core.dataarray.DataArray¶ Multidimensional interpolation of variables.
- coordsdict, optional
Mapping from dimension names to the new coordinates. new coordinate can be an scalar, array-like or DataArray. If DataArrays are passed as new coordates, their dimensions are used for the broadcasting.
- method: {‘linear’, ‘nearest’} for multidimensional array,
{‘linear’, ‘nearest’, ‘zero’, ‘slinear’, ‘quadratic’, ‘cubic’} for 1-dimensional array.
- assume_sorted: boolean, optional
If False, values of x can be in any order and they are sorted first. If True, x has to be an array of monotonically increasing values.
- kwargs: dictionary
Additional keyword passed to scipy’s interpolator.
- **coords_kwarg{dim: coordinate, …}, optional
The keyword arguments form of
coords
. One of coords or coords_kwargs must be provided.
- Returns
- interpolated: xr.DataArray
New dataarray on the new coordinates.
See also
scipy.interpolate.interp1d
,scipy.interpolate.interpn
Notes
scipy is required.
Examples
>>> da = xr.DataArray([1, 3], [('x', np.arange(2))]) >>> da.interp(x=0.5) <xarray.DataArray ()> array(2.0) Coordinates: x float64 0.5