Reputation:
I'm trying to generate a plot for the cubic spline generated between the points
#y-coordinate
v_max = [0.07313751514675049,
0.0931375151467517,
0.11313751514675259,
0.13313751514675398,
0.1531375151467546,
0.17313751514676343,
0.19313751514676608,
0.2131375151467626,
0.23313751514675923,
0.2531375151467538]
#x-coodinate
t = [1.0, 3.0, 5.0, 7.0, 9.0, 11.0, 13.0, 15.0, 17.0, 19.0]
I used Cubic Spline method from the scipy package for cubic spline interpolation
cs = CubicSpline(t, v_max, bc_type='natural')
How do I get a list of points on the spline for the time period np.arange(0, 20, 0.1)?
Upvotes: 0
Views: 1766
Reputation: 1855
As you can see in the example given in the CubicSpline
documentation, you can call the cubic spline as if it is a function, providing the coordinates where you want to evaluate the cubic spline as an argument.
cs = CubicSpline(t, v_max, bc_type='natural')
t_interp = np.arange(0, 20, 0.1)
v_interp = cs(t_interp)
The variables t_interp
and v_interp
are now both numpy arrays with shape (200,)
.
Your data can be represented as a straight line, which is reflected by the generated interpolation.
Upvotes: 1