-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathProcess_GNSS_rawdata.py
More file actions
90 lines (66 loc) · 2.09 KB
/
Process_GNSS_rawdata.py
File metadata and controls
90 lines (66 loc) · 2.09 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
import numpy as np
import matplotlib.pyplot as plt
def get_long_lat(file_nm):
"""
get longtitude and latitud
for plot: longtitude -- x
latitude -- y
"""
records = []
with open(file_nm,'r') as fh:
records = fh.readlines()
x_set = []
y_set = []
for r in records:
r = r.split(',')
x_set.append(float(r[4])*0.01) # longtitude to x_set
y_set.append(float(r[2])*0.01) # latitude to y_set
return x_set, y_set
def covariance(x_set, y_set):
"""
calculate the covariance of x and y
"""
return np.cov(x_set, y_set)
def main():
x_set, y_set = get_long_lat("new_gpgga.txt")
result = covariance(x_set, y_set)
print(result)
print(np.mean(x_set),np.mean(y_set))
plt.figure()
plt.xlabel('Longitude')
plt.ylabel('Latitude')
ax = plt.gca()
ax.spines['top'].set_color('none')
ax.spines['right'].set_color('none')
ax.xaxis.set_ticks_position('bottom')
ax.spines['bottom'].set_position(('data', np.mean(y_set)))
ax.yaxis.set_ticks_position('left')
ax.spines['left'].set_position(('data', np.mean(x_set)))
#plt.xlim(min(x_set), max(x_set))
#plt.ylim(min(y_set), max(y_set))
plt.xticks([])
plt.yticks([])
#plt.text(np.mean(x_set),np.mean(y_set),(round(np.mean(x_set),2),round(np.mean(y_set)),2),color='r')
plt.scatter(x_set,y_set,marker='.')
plt.scatter(np.mean(x_set),np.mean(y_set),marker = '*')
plt.show()
#x = np.linspace(-5, 5, 100)
#y1 = 0.5 * x
#y2 = x * x
#plt.figure()
#plt.xlabel('Longitude')
#plt.ylabel('Latitude')
#ax = plt.gca()
#ax.spines['right'].set_color('none')
#ax.spines['top'].set_color('none')
#ax.xaxis.set_ticks_position('bottom')
#ax.yaxis.set_ticks_position('left')
#ax.spines['bottom'].set_position(('data', 0))
#ax.spines['left'].set_position(('data', 20))
#plt.xlim(-50, 50) # 设定绘图范围
#plt.ylim(-10, 10)
#plt.plot(x, y1, linestyle='--')
#plt.plot(x, y2)
#plt.show()
if __name__ == "__main__":
main()