MCPcopy Index your code
hub / github.com/pydata/xarray / interp

Method interp

xarray/core/dataset.py:3733–4040  ·  view source on GitHub ↗

Interpolate a Dataset onto new coordinates. 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`

(
        self,
        coords: Mapping[Any, Any] | None = None,
        method: InterpOptions = "linear",
        assume_sorted: bool = False,
        kwargs: Mapping[str, Any] | None = None,
        method_non_numeric: str = "nearest",
        **coords_kwargs: Any,
    )

Source from the content-addressed store, hash-verified

3731 )
3732
3733 def interp(
3734 self,
3735 coords: Mapping[Any, Any] | None = None,
3736 method: InterpOptions = "linear",
3737 assume_sorted: bool = False,
3738 kwargs: Mapping[str, Any] | None = None,
3739 method_non_numeric: str = "nearest",
3740 **coords_kwargs: Any,
3741 ) -> Self:
3742 """
3743 Interpolate a Dataset onto new coordinates.
3744
3745 Performs univariate or multivariate interpolation of a Dataset onto new coordinates,
3746 utilizing either NumPy or SciPy interpolation routines.
3747
3748 Out-of-range values are filled with NaN, unless specified otherwise via `kwargs` to the numpy/scipy interpolant.
3749
3750 Parameters
3751 ----------
3752 coords : dict, optional
3753 Mapping from dimension names to the new coordinates.
3754 New coordinate can be a scalar, array-like or DataArray.
3755 If DataArrays are passed as new coordinates, their dimensions are
3756 used for the broadcasting. Missing values are skipped.
3757 method : { "linear", "nearest", "zero", "slinear", "quadratic", "cubic", \
3758 "quintic", "polynomial", "pchip", "barycentric", "krogh", "akima", "makima" }
3759 Interpolation method to use (see descriptions above).
3760 assume_sorted : bool, default: False
3761 If False, values of coordinates that are interpolated over can be
3762 in any order and they are sorted first. If True, interpolated
3763 coordinates are assumed to be an array of monotonically increasing
3764 values.
3765 kwargs : dict, optional
3766 Additional keyword arguments passed to the interpolator. Valid
3767 options and their behavior depend which interpolant is used.
3768 method_non_numeric : {"nearest", "pad", "ffill", "backfill", "bfill"}, optional
3769 Method for non-numeric types. Passed on to :py:meth:`Dataset.reindex`.
3770 ``"nearest"`` is used by default.
3771 **coords_kwargs : {dim: coordinate, ...}, optional
3772 The keyword arguments form of ``coords``.
3773 One of coords or coords_kwargs must be provided.
3774
3775
3776 Returns
3777 -------
3778 interpolated : Dataset
3779 New dataset on the new coordinates.
3780
3781 Notes
3782 -----
3783 - SciPy is required for certain interpolation methods.
3784 - When interpolating along multiple dimensions with methods `linear` and `nearest`,
3785 the process attempts to decompose the interpolation into independent interpolations
3786 along one dimension at a time.
3787 - The specific interpolation method and dimensionality determine which
3788 interpolant is used:
3789
3790 1. **Interpolation along one dimension of 1D data (`method='linear'`)**

Calls 15

sortbyMethod · 0.95
create_variablesMethod · 0.95
either_dict_or_kwargsFunction · 0.90
is_chunked_arrayFunction · 0.90
is_duck_dask_arrayFunction · 0.90
broadcast_variablesFunction · 0.90
PandasIndexClass · 0.90
itemsMethod · 0.80
to_base_variableMethod · 0.80
keysMethod · 0.80

Tested by 15

test_dtypeFunction · 0.76
test_coord_attrsFunction · 0.76
test_keywargsFunction · 0.36
test_interpolate_1dFunction · 0.36