forked from dshean/sfm_tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rtklib_pos_stats.py
executable file
·66 lines (54 loc) · 1.74 KB
/
rtklib_pos_stats.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
59
60
61
62
63
64
65
66
#! /usr/bin/env python
"""
Compute final base position and statistics
Input is pos file from RTKLIB
David Shean
dshean@gmail.com
"""
import os
import argparse
import numpy as np
import pandas as pd
from pygeotools.lib import geolib
#Hack to update solution status
def get_solution_status(Q):
Q = np.round(Q)
out = None
if Q == 1.0:
out = 'FIX'
elif Q == 2.0:
out = 'FLOAT'
elif Q == 5.0:
out = 'SINGLE'
return out
def getparser():
parser = argparse.ArgumentParser(description='Comptue base position from PPK position output from RTKLIB')
parser.add_argument('ppk_pos_fn', type=str, help='PPK pos filename')
return parser
def main():
parser = getparser()
args = parser.parse_args()
ppk_pos_fn = args.ppk_pos_fn
header = 'Date UTC latitude(deg) longitude(deg) height(m) Q ns sdn(m) sde(m) sdu(m) sdne(m) sdeu(m) sdun(m) age(s) ratio'
print('Loading: %s' % ppk_pos_fn)
ppk_pos = pd.read_csv(ppk_pos_fn, comment='%', delim_whitespace=True, names=header.split(), parse_dates=[[0,1]])
#Add filter to include only fix positions
#Compute statistics for pos
ppk_pos_mean = ppk_pos.mean()
ppk_pos_std = ppk_pos.std()
ppk_pos_med = ppk_pos.median()
ppk_pos_nmad = (abs(ppk_pos.drop('Date_UTC', axis=1) - ppk_pos_med)).median()
ppk_pos_itrf = geolib.ll2itrf(ppk_pos_med['longitude(deg)'], ppk_pos_med['latitude(deg)'], ppk_pos_med['height(m)'])
#Should format output to be mean +/- std in meters
print("\nMean")
print(ppk_pos_mean)
print("\nStd")
print(ppk_pos_std)
print("\nMedian")
print(ppk_pos_med)
print("\nNMAD")
print(ppk_pos_nmad)
print("\nITRF")
print(ppk_pos_itrf)
if __name__ == "__main__":
main()