interpolate
- sherpa.utils.interpolate(xout: ~numpy.ndarray, xin: ~numpy.ndarray, yin: ~numpy.ndarray, function: ~collections.abc.Callable[[~numpy.ndarray, ~numpy.ndarray, ~numpy.ndarray], ~numpy.ndarray] = <function linear_interp>)[source] [edit on github]
One-dimensional interpolation.
- Parameters:
- xoutarray_like
The positions at which to interpolate.
- xinarray_like
The x values of the data to interpolate. This must be sorted so that it is monotonically increasing.
- yinarray_like
The y values of the data to interpolate (must be the same size as
xin).- function
func,optional The function to perform the interpolation. It accepts the arguments (xout, xin, yin) and returns the interpolated values. The default is to use linear interpolation.
- Returns:
- youtarray_like
The interpolated y values (same size as
xout).
See also
Examples
Use linear interpolation to calculate the Y values for the
xgridarray:>>> import numpy as np >>> x = np.asarray([1.2, 3.4, 4.5, 5.2]) >>> y = np.asarray([12.2, 14.4, 16.8, 15.5]) >>> xgrid = np.linspace(2, 5, 5) >>> ygrid = interpolate(xgrid, x, y)
Use Neville’s algorithm for the interpolation:
>>> ygrid = interpolate(xgrid, x, y, neville)