interpolate — xarray_extras 0.6.1.dev7+g2fd6faf.d20250305 documentation (original) (raw)


xarray spline interpolation functions

xarray_extras.interpolate.splev(x_new: object, tck: Dataset, extrapolate: bool | str = True) → DataArray

Evaluate the B-spline generated with splrep().

Parameters:

Returns:

DataArray with all dims of the interpolated array, minus the interpolation dim, plus all dims of x_new

See splrep() for usage example.

xarray_extras.interpolate.splrep(a: DataArray, dim: Hashable, k: int = 3) → Dataset

Calculate the univariate B-spline for an N-dimensional array

Parameters:

Returns:

Dataset with t, c, k (knots, coefficients, order) variables, the same shape and coords as the input, that can be passed to splev().

Example:

x = np.arange(0, 120, 20) x = xarray.DataArray(x, dims=['x'], coords={'x': x}) s = xarray.DataArray(np.linspace(1, 20, 5), dims=['s']) y = np.exp(-x / s) x_new = np.arange(0, 120, 1) tck = splrep(y, 'x') y_new = splev(x_new, tck)

Features

Limitations