tcs = []
gnuplot("set style data lp")
+ gnuplot("set key outside right")
+ #gnuplot("set title \"Au on Si (50min 3.5A 3-6 e-8mbar)\"")
+ #gnuplot("set xlabel \"E (DAC Counts)\"")
+ #gnuplot("set ylabel \"S(E) (ADC/DAC Counts)\"")
+ #gnuplot("set term postscript colour")
+ #gnuplot("set output \"test.eps\"")
for i in range(1, len(sys.argv)):
- tcs.append(GetTCS(GetData(sys.argv[i])))
+ tcs.append(map(lambda e : [e[1], e[2]], GetData(sys.argv[i])))
+ #tcs.append(GetTCS(GetData(sys.argv[i])))
if (len(tcs[i-1]) > 0):
- gnuplot.replot(tcs[i-1])
+ gnuplot.replot(Gnuplot.Data(tcs[i-1], title="", with_="lp"))
+
+ # Now average the data
+
+ avg = odict.odict()
+ for t in tcs:
+ for p in t:
+ if p[0] in avg:
+ avg[p[0]][0] += p[1]
+ avg[p[0]][1] += 1
+ else:
+ avg.update({p[0] : [p[1], 1]})
+
+ for a in avg.keys():
+ avg[a] = float(avg[a][0]) / float(avg[a][1])
+
+ gnuplot.replot(Gnuplot.Data(sorted(avg.items(), key = lambda e : e[0]), title="Average", with_="l lw 2"))
- print("Press enter to exit")
- sys.stdin.readline()
+ sys.stdout.write("Save averaged data as (blank for no save): ")
+ filename = sys.stdin.readline().strip(" \r\n\t")
+ if (filename != ""):
+ out = open(filename, "w", 0)
+ for a in sorted(avg.items(), key = lambda e : e[0]):
+ out.write(str(a[0]) + "\t" + str(a[1]) + "\n")
return 0