fosanalysis
A framework to evaluate distributed fiber optic sensor data
Loading...
Searching...
No Matches
interpolation.py
Go to the documentation of this file.
2r"""
3Contains functionality for interpolating data.
4\author Bertram Richter
5\date 2023
6"""
7
8import numpy as np
9import scipy.interpolate
10
12 x: np.array,
13 y: np.array,
14 x_new: np.array,
15 method: str,
16 **kwargs,) -> np.array:
17 r"""
18 Interpolate one-dimensional data.
19 \param x Original abcissa data.
20 \param y Original ordinate data.
21 \param x_new Abcissa data for the new data points.
22 The interpolation function is evaluated at those points.
23 \param method Name of the interpolation function to use.
24 The interpolation function expects two parameters (`x` and `y`) and returns a callable.
25 The returned callable should expect only a single parameter (the `x_new`).
26 According to [scipy.interpolate](https://docs.scipy.org/doc/scipy/reference/interpolate.html),
27 the following options are available (consult the `scipy` documentation for details):
28 - `"interp1d"` (legacy)
29 - `"BarycentricInterpolator"`
30 - `"KroghInterpolator"`
31 - `"PchipInterpolator"`
32 - `"Akima1DInterpolator"`
33 - `"CubicSpline"`
34 - `"make_interp_spline"`
35 - `"make_smoothing_spline"`
36 - `"UnivariateSpline"`
37 - `"InterpolatedUnivariateSpline"`
38 \param **kwargs Additionals keyword arguments.
39 Will be passed to the interpolation function.
40 """
41 integrator_class = getattr(scipy.interpolate, method)
42 integrator = integrator_class(x, y, **kwargs)
43 return integrator(x_new)
np.array scipy_interpolate1d(np.array x, np.array y, np.array x_new, str method, **kwargs)
Interpolate one-dimensional data.