annotate find.py @ 46:a6e5c97b4767

Add noise test
author Daniel O'Connor <darius@dons.net.au>
date Thu, 20 Dec 2012 11:48:19 +1030
parents df1b4d7e988f
children 91b476ebc0f2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38
7d76b1d70096 Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
1 #!/usr/bin/env python
7d76b1d70096 Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
2
7d76b1d70096 Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
3 import datafile
7d76b1d70096 Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
4 import getopt
7d76b1d70096 Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
5 import numpy
7d76b1d70096 Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
6 import sys
7d76b1d70096 Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
7
7d76b1d70096 Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
8 if __name__ == "__main__":
7d76b1d70096 Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
9 opts, args = getopt.getopt(sys.argv[1:], "e:hm:s")
7d76b1d70096 Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
10
7d76b1d70096 Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
11 minlev = None
7d76b1d70096 Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
12 exptag = None
7d76b1d70096 Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
13 dostats = False
7d76b1d70096 Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
14 for o, a in opts:
7d76b1d70096 Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
15 if o == "-h":
7d76b1d70096 Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
16 print """Find data files with certain characteristics
7d76b1d70096 Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
17
7d76b1d70096 Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
18 %s [-h] [-e exp] [-m min] [-s] file [file ..]
7d76b1d70096 Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
19 exp Limit to experiment tag exp
7d76b1d70096 Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
20 min Find files with power greater than min
7d76b1d70096 Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
21 -s Print stats about files
7d76b1d70096 Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
22 """
7d76b1d70096 Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
23 elif o == "-e":
7d76b1d70096 Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
24 exptag = a
7d76b1d70096 Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
25 elif o == "-m":
7d76b1d70096 Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
26 minlev = float(a)
7d76b1d70096 Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
27 elif o == "-s":
7d76b1d70096 Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
28 dostats = True
7d76b1d70096 Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
29 else:
7d76b1d70096 Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
30 print "Unknown option " + o
7d76b1d70096 Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
31 sys.exit(1)
7d76b1d70096 Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
32
7d76b1d70096 Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
33 if len(args) == 0:
7d76b1d70096 Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
34 print "Need at least one file to analyse"
7d76b1d70096 Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
35 sys.exit(1)
7d76b1d70096 Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
36
7d76b1d70096 Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
37 minfiles = []
7d76b1d70096 Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
38 if dostats:
7d76b1d70096 Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
39 print "%-50s %7s %7s %7s (dBm)" % ("Name", "Min", "Mean", "Max")
7d76b1d70096 Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
40 for fn in args:
7d76b1d70096 Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
41 dfile = datafile.DataFile(fn)
7d76b1d70096 Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
42
7d76b1d70096 Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
43 if exptag != None and dfile['TAG'] != exptag:
7d76b1d70096 Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
44 continue
7d76b1d70096 Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
45
7d76b1d70096 Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
46 if minlev != None:
7d76b1d70096 Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
47 if reduce(lambda x, y: x or y, dfile.powers > minlev):
7d76b1d70096 Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
48 minfiles.append(fn)
7d76b1d70096 Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
49
7d76b1d70096 Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
50 if dostats:
7d76b1d70096 Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
51 print "%-50s %7.2f %7.2f %7.2f" % (fn, dfile.powers.min(), dfile.powers.mean(), dfile.powers.max())
7d76b1d70096 Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
52
7d76b1d70096 Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
53 if minlev != None:
7d76b1d70096 Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
54 if dostats:
7d76b1d70096 Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
55 print ""
41
df1b4d7e988f Reword text to be clearer.
Daniel O'Connor <darius@dons.net.au>
parents: 38
diff changeset
56 print "Files with any sample exceeding %.2f dBm:" % (minlev)
38
7d76b1d70096 Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
57 for fn in minfiles:
7d76b1d70096 Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
58 print fn
7d76b1d70096 Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
59