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