Mercurial > ~darius > hgwebdir.cgi > pyinst
comparison plotss.py @ 33:e80c2ff5fa87
Add program to plot data files from sitesurvey.py
author | Daniel O'Connor <darius@dons.net.au> |
---|---|
date | Wed, 21 Sep 2011 15:34:49 +0930 |
parents | |
children | ff63d71e1383 |
comparison
equal
deleted
inserted
replaced
32:660a2997e720 | 33:e80c2ff5fa87 |
---|---|
1 #!/usr/bin/env python | |
2 | |
3 import exceptions | |
4 import numpy | |
5 import pylab | |
6 import sys | |
7 | |
8 def doplot(fname): | |
9 f = file(fname) | |
10 opts = {} | |
11 for line in f: | |
12 key, value = line.strip().split(' ', 1) | |
13 try: | |
14 opts[key] = int(value) | |
15 except exceptions.ValueError, e: | |
16 try: | |
17 opts[key] = float(value) | |
18 except exceptions.ValueError, e: | |
19 opts[key] = value | |
20 | |
21 xdata = numpy.fromstring(opts['XDATA'], sep = ', ') | |
22 ydata = numpy.fromstring(opts['YDATA'], sep = ', ') | |
23 xdata /= 1e6 | |
24 pylab.title("Tag \'" + opts['TAG'] + "\' at " + opts['TIMESTAMP']) | |
25 pylab.xlabel("Frequency (MHz)") | |
26 pylab.ylabel("Level (dBm)") | |
27 annstr = "FStart\t%.2f MHz\nFStop\t%.2f MHz\nPoints\t%d" % ( | |
28 float(opts['FSTART']) / 1e6, | |
29 float(opts['FSTOP']) / 1e6, | |
30 len(xdata)) | |
31 pylab.annotate(annstr, xy=(5, -40), xycoords='axes points') | |
32 | |
33 annstr = "Video BW\t%.1f kHz\nResol. BW\t%.1f kHz\nAttenuation\t%.1f dB\nRef Level\t%.1f dBm" % ( | |
34 float(opts['VIDBW']) / 1e3, | |
35 float(opts['RESBW']) / 1e3, | |
36 float(opts['ATTEN']), | |
37 float(opts['REFLEV'])) | |
38 pylab.annotate(annstr, xy=(-140, -55), xycoords='axes points') | |
39 pylab.grid(True) | |
40 pylab.plot(xdata, ydata, linestyle='solid', marker='.') | |
41 pylab.show() | |
42 | |
43 if __name__ == "__main__": | |
44 if len(sys.argv) < 2: | |
45 print "Need at least one file to plot" | |
46 sys.exit(1) | |
47 | |
48 for fn in sys.argv[1:]: | |
49 doplot(fn) | |
50 |