interpax.interp1d
- interpax.interp1d(xq: Real[Array, 'Nq'] | Real[ndarray, 'Nq'], x: Real[Array, 'Nx'] | Real[ndarray, 'Nx'], f: Num[Array, 'Nx ...'] | Num[ndarray, 'Nx ...'], method: str = 'cubic', derivative: int = 0, extrap: bool | float | tuple = False, period: None | float = None, **kwargs) Inexact[Array, 'Nq ...']Source
Interpolate a 1d function.
- Parameters:
xq (ndarray, shape(Nq,)) – query points where interpolation is desired
x (ndarray, shape(Nx,)) – coordinates of known function values (“knots”)
f (ndarray, shape(Nx,...)) – function values to interpolate
method (str) –
method of interpolation
'nearest': nearest neighbor interpolation'linear': linear interpolation'cubic': C1 cubic splines (aka local splines)'cubic2': C2 cubic splines (aka natural splines)'catmull-rom': C1 cubic centripetal “tension” splines'cardinal': C1 cubic general tension splines. If used, can also pass keyword parametercin float[0,1] to specify tension'monotonic': C1 cubic splines that attempt to preserve monotonicity in the data, and will not introduce new extrema in the interpolated points'monotonic-0': same as'monotonic'but with 0 first derivatives at both endpoints'akima': C1 cubic splines that appear smooth and natural
derivative (int >= 0) – derivative order to calculate
extrap (bool, float, array-like) – whether to extrapolate values beyond knots (True) or return nan (False), or a specified value to return for query points outside the bounds. Can also be passed as a 2 element array or tuple to specify different conditions for xq<x[0] and x[-1]<xq
period (float > 0, None) – periodicity of the function. If given, function is assumed to be periodic on the interval [0,period]. None denotes no periodicity
- Returns:
fq (ndarray, shape(Nq,…)) – function value at query points
Notes
For repeated interpolation given the same x, f data, recommend using Interpolator1D which caches the calculation of the derivatives and spline coefficients.