[SciPy-User] UnivariateSpline interpolation problem

Renaux Christian kortak at gmail.com
Sat Apr 16 17:04:40 EDT 2011


Hi,

I'm having a weird problem trying to interpolate data using
the UnivariateSpline function.  Interpolating through all the points (s=0)
and the spline function does not give a result on the entire set of data.
 The result for s>=1 is also very weird.  As I think it is related to the
data I'm using, I join them in attachement.
I'm stuck, so if anyone have a good idea on a solution, I will really
appreciate.

Thanks,

here part of the code:

import numpy as np
import matplotlib.pyplot as plt
from scipy.interpolate import UnivariateSpline

def openfile(infilename):

    ifile = open(infilename, 'r') # open file for reading

    lines = ifile.readlines()
    ifile.close()
    return lines

def extractData(lines):
    data=[]
    CV=[]

    for i in range(len(lines)):
        item=lines[i].split()
        for j in range(len(item)):
            item[j]=float(item[j])
            data.append(item[j])

    CV=np.array(data)
    CV.shape = (len(CV)/3,3)
    return CV

if __name__ == "__main__":

    lines=openfile("D:\capamos\LOCOS\cap15L1_rec_mod.csv")
    CV=extractData(lines)
    Vg1=CV[:,0]
    C1=CV[:,1]
    Cmax=C1.max()
    Cmin=C1.min()
    S=0.002
    Cfb=compute(Cmax,Cmin,S) #compute the flat band capacitance
    print "Cfb=",Cfb

    splineCV= UnivariateSpline(Vg1,C1,s=0)
    x = linspace(-5, 5, 1000)   # just to draw the spline function
    y=splineCV(x)
    Vfb=splineCV(Cfb)  # find the flat band voltage at Cfb
    print "Vfb=",Vfb
    print y

    plt.figure(1)
    p1=plot(Vg1,C1,'b',label='edge')
    p2=plot(x,y,'g')
    plt.axis([-6,6,1e-11,80e-12])
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20110416/76a87eb6/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cap15L1_rec_mod.csv
Type: text/csv
Size: 5147 bytes
Desc: not available
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20110416/76a87eb6/attachment.csv>


More information about the SciPy-User mailing list