Using scipy - spline / interp1d Programming Software Development by DougArndt … np from struct import * from scipy.interpolate import InterpolatedUnivariateSpline as spline from scipy.interpolate import interp1d wave = ''' 728 2563 4520 …arange(1,x_points) x_array = np.array(x_values,np.float64) #cubic = spline(x_array, y_wavearray) #for i in range(1,x_points): # print(i… Re: Using scipy - spline / interp1d Programming Software Development by Gribouillis I think you may misunderstand what cubic spline interpolation does. Here is a simple example def attempt(): # create … Numerical Computation/Need for interpolation subroutine(akima spline) Programming Software Development by kwesicat … be done. 3. The preferred interpolation method is the akima spline (can be found in the GSL). Below is the code… opengl c++ spline Programming Game Development by c++_fem Hi, Does anyone know how to animate object so it follows a previously drawn spline? I tried by translating all object vertices by Spline_point[i]-Spline_point[i-1] by frames but this doesn't work. Does anyone have a better idea? Cubic spline Interpolation output Programming Software Development by Kitson ….polyfit.html?highlight=interpolation[/url]) Either polynomial fit or cubic spline would be great. Can you guys help? Cubic Spline Problem Programming Software Development by Kirielson …, I am trying to implement a version of the cubic spline based on the artilce here: [Click Here](http://en.wikipedia… Re: Using scipy - spline / interp1d Programming Software Development by Gribouillis I think it works well. I changed the code to clip with [`np.clip()`](http://docs.scipy.org/doc/numpy/reference/generated/numpy.clip.html) and plot the wave with [matplotlib](http://matplotlib.org/) in [ipython notebook](http://ipython.org/notebook.html) (This was done with python 2). See the plot below y_wavearray = np.array(wave,np.float64)… Re: Using scipy - spline / interp1d Programming Software Development by DougArndt Thanks Gribouillis, that's encouraging. The plot indeed looks like what I'm after. (I can't get matplotlib working yet, due to (more) needed requirements) The odd thing is, when I look at the print of the points plotted, I see the clipped values, yet the plot looks right. Am I doing something wrong in my display routine ? It's the values that I'… Re: Using scipy - spline / interp1d Programming Software Development by DougArndt Thanks for the explanation and sample. I am still puzzled, however, in how does the plot software make the nice rounded curve if it's following the "flat" constant values ? is it doing something on it's own ? Your example promted some thoughts that I have to play with too, thanks. Re: Using scipy - spline / interp1d Programming Software Development by Gribouillis > how does the plot software make the nice rounded curve if it's following the "flat" constant values ? Think of 3 points in a plane. If they dont line up,there is exacly one circle passing through the 3 points. The circle is a example of a *rounded* curve following flat values. Interpolation does something similar with * A … Re: Numerical Computation/Need for interpolation subroutine(akima spline) Programming Software Development by ArkM 1. I don't understand where the problem starts. You have else without previous if. 2. There are some suspicious fragments in your code. For example, in geoParaFunc you allocated three arrays (see Para... pointers) then overwrite these pointers in [code=cpp] ... Para=geoParaFunc(atNumb[i],Zeq); // function call ... [/code] It's classic … Re: Numerical Computation/Need for interpolation subroutine(akima spline) Programming Software Development by kwesicat >1. I don't understand where the problem starts. You have else without previous if. I noticed the anomaly some time back and revised the code. Here is the correction to the said section: [CODE=C++] /* THE PROBLEM STARTS FROM HERE: */ // double *call_interp_function(double … Re: opengl c++ spline Programming Game Development by c++_fem Nevermind Re: Cubic spline Interpolation output Programming Software Development by Gribouillis The only problem I see is that your np arrays don't match your description of the problem. The following works for me [code=python] import numpy as np data = """ 1000 36 2000 40 3000 45 4000 50 """.strip().splitlines() data = zip(*(map(float, item.split()) for item in data)) x, y = (np.array(z) for z in data) print x … Re: Cubic spline Interpolation output Programming Software Development by Kitson Thanks for the reply, I'll give this a try when I'm home :D. Yeah sorry, I got the example from the Python website and hadn't changed the values. Re: Cubic Spline Problem Programming Software Development by TrustyTony m and n are undefined, the loop until len(n) as n[len(n)] does not exist. Also limit of len(n) on second loop does not make sense, as n is not used in loop. Also len(a) is not len(n), but len(m)+1. Re: Cubic Spline Problem Programming Software Development by scudzilla Your array of n has a maximum index of len(n) - 1. Your counter i ranges from 0 to len(n) - 1. So far so good. However, at line 14, you're trying to access the (i+1)th element of array n. What happens once i = len(n)-1? i would be equal to len(n), which exceeds the maximum available index of len(n)-1, hence the index out of range. @pyTony I think … Re: Cubic Spline Problem Programming Software Development by Kirielson Thanks for the help scudzilla and pyTony. Well I again go through the loop only to find the same out of index issue as well as mixed type issues between indices: for j in range(len(n)-1,0, -1): c[j]=zo[j]-mo[j]*c[j+1]; b[j]=(a[j+1]-a[j])/h[j]-h[j]*(c[j+1] + 2*c[j])/3; d[j]=(c[j+1]-c[j])/(3*h[j]); It looks … Re: Cubic Spline Problem Programming Software Development by scudzilla Do arrays m and n have fixed sizes? If so, what are the sizes? If not, is it possible for len(m) to be greater than or equal to len(n) - 2? Re: Cubic Spline Problem Programming Software Development by Kirielson M and N do not have fixed lenghts but both of them are checked for the same lenght. while mismatch == 1: x= (raw_input("Please enter the number the coords for x: ")) x_new= list(map(int, x.split())) n=x_new y= (raw_input("Please enter the number the coords for y: ")) y_new= list(map(int, y… Re: Cubic Spline Problem Programming Software Development by scudzilla Hmm lemme compile the code. Unfortunately I'll have to recreate the rest of the code so it'll take some time. Re: Cubic Spline Problem Programming Software Development by scudzilla On second thought, it's not definite that I could recreate those errors in my own code. Is it possible for you to post the rest of the code? Re: Cubic Spline Problem Programming Software Development by Kirielson from Tkinter import * from array import * mismatch = 1 #Enter the the values while mismatch == 1: x= (raw_input("Please enter the number the coords for x: ")) x_new= list(map(int, x.split())) n=x_new y= (raw_input("Please enter the number the coords for y: ")) y_new= list(map(… Re: Cubic Spline Problem Programming Software Development by scudzilla Strange, I'm not encountering any error, except the unindent issues at lines 63 to 66. Re: Cubic Spline Problem Programming Software Development by Kirielson That's weird, can you resend what you have? Right now I'm using a Mac with python 2.6. Re: Cubic Spline Problem Programming Software Development by TrustyTony lines 10 and 11 are weird, as you leave the loop without announcement immediately, if user enter same number of values. So you reinput the values, if they are equally many. Also you prompt is to give a single value of how many values for m and how many for n you have, but you do split for the input and do not ask about the values for them. Also you… Re: Cubic Spline Problem Programming Software Development by Kirielson Let me see if I'm understanding this correctly: A) There's no proper announcemt to the user that they entered the wrong values in the loop statement B)I'm improperly using the split command to accept one user input when I'm accepting multiple user commands. Re: Cubic Spline Problem Programming Software Development by scudzilla Oh, now I know why you're getting out of ranges and nonetype elements. You confused the element number with the length. Suppose you create a list x with length 5. Wouldn't the contents of x be (0 to 4)? Or to put it another way, if you create a list x with elements (0 to 5), wouldn't the length be 6? Meaning, for any list x with elements (0 to n), … Re: Cubic Spline Problem Programming Software Development by TrustyTony And it would be more clear to use directly tuples, not the way wikipedia says it. It is natural that you should have equal number of each item which goes to the tuple. Re: Cubic Spline Problem Programming Software Development by Kirielson Both Scudzilla and pyTom, thanks for helping. There's only one more problem, I'll post the code: for j in range(len(n)-2,-1, -1): c[j]=zo[j]-mo[j-1]*c[j+1]; b[j]=(a[j+1]-a[j])/h[j]-(h[j]*(c[j+1] + 2*c[j])/3); d[j]=(c[j+1]-c[j])/(3*h[j]); > > Traceback (most recent call last): > File "inter.py"…