Mercurial > ~darius > hgwebdir.cgi > pyinst
annotate find.py @ 59:dd27521002a5
Change default timeout to 500msec
author | Daniel O'Connor <doconnor@gsoft.com.au> |
---|---|
date | Fri, 08 Jan 2021 14:04:09 +1030 |
parents | 91b476ebc0f2 |
children |
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 |
56 | 7 from functools import reduce |
38
7d76b1d70096
Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
8 |
7d76b1d70096
Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
9 if __name__ == "__main__": |
7d76b1d70096
Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
10 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
|
11 |
7d76b1d70096
Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
12 minlev = None |
7d76b1d70096
Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
13 exptag = None |
7d76b1d70096
Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
14 dostats = False |
7d76b1d70096
Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
15 for o, a in opts: |
7d76b1d70096
Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
16 if o == "-h": |
56 | 17 print("""Find data files with certain characteristics |
38
7d76b1d70096
Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
18 |
7d76b1d70096
Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
19 %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
|
20 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
|
21 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
|
22 -s Print stats about files |
56 | 23 """) |
38
7d76b1d70096
Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
24 elif o == "-e": |
7d76b1d70096
Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
25 exptag = a |
7d76b1d70096
Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
26 elif o == "-m": |
7d76b1d70096
Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
27 minlev = float(a) |
7d76b1d70096
Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
28 elif o == "-s": |
7d76b1d70096
Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
29 dostats = True |
7d76b1d70096
Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
30 else: |
56 | 31 print("Unknown option " + o) |
38
7d76b1d70096
Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
32 sys.exit(1) |
7d76b1d70096
Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
33 |
7d76b1d70096
Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
34 if len(args) == 0: |
56 | 35 print("Need at least one file to analyse") |
38
7d76b1d70096
Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
36 sys.exit(1) |
7d76b1d70096
Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
37 |
7d76b1d70096
Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
38 minfiles = [] |
7d76b1d70096
Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
39 if dostats: |
56 | 40 print("%-50s %7s %7s %7s (dBm)" % ("Name", "Min", "Mean", "Max")) |
38
7d76b1d70096
Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
41 for fn in args: |
7d76b1d70096
Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
42 dfile = datafile.DataFile(fn) |
7d76b1d70096
Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
43 |
7d76b1d70096
Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
44 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
|
45 continue |
7d76b1d70096
Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
46 |
7d76b1d70096
Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
47 if minlev != None: |
7d76b1d70096
Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
48 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
|
49 minfiles.append(fn) |
7d76b1d70096
Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
50 |
7d76b1d70096
Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
51 if dostats: |
56 | 52 print("%-50s %7.2f %7.2f %7.2f" % (fn, dfile.powers.min(), dfile.powers.mean(), dfile.powers.max())) |
38
7d76b1d70096
Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
53 |
7d76b1d70096
Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
54 if minlev != None: |
7d76b1d70096
Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
55 if dostats: |
56 | 56 print("") |
57 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
|
58 for fn in minfiles: |
56 | 59 print(fn) |
38
7d76b1d70096
Add file to generate stats on data files.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
60 |