-
Notifications
You must be signed in to change notification settings - Fork 3
/
raw2rinex.py
58 lines (57 loc) · 2.04 KB
/
raw2rinex.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
55
56
57
58
import sys
import json
import getopt
import ReadHeader
from ReadEpoch import RawDataReader
import processGNSSMeas as pro
from convert2rinex import Convert
def raw2rinex(conf_file):
with open(conf_file) as f:
conf = json.load(f)
convertType = conf['type']
dirpath = conf['dir_path']
rawpath = conf['raw_path']
nHead,HeadInfor = ReadHeader.read_rawhead(dirpath + rawpath)
rawreader = RawDataReader(dirpath + rawpath,nHead,HeadInfor)
if convertType.upper() == 'RAW':
rfile = dirpath + rawpath.replace("txt","o")
# read from rawfile
gnssRaw = pro.GnssRaw()
gnssMeas = pro.GnssMeas()
rinexConv = Convert(rfile,HeadInfor)
print("START")
for gnssRaw in rawreader.raw_epochstream(gnssRaw):
print("Process one raw epoch data...")
if gnssRaw is None:
continue
gnssMeas.process(gnssRaw.gnssRaw)
if (gnssMeas.iepoch - 1) == 1:
rinexConv.addRinexHead(gnssMeas)
rinexConv.gnssmeas2rinex(gnssMeas)
print('Epoch Number : %d' % (gnssMeas.iepoch - 1))
print('END')
elif convertType.upper() == 'FIX':
rfile = dirpath + rawpath.replace("txt","out")
gpsLoc = pro.GpsLoc(rfile)
print("START")
iepoch = 0
for lfix in rawreader.fix_epochstream(gpsLoc):
print("Process one fix epoch data...")
iepoch += 1
print('Epoch Number : %d' % iepoch)
print('END')
else:
print("wrong type[%s]! confgure file[type] option: fix/raw." % convertType)
if __name__ == "__main__":
try:
opts,args = getopt.getopt(sys.argv[1:],"hc:",["conf="])
except getopt.GetoptError:
print("raw2rinex.py -c <confgure file>")
sys.exit(2)
for opt,arg in opts:
if opt == '-h':
print("raw2rinex.py -c <confgure file>")
sys.exit()
elif opt in ("-c","--conf"):
conf_file = arg
raw2rinex(conf_file)