1

I'm trying to convert some matlab code into python using numpy and scipy.

Here is the matlab code :

pp=csaps(Data(:,1),Data(:,2),0.9999);
new_data= ppval(pp,Data(:,1));

In python, I replace csaps by the SmoothSpline function from pywafo library. But I'm not able to find any function to replace ppval.

Here is the current python code:

pp = SmoothSpline(Data[0], Data[1], 0.9999)
new_data = pp(Data[0]) # should use ppval?

Any idea? Thanks in advance!

Mikhail_Sam
  • 10,602
  • 11
  • 66
  • 102
Djay
  • 13
  • 3
  • could you briefly describe what that function would do? – Magellan88 Apr 01 '14 at 17:08
  • Did you try [scipy.interpolate.PiecewisePolynomial](http://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.PiecewisePolynomial.html)? Note the difference in input parameters' order. – abudis Apr 02 '14 at 14:28

1 Answers1

0

I havent used SmoothSpline from pywafo library but i have used UnivariateSpline from Scipy. Here is a minimal working example from Scipy Spline

from scipy.interpolate import UnivariateSpline
x = np.linspace(0, 10, 70)
y = np.sin(x)
spl = UnivariateSpline(x, y, k=4, s=0)

you can obtain the value of the piecewise polynomial function MATLAB "ppval" as follows

spl(Data[0])

as you have rightly stated above

tsbankole
  • 13
  • 4