annotate plotss.py @ 49:22187590594b

Turn averaging on otherwise we throw away all but the last sweep.
author Daniel O'Connor <doconnor@gsoft.com.au>
date Thu, 31 Jan 2013 12:53:22 +1030
parents 3c01bd3f2786
children 91b476ebc0f2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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):
39
c6089f1ecc75 Use DataFile properly..
Daniel O'Connor <darius@dons.net.au>
parents: 37
diff changeset
10 dfile = datafile.DataFile(fname)
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
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)")
40
3c01bd3f2786 Tabs don't work when saving a file, or on windows so don't use them.
Daniel O'Connor <darius@dons.net.au>
parents: 39
diff changeset
17 annstr = "FStart: %.2f MHz\nFStop: %.2f MHz\nPoints: %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
40
3c01bd3f2786 Tabs don't work when saving a file, or on windows so don't use them.
Daniel O'Connor <darius@dons.net.au>
parents: 39
diff changeset
23 annstr = "Video BW: %.1f kHz\nResol. BW: %.1f kHz\nAttenuation: %.1f dB\nRef Level: %.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