[SciPy-User] newbie help: splprep to get spline interpolation of 2d signal : ValueError from code but not in command line example

hari jayaram harijay@gmail....
Fri Sep 30 15:08:41 CDT 2011


Thanks Pauli for your email.  Repeated experimentation made me gloss over
the two different functions ..splrep for spline-represent is what I needed
to use as you pointed out.

I could get my spline interpolation to work just great with splrep once I
used only every 10th point or so since the data had a high frequency
component which was not usefull to the analysis. I handled the spline
calculation by using only every 10th point.

Thanks for your help
Hari

My code that worked
def plot_for_well(well_id,window=10):
    xvals = []
    yvals = []
    for vals in mega_data_dict[well_id]:
        xvals.append(float(vals[0]))
        yvals.append(float(vals[1]))
    window = int(window)
tck =interpolate.splrep(xs,ys,k=5,s=0.3)
    xcalc = linspace(min(xvals),max(xvals),len(xvals))
    ycalc = interpolate.splev(xcalc,tck)
    my_derivative = interpolate.splev(xcalc,tck,der=3)
#    print xcalc(xs.index(max(my_derivative)))
    print ycalc
    ax = host_subplot(111,axes_class=AA.Axes)
    plt.subplots_adjust(right=0.75)
    par1 = ax.twinx()
    par2 = ax.twinx()
    offset = 60
    new_fixed_axis = par2.get_grid_helper().new_fixed_axis
    par2.axis["right"] =
new_fixed_axis(loc="right",axes=par2,offset=(offset, 0))
#    par2.axis["right"].toggle(all=True)
#    ax.set_yscale('log')
    par1.plot(xs,ys,"o",xcalc,ycalc)
    par2.plot(xcalc,my_derivative)
    plt.show()

On Thu, Sep 29, 2011 at 5:34 PM, Pauli Virtanen <pav@iki.fi> wrote:

> On 29.09.2011 23:24, hari jayaram wrote:
> [clip]
> > x = linspace(20,81,2339)
> > y = sin(x)
> > tck = interpolate.splrep(x, y)
> [clip]
> >      tck = interpolate.splprep(x=ys)
>
> Note that there are two functions: `splrep` and `splprep`, and they do
> somewhat different things (read the docs for each to find out more).
>
> You probably intendeded to write `splrep(xs, ys)` in the latter case.
>
> --
> Pauli Virtanen
>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20110930/c11b4cf3/attachment.html 


More information about the SciPy-User mailing list