[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[freehaven-cvs] Add a script to post-process analyzed results into a...
Update of /home/freehaven/cvsroot/doc/e2e-traffic/src
In directory moria.mit.edu:/tmp/cvs-serv4749
Added Files:
postproc.py
Log Message:
Add a script to post-process analyzed results into a gnuplot-friendly format
--- NEW FILE: postproc.py ---
#!/usr/bin/python
# post-process a results file
import re
def val(s):
try:
return float(s)
except ValueError:
return s
def pp(fn, xvar, yvar, gvars):
f = open(fn, 'r')
data = {}
for line in f.xreadlines():
line = re.sub(r':\s*',':', line)
line = line.replace("%","")
items = line.split()
xval=yval=None
gvals = []
for item in items:
c = item.split(":")
if len(c) == 2:
if c[0] == xvar:
xval = float(c[1])
elif c[0] == yvar:
yval = float(c[1])
elif c[0] in gvars:
gvals.append((gvars.index(c[0]),c[0],val(c[1])))
gvals.sort()
if xval == None:
print "missing",xvar
continue
if yval == None:
print "missing",yvar
continue
data.setdefault(tuple(gvals), []).append((xval,yval))
ks = data.keys()
ks.sort()
for group in ks:
print
print "# ","; ".join(["%s=%s"%(k,v) for idx,k,v in group])
d = data[group]
d.sort()
for x,y in d:
print x,y
if __name__ == '__main__':
import sys
fn = sys.argv[1]
xv = sys.argv[2]
yv = sys.argv[3]
gv = sys.argv[4:]
print "# Post-processed from",fn
print "# x variable:",xv
print "# y variable:",yv
print "# grouped by:",gv
pp(fn,xv,yv,gv)
***********************************************************************
To unsubscribe, send an e-mail to majordomo@seul.org with
unsubscribe freehaven-cvs in the body. http://freehaven.net/