Mercurial > ~darius > hgwebdir.cgi > pyinst
annotate plotss.py @ 37:3d2306e39700
Move DataFile class to new file for ease of reuse.
author | Daniel O'Connor <darius@dons.net.au> |
---|---|
date | Wed, 28 Sep 2011 12:29:19 +0930 |
parents | ff63d71e1383 |
children | c6089f1ecc75 |
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 |
37
3d2306e39700
Move DataFile class to new file for ease of reuse.
Daniel O'Connor <darius@dons.net.au>
parents:
36
diff
changeset
|
3 import datafile |
33
e80c2ff5fa87
Add program to plot data files from sitesurvey.py
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
4 import exceptions |
e80c2ff5fa87
Add program to plot data files from sitesurvey.py
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
5 import numpy |
e80c2ff5fa87
Add program to plot data files from sitesurvey.py
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
6 import pylab |
e80c2ff5fa87
Add program to plot data files from sitesurvey.py
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
7 import sys |
e80c2ff5fa87
Add program to plot data files from sitesurvey.py
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
8 |
36
ff63d71e1383
Separate out data file reader into a new class for ease of reuse.
Daniel O'Connor <darius@dons.net.au>
parents:
33
diff
changeset
|
9 def doplot(fname): |
ff63d71e1383
Separate out data file reader into a new class for ease of reuse.
Daniel O'Connor <darius@dons.net.au>
parents:
33
diff
changeset
|
10 dfile = DataFile(fname) |
ff63d71e1383
Separate out data file reader into a new class for ease of reuse.
Daniel O'Connor <darius@dons.net.au>
parents:
33
diff
changeset
|
11 |
37
3d2306e39700
Move DataFile class to new file for ease of reuse.
Daniel O'Connor <darius@dons.net.au>
parents:
36
diff
changeset
|
12 xdata = dfile.freqs / 1e6 |
3d2306e39700
Move DataFile class to new file for ease of reuse.
Daniel O'Connor <darius@dons.net.au>
parents:
36
diff
changeset
|
13 ydata = dfile.powers |
36
ff63d71e1383
Separate out data file reader into a new class for ease of reuse.
Daniel O'Connor <darius@dons.net.au>
parents:
33
diff
changeset
|
14 pylab.title("Tag \'" + dfile['TAG'] + "\' at " + dfile['TIMESTAMP']) |
33
e80c2ff5fa87
Add program to plot data files from sitesurvey.py
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
15 pylab.xlabel("Frequency (MHz)") |
e80c2ff5fa87
Add program to plot data files from sitesurvey.py
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
16 pylab.ylabel("Level (dBm)") |
e80c2ff5fa87
Add program to plot data files from sitesurvey.py
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
17 annstr = "FStart\t%.2f MHz\nFStop\t%.2f MHz\nPoints\t%d" % ( |
36
ff63d71e1383
Separate out data file reader into a new class for ease of reuse.
Daniel O'Connor <darius@dons.net.au>
parents:
33
diff
changeset
|
18 float(dfile['FSTART']) / 1e6, |
ff63d71e1383
Separate out data file reader into a new class for ease of reuse.
Daniel O'Connor <darius@dons.net.au>
parents:
33
diff
changeset
|
19 float(dfile['FSTOP']) / 1e6, |
33
e80c2ff5fa87
Add program to plot data files from sitesurvey.py
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
20 len(xdata)) |
e80c2ff5fa87
Add program to plot data files from sitesurvey.py
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
21 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
|
22 |
e80c2ff5fa87
Add program to plot data files from sitesurvey.py
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
23 annstr = "Video BW\t%.1f kHz\nResol. BW\t%.1f kHz\nAttenuation\t%.1f dB\nRef Level\t%.1f dBm" % ( |
36
ff63d71e1383
Separate out data file reader into a new class for ease of reuse.
Daniel O'Connor <darius@dons.net.au>
parents:
33
diff
changeset
|
24 float(dfile['VIDBW']) / 1e3, |
ff63d71e1383
Separate out data file reader into a new class for ease of reuse.
Daniel O'Connor <darius@dons.net.au>
parents:
33
diff
changeset
|
25 float(dfile['RESBW']) / 1e3, |
ff63d71e1383
Separate out data file reader into a new class for ease of reuse.
Daniel O'Connor <darius@dons.net.au>
parents:
33
diff
changeset
|
26 float(dfile['ATTEN']), |
ff63d71e1383
Separate out data file reader into a new class for ease of reuse.
Daniel O'Connor <darius@dons.net.au>
parents:
33
diff
changeset
|
27 float(dfile['REFLEV'])) |
33
e80c2ff5fa87
Add program to plot data files from sitesurvey.py
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
28 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
|
29 pylab.grid(True) |
e80c2ff5fa87
Add program to plot data files from sitesurvey.py
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
30 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
|
31 pylab.show() |
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 if __name__ == "__main__": |
e80c2ff5fa87
Add program to plot data files from sitesurvey.py
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
34 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
|
35 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
|
36 sys.exit(1) |
e80c2ff5fa87
Add program to plot data files from sitesurvey.py
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
37 |
e80c2ff5fa87
Add program to plot data files from sitesurvey.py
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
38 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
|
39 doplot(fn) |
e80c2ff5fa87
Add program to plot data files from sitesurvey.py
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
40 |