def test1(): xy = [[1,1], [2,5], [3,3], [4,7], [5,6], [6,5], [7,4], [8,3], [9,2], [10,1]] n = len(xy) c = interpolator.buildSpline(xy, n) res = [] for i in [1.2, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5]: res.append(interpolator.interpolate(xy, c, i)) print res
def test2(): f = open('D:\\LEARN\\AnaNas-Python\\1.txt') xy = [] i = 0 for line in f: data = re.findall('\d+\.*\d*\.*\d*', str(line)) time_com = data[0].split('.') time = float(time_com[0])*3600 + float(time_com[1])*60 + float(time_com[2]) xy.append([time, float(data[2])]) int_time = xy[0][0] for i in xy: i[0] = i[0]-int_time n = len(xy) c = interpolator.buildSpline(xy, n) res = [] for i in range(0, int(xy[int(len(xy)-1)][0])): res.append(interpolator.interpolate(xy, c, i)) res_file = open('D:\\LEARN\\AnaNas-Python\\res.txt', 'w') for i in range(0, int(xy[int(len(xy)-1)][0])): res_file.write(str(i)+' '+str(res[i])+'\r\n') init_file = open('D:\\LEARN\\AnaNas-Python\\init.txt', 'w') for i in range(0,int(len(xy)-1)): init_file.write(str(xy[i][0])+' '+str(xy[i][1])+'\r\n')