#!/usr/bin/python -itt import struct import sys import numpy as np import rlcompleter import readline readline.parse_and_bind('tab: complete') import matplotlib.pyplot as plt import scipy.interpolate print "start" f = open(sys.argv[1]) lines = [] print "file open" for index, line in enumerate(f): line = line.split() if '#' in line[0]: continue line = map(float, line) print index, line if len(line) == 0: continue lines.append(line) data = np.array(lines) x = data[:,0] y = data[:,1] w = None plt.ion() fig = plt.figure() #plt.plot(x,y, '.') #scipy.interpolate.UnivariateSpline #(self, x, y, w=None, bbox=[None, None], k=3, s=None) #spline = scipy.interpolate.UnivariateSpline( x=x ,y=y ,w=w ) #PiecewisePolynomial # __init__(self, xi, yi, orders=None, direction=None) #spline = scipy.interpolate.PiecewisePolynomial(x,y) # did not work # ringing like hell! #spline = scipy.interpolate.BarycentricInterpolator(x,y) spline = scipy.interpolate.InterpolatedUnivariateSpline(x,y) #spline2 = scipy.interpolate.UnivariateSpline(x,y) # generate y-x-data from spline just for plotting. xx = np.linspace( x[0], x[-1], len(x)*10) xx = x #plt.plot(xx,spline(xx), ':') plt.plot(xx,spline(xx)-y, ':') #plt.plot(xx,spline2(xx), ':')