-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstatistic.py
More file actions
141 lines (115 loc) · 5.27 KB
/
statistic.py
File metadata and controls
141 lines (115 loc) · 5.27 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# -*- coding: utf-8 -*-
"""
Created on Tue Mar 23 11:17:43 2021.
@author: Michael
"""
import sys
# Import local modules
from lib import gui_statistic as gui
from lib import stat_df
from lib import Concat
from lib import stat
# Lpocal function
def _err_msg(valid1, valid2, valid3, file_name1, file_name2, file_name3):
if valid1:
pass
else:
raise Exception("Failed importation of " + file_name1 + '\n' +
'_columns doesn\'t apply to the .csv file')
sys.exit(1)
if valid2:
pass
else:
raise Exception("Failed importation of : " + file_name2 + '\n' +
'_columns doesn\'t apply to the .csv file')
sys.exit(1)
if valid3:
pass
else:
raise Exception("Failed importation of : " + file_name3 + '\n' +
'_columns doesn\'t apply to the .csv file')
sys.exit(1)
# In[]:
# Call the interface class
app = gui.Interface()
app.title('Measurement statistics')
app.mainloop()
_folder_name, zone, save_csv = app.output()
_columns = ['timestamp', 'lon', 'lat', 'posMode', 'numSV', 'difAge',
'HDOP', 'dist']
# =============================================================================
# Extract dataframe
# =============================================================================
if 'DataBase' in _folder_name:
df_net = Concat(_folder_name, 'NetR9', zone, save_csv).main()
df_swi = Concat(_folder_name, 'swipos_ublox', zone, save_csv).main()
df_sap = Concat(_folder_name, 'sapcorda', zone, save_csv).main()
elif 'res/data' in _folder_name:
_file_name1 = _folder_name + '/NetR9_' + zone + '.csv'
_file_name2 = _folder_name + '/swipos_ublox_' + zone + '.csv'
_file_name3 = _folder_name + '/sapcorda_' + zone + '.csv'
df_net, _valid1 = stat_df(_file_name1, _columns)
df_swi, _valid2 = stat_df(_file_name2, _columns)
df_sap, _valid3 = stat_df(_file_name3, _columns)
_err_msg(_valid1, _valid2, _valid3, _file_name1, _file_name2, _file_name3)
# =============================================================================
# "Sync" Dataframe
# =============================================================================
df_net = df_net.set_index('timestamp', drop=False)
df_swi = df_swi.set_index('timestamp', drop=False)
df_sap = df_sap.set_index('timestamp', drop=False)
df_net = df_net.loc[df_net.index.intersection(df_sap.index)]
df_swi = df_swi.loc[df_swi.index.intersection(df_sap.index)]
# =============================================================================
# (A) NetR9
# =============================================================================
if df_net is not None:
netr9 = stat.Statistic(df_net, 'NetR9 avec swipos')
df_net = netr9.rmv_bad_days(df_net)
# netr9.plt_bad_days(df_net, ['2021-06-23', '2021-07-06'])
# netr9.spatial_analysis(df_net, 100)
accuracy_net = netr9.accuracy(df_net, True)
integrity_net = netr9.integrity(df_net)
# =============================================================================
# (B) u-blox with swipos
# =============================================================================
if df_swi is not None:
swipos = stat.Statistic(df_swi, 'u-blox avec swipos')
df_swi = swipos.rmv_bad_days(df_swi)
# swipos.spatial_analysis(df_swi, 100)
accuracy_swi = swipos.accuracy(df_swi, True)
integrity_swi = swipos.integrity(df_swi)
# =============================================================================
# (C) u-blox with sapcorda
# =============================================================================
if df_sap is not None:
sapcorda = stat.Statistic(df_sap, 'u-blox avec SAPA')
df_sap = sapcorda.rmv_bad_days(df_sap)
# sapcorda.spatial_analysis(df_sap, 100)
accuracy_sap = sapcorda.accuracy(df_sap, True)
integrity_sap = sapcorda.integrity(df_sap)
# =============================================================================
# PLot Histogram HPE
# =============================================================================
# TODO: This part need to be adapted
# do_xlim = True
# save_plt1 = False
# if False:
# fname2 = './res/stat/Accuracy_PDF_CFD_swipos_sapos.png'
# fname3 = './res/stat/Accuracy_PDF_CFD_netr9_ublox.png'
# receiver = 'u-blox avec RTK VRS GIS/GEO swipos'
# receiver2 = 'u-blox avec PPP-RTK SAPOS'
# receiver3 = 'NetR9 avec RTK VRS GIS/GEO swipos'
# fname2 = [save_plt1, fname2]
# fname3 = [save_plt1, fname3]
# dist, bins, weights, CDF, quantile = _pdf_cdf(df)
# dist2, bins2, weights2, CDF2, quantile2 = _pdf_cdf(df2)
# dist3, bins3, weights3, CDF3, quantile3 = _pdf_cdf(df3)
# tools.plotHistAcc2(dist, bins, weights, CDF, quantile, receiver, 'blue',
# dist2, bins2, weights2, CDF2, quantile2, fname2, receiver2, 'orange', do_xlim)
# tools.plotHistAcc2(dist, bins, weights, CDF, quantile, receiver, 'blue',
# dist3, bins3, weights3, CDF3, quantile3, fname3, receiver3, 'red', do_xlim)
# # Plot HPE
# tools.plot_HPE(df, df2, df3, receiver, receiver2,
# receiver3, posMode, posMode2, posMode2)
# receiver3, posMode, posMode2, posMode2)