3 from __future__ import division
9 def parse_data(l, state):
10 state['data'].append([float(x) for x in filter(None, l.split(' '))])
13 def parse_event(l, state):
14 components = filter(None, l.split(' '))
15 vals = [float(x) for x in components[1:]]
16 if not components[0] in state:
17 state[components[0]] = [vals]
19 state[components[0]].append(vals)
22 def read_line(fd, state):
28 return parse_data(l, state)
30 return parse_event(l, state)
41 newstate = read_line(fd, state)
44 def make_xticks(start, end, numticks):
45 return range(int(start), int(end), int((start-end)/numticks))
48 l = sys.stdin.readline()
49 labels = l.strip().split(';')
50 state = read_data(sys.stdin)
52 lost_packets = state['packet-lost']
53 obsv_packets = state['packet-observed']
54 sent_packets = state['packet-sent']
55 recd_packets = state['packet-received']
57 domain = [x[0] for x in data]
58 for i in range(1,len(labels)):
59 pylab.plot(domain, [x[i] for x in data], label=labels[i])
60 pylab.plot([x[0] for x in lost_packets], [x[1] for x in lost_packets],
61 label='Client sent packet, but dropped', marker='x', linestyle=None, ms=8)
62 pylab.plot([x[0] for x in sent_packets], [x[1] for x in sent_packets],
63 label='Client sent packet', marker='^', linestyle=None, ms=8)
64 pylab.plot([x[0] for x in obsv_packets], [x[1] for x in obsv_packets],
65 label='Remote time observation', marker='D', linestyle=None, ms=8)
66 pylab.plot([x[0] for x in recd_packets], [x[1] for x in recd_packets],
67 label='Client received packet', marker='v', linestyle=None, ms=8)
69 pylab.ylabel(r'Clock time (s)')
70 pylab.xlabel(r'Real time (s)')
76 parser = optparse.OptionParser()
78 title = ' '.join(args[1:])