插入具有不同点数的两组数据

时间:2016-07-14 22:50:21

标签: python interpolation

我试图插入两组复杂数据我无法弄清楚我哪里出错了。你把数据长度放在哪里? 这已经加载了数据吗?示例只有数字

fig1 = plt.figure() 

#load data    
    data1 = np.loadtxt(open("296.csv","rb"),delimiter=",",usecols=(0,1))        
    shape = (np.shape(data1))
    (x,y)=shape 
    len1 = len(data1)
#define data
    trans1 = list()
    wavelength1 = list()
#get data from what row
    for i in range(0,x,1):   
        trans1.append(data1[i,1])
        wavelength1.append(data1[i,0])   

    data3 = np.loadtxt(open("300.csv","rb"),delimiter=",",usecols=(0,1))
    #skiprows=6
    shape = (np.shape(data3))
    (x,y)=shape 
    trans3 = list()
    wavelength3 = list()        
    for i in range(0,x,1):  
        trans3.append(data3[i,1])
        wavelength3.append(data3[i,0])
    len3 = len(data3)

    ax1 = plt.subplot(111)


    x1axis = wavelength1
    x2axis = wavelength2
    x3axis = wavelength3
    y1axis = trans1
    y2axis = trans2
    y3axis = trans3
    ax1.plot(x1axis,y1axis,'blue')
    ax1.plot(x2axis,y2axis,'purple')
    ax1.plot(x3axis,y3axis,'green')
    x = (wavelength1,trans1,len1)
#error with lengths ...
    y = (wavelength3,trans3,len3)
    f = interpolate.interp1d(x, y)
    ax1.axis([1.55,1.65,.9986,.9988])

0 个答案:

没有答案