[SciPy-user] three interpolation scenarios

Bryan Bryan.Fodness at gmail.com
Tue Jun 17 19:19:45 EDT 2008



On Jun 17, 7:10 pm, "Bryan Fodness" <bryan.fodn... at gmail.com> wrote:
> i have three different sets of data that need interpolation.
>
> the first with a single x and y was easy and works.
>
> x    y
> 0.0 0.999
> 0.1 1.006
> 0.2 1.014
> 0.3 1.021
> 0.4 1.000
> 0.5 1.001
> ...
>
> data = loadtxt('data.txt', skiprows=1)
> x, y = data[:,0], data[:,1]
> interp = interpolate.interp1d(x, y)
>
> the second with multiple y values is a little more complicated.
> x    y1     y2      y3     y4      y5
> 0.0 1.000 0.999 0.999 0.999 1.000
> 0.1 1.000 1.000 1.001 1.005 1.006
> 0.2 1.000 1.001 1.004 1.008 1.014
> 0.3 1.000 1.002 1.006 1.012 1.021
> 0.4 1.000 1.003 1.009 1.015 1.028
> 0.5 1.001 1.005 1.012 1.019 1.036
> ...
>
> y = 'y3'
> data = loadtxt('oaf.txt', skiprows=1)
> label = line.split()
> d = label[0]
this is supposed to be
   if d == 'x':
> if d == 'd':
>     dlist = label
> x, y = data[:,0], data[:,dlist.index(y)]
> interp = interpolate.interp1d(x, y)
>
> and the third, is the 2d case.
>
>        10     20      30     40      50
> 0.0 1.000 0.999 0.999 0.999 1.000
> 0.1 1.000 1.000 1.001 1.005 1.006
> 0.2 1.000 1.001 1.004 1.008 1.014
> 0.3 1.000 1.002 1.006 1.012 1.021
> 0.4 1.000 1.003 1.009 1.015 1.028
> 0.5 1.001 1.005 1.012 1.019 1.036
> ...
>
> not sure how to get the x, y and z's
>
> is the 1st and 2nd way the best way to do this, and can someone help with
> the third case.
>
> --
> "The game of science can accurately be described as a never-ending insult to
> human intelligence." - João Magueijo
>
> _______________________________________________
> SciPy-user mailing list
> SciPy-u... at scipy.orghttp://projects.scipy.org/mailman/listinfo/scipy-user



More information about the SciPy-User mailing list