1
2 """Compare files with Gnuplot"""
3
4 from glob import glob
5 from os import path
6
8 """Class that compares a number of files with gnuplot"""
9
11 """
12 @param files: a list of tuples: (filename,name [,col])
13 @param col: the default column to use
14 """
15
16 self.files=[]
17 for f in files:
18 if len(f)==3:
19 self.files.append(f)
20 else:
21 self.files.append(f+(col,))
22
24 """
25 @param name: Name of the file
26 """
27
28 fh=open(name,'w')
29
30 fh.write("plot ")
31 first=True
32
33 for f in self.files:
34 if first:
35 first=False
36 else:
37 fh.write(" , ")
38
39 fh.write(" \"%s\" using 1:%d title \"%s\" with lines " % (f[0],f[2],f[1]))
40
41 fh.write("\n")
42 fh.close()
43
45 """
46 Wrapper to Gnuplot Compare to compare files with similar names
47 """
48
49 - def __init__(self,pattern,col=2,common=None):
50 """
51 @param pattern: The pattern for which to look
52 @param col: The colum that is to be compared
53 @param common: String that is to be removed from the filename before using it as a name
54 """
55
56 files=[]
57
58 for f in glob(pattern):
59 nm=path.basename(f)
60 if common!=None:
61 nm=nm[len(common):]
62 files.append((f,nm,col))
63
64 GnuplotCompare.__init__(self,files)
65