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