forked from muccc/iridium-toolkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rx-stats-freq-hist.py
executable file
·54 lines (44 loc) · 1.75 KB
/
rx-stats-freq-hist.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env python
# vim: set ts=4 sw=4 tw=0 et pm=:
# Parses .bits files and displays the distribution
# of the length of received frames
import sys
import matplotlib.pyplot as plt
import getopt
import bitutils
options, remainder = getopt.getopt(sys.argv[1:], 'b:c:eo', [
'bin=',
'minimum_confidence=',
'errors',
'lead_out_required'
])
bin_size = 10000
minimum_confidence = 0
lead_out_required = False
show_errors = False
for opt, arg in options:
if opt in ('-b', '--bin'):
bin_size = int(arg)
elif opt in ('-c', '--minimum_confidence'):
minimum_confidence = int(arg)
elif opt in ('-o', '--lead_out_required'):
lead_out_required = True
elif opt in ('-e', '--errors'):
show_errors = True
else:
print opt
raise Exception("unknown argument?")
messages = bitutils.read_file(remainder)
data = [s['freq'] for s in messages if s['length'] > 100 and s['confidence'] > minimum_confidence and (s['lead_out'] or not lead_out_required) and (s['error'] == show_errors)]
bins = (max(data) - min(data))/bin_size
filename=["<stdin>",",".join(remainder)][remainder is None]
title = "File: %s : Distribution of message frequency. Bin Size: %d, Minimum Confidence: %d" % (filename, bin_size, minimum_confidence)
if lead_out_required:
title += ', lead out needs to be present'
else:
title += ', lead out does not need to be present'
if show_errors:
title += " and having decoding errors"
plt.title(title)
plt.hist(data, bins)
plt.show()