I have a data set containing n two-dimensional points (x0,y0),(x1,y1), ... (xn-1,yn-1) where x0 < x1 < ... < xn-1. I want to interpolate this data set using cubic splines with explicit slope values SBEGIN and SEND set at both end points (x0,y0) and (xn-1,yn-1). I mean, let the produced n-1 cubic functions be f0(x)=a0x3+b0x2+c0x+d0, f1, ... , fn-2, then df0/dx(x0) = SBEGIN, dfn-2/dx(xn-1) = SEND.
I looked in scipy.interpolate
but can't find out how to set SBEGIN and SEND to the current instance.
import numpy
import scipy
xi = numpy.array([1, 2, 3, 4, ... , 100])
yi = numpy.array([3, 5, 18, 9, ... , 42])
s_begin = 2
s_end = -1
# How can I set s_begin and s_end?
f = scipy.interpolate.interp1d(xi,yi,type='cubic')
Also, I would like to know how to get the 4(n-1) coefficients a0,b0,c0,d0,a1,...,dn-2 of each cubic splines which should all be built in f
.
This is not possible with interp1d
. You can get the spline coefficients from splrep
though.