5 # @purpose Process TCS data
13 import re # Regular expressions - for removing comments
14 import odict #ordered dictionary
16 import Gnuplot, Gnuplot.funcutils
18 gnuplot = Gnuplot.Gnuplot()
20 def GetData(filename):
21 input_file = open(filename, "r")
23 for line in input_file:
24 line = re.sub("#.*", "", line).strip("\r\n ")
27 data.append(map(lambda e : float(e), line.split("\t")))
35 for i in range(1, len(data)-1):
36 dE = data[i+1][1] - data[i][1]
42 dI += data[i+1][2] - data[i][2]
44 result.append([data[i][1], (dI / (n * dE)) / data[i][2]])
55 if (len(sys.argv) < 2):
56 sys.stderr.write(sys.argv[0] + " - Require arguments (filename)\n")
60 gnuplot("set style data lp")
61 for i in range(1, len(sys.argv)):
62 tcs.append(GetTCS(GetData(sys.argv[i])))
63 if (len(tcs[i-1]) > 0):
64 gnuplot.replot(tcs[i-1])
67 print("Press enter to exit")
73 if __name__ == "__main__":