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

Method interp

xarray/core/dataarray.py:2267–2426  ·  view source on GitHub ↗

Interpolate a DataArray 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 `kwarg

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

Source from the content-addressed store, hash-verified

2265 )
2266
2267 def interp(
2268 self,
2269 coords: Mapping[Any, Any] | None = None,
2270 method: InterpOptions = "linear",
2271 assume_sorted: bool = False,
2272 kwargs: Mapping[str, Any] | None = None,
2273 **coords_kwargs: Any,
2274 ) -> Self:
2275 """
2276 Interpolate a DataArray onto new coordinates.
2277
2278 Performs univariate or multivariate interpolation of a Dataset onto new coordinates,
2279 utilizing either NumPy or SciPy interpolation routines.
2280
2281 Out-of-range values are filled with NaN, unless specified otherwise via `kwargs` to the numpy/scipy interpolant.
2282
2283 Parameters
2284 ----------
2285 coords : dict, optional
2286 Mapping from dimension names to the new coordinates.
2287 New coordinate can be a scalar, array-like or DataArray.
2288 If DataArrays are passed as new coordinates, their dimensions are
2289 used for the broadcasting. Missing values are skipped.
2290 method : { "linear", "nearest", "zero", "slinear", "quadratic", "cubic", \
2291 "quintic", "polynomial", "pchip", "barycentric", "krogh", "akima", "makima" }
2292 Interpolation method to use (see descriptions above).
2293 assume_sorted : bool, default: False
2294 If False, values of x can be in any order and they are sorted
2295 first. If True, x has to be an array of monotonically increasing
2296 values.
2297 kwargs : dict-like or None, default: None
2298 Additional keyword arguments passed to scipy's interpolator. Valid
2299 options and their behavior depend whether ``interp1d`` or
2300 ``interpn`` is used.
2301 **coords_kwargs : {dim: coordinate, ...}, optional
2302 The keyword arguments form of ``coords``.
2303 One of coords or coords_kwargs must be provided.
2304
2305 Returns
2306 -------
2307 interpolated : DataArray
2308 New dataarray on the new coordinates.
2309
2310 Notes
2311 -----
2312 - SciPy is required for certain interpolation methods.
2313 - When interpolating along multiple dimensions with methods `linear` and `nearest`,
2314 the process attempts to decompose the interpolation into independent interpolations
2315 along one dimension at a time.
2316 - The specific interpolation method and dimensionality determine which
2317 interpolant is used:
2318
2319 1. **Interpolation along one dimension of 1D data (`method='linear'`)**
2320 - Uses :py:func:`numpy.interp`, unless `fill_value='extrapolate'` is provided via `kwargs`.
2321
2322 2. **Interpolation along one dimension of N-dimensional data (N ≥ 1)**
2323 - Methods {"linear", "nearest", "zero", "slinear", "quadratic", "cubic", "quintic", "polynomial"}
2324 use :py:func:`scipy.interpolate.interp1d`, unless conditions permit the use of :py:func:`numpy.interp`

Callers 15

test_interpolate_nd_ndFunction · 0.95
test_nansFunction · 0.95
test_errorsFunction · 0.95
test_sortedFunction · 0.95
test_dimension_wo_coordsFunction · 0.95
test_datetimeFunction · 0.95
test_cftimeFunction · 0.95
test_cftime_type_errorFunction · 0.95

Calls 2

_to_temp_datasetMethod · 0.95
_from_temp_datasetMethod · 0.95

Tested by 15

test_interpolate_nd_ndFunction · 0.76
test_nansFunction · 0.76
test_errorsFunction · 0.76
test_sortedFunction · 0.76
test_dimension_wo_coordsFunction · 0.76
test_datetimeFunction · 0.76
test_cftimeFunction · 0.76
test_cftime_type_errorFunction · 0.76