-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathqcplot.py
More file actions
executable file
·109 lines (91 loc) · 2.91 KB
/
qcplot.py
File metadata and controls
executable file
·109 lines (91 loc) · 2.91 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/usr/bin/python
# -*- coding: UTF-8 -*-
"""
.. module:: qcplot.py
.. moduleauthor:: Siki Zoltan, Takacs Bence
Sample application to plot teqc output
this python script merges teqc output files (.azi, .ele, .sn?)
usage of teqc: teqc +qc -nav brdc1690.15n bute1690.15o
the output of qcplot.py is sent to stdout which contains each measurement in a
separate line
format: azimuth elevation snr1 (or snr2)
example: python qcplot.py bute1690 sn1
:param argv[1]: file name
:param argv[2]: type of plot sn1 (=snr1) or sn2 (=snr2)
"""
import sys
class qcfile(object):
""" qcfile class handles a ...
"""
def __init__(self, fname):
""" constructor
"""
self.fname = fname # name of data file
self.last = [] # last satelite list
self.state = 0
try:
self.fp = open(fname, 'r')
except IOError:
self.fp = None
self.state = -1
return
# skip first 3 lines
buf = self.fp.readline().strip()
if buf != "COMPACT2":
self.fp.close()
self.fp = None
self.state = -2
return
self.fp.readline()
self.fp.readline()
def __del__(self):
""" Destructor
"""
if not self.fp is None:
self.fp.close()
def next(self):
""" get next items from the next two lines of file
:returns: a dictionary satelite id is the key
"""
buf = self.fp.readline().strip() #number and list of satellites
if not buf:
self.state = -3
return None
if buf != '-1':
self.last = buf.split()[1:]
buf = self.fp.readline() #azimuth/elevation/snr values of satellites
if not buf:
self.state = -3
return None
return dict(zip(self.last, buf.split()))
if len(sys.argv) < 3:
print >> sys.stderr, "usage: ./qcplot.py filename plottype"
exit(1)
if not (sys.argv[2] == 'sn1' or sys.argv[2] == 'sn2'):
print >> sys.stderr, "usage: ./qcplot.py filename plottype"
print >> sys.stderr, "plottype should be sn1 or sn2"
exit(1)
ext = ('.azi', '.ele', '.' + sys.argv[2])
fn = sys.argv[1]
if fn[-4:] in ext:
fn = fn[:-4] # remove extension
[azi, ele, snr] = [qcfile(fn + x) for x in ext]
# check for error
for i in [azi, ele, snr]:
if i.state != 0:
print >> sys.stderr, "error with file: " + i.fname
exit(-1)
while 1:
data_azi = azi.next()
data_ele = ele.next()
data_snr = snr.next()
if azi.state != 0 or ele.state != 0 or snr.state != 0:
break
#output prn, azimuth, elevation, snr
for prn in data_azi:
if prn in data_snr:
if float(data_azi[prn]) < 0:
w = float(data_azi[prn]) + 360.0
else:
w = float(data_azi[prn])
print("%.3f %s %s" % (w, data_ele[prn], data_snr[prn]))