FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Aether/srcPython/satellite_test.py at refs/heads/develop · AetherModel/Aether · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
AetherModel
/
Aether
Public
Notifications
You must be signed in to change notification settings
Fork
31
Star
25
Code
Issues
21
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
Aether
/
srcPython
/
satellite_test.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
89 lines (78 loc) · 3.26 KB
Breadcrumbs
Aether
/
srcPython
/
satellite_test.py
Copy path
File metadata and controls
executable file
·
89 lines (78 loc) · 3.26 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
#!/usr/bin/env python3
import
matplotlib
.
pyplot
as
plt
import
numpy
as
np
def
sat_line
(
line
):
"""Convert a line of satellite file into time and position."""
if
line
is
None
:
return
None
line
=
line
.
strip
().
split
(
", "
)
return
[
int
(
line
[
i
])
for
i
in
range
(
6
)]
+
[
float
(
line
[
i
])
for
i
in
range
(
6
,
9
,
1
)]
def
log_line
(
line
):
"""Convert a line of log file into time and position."""
if
line
is
None
:
return
None
line
=
line
.
strip
().
split
(
' '
)
# Need to neglect milliseconds here
return
[
int
(
line
[
i
])
for
i
in
range
(
6
)]
+
[
float
(
line
[
i
])
for
i
in
range
(
7
,
10
,
1
)]
def
calc_diff
(
x
:
list
,
y
:
list
):
"""Calculate the error between two positions."""
if
abs
(
x
[
0
]
-
y
[
0
])
>
180
:
# One point close to 0 and the other close to 360
return
360
-
abs
(
x
[
0
]
-
y
[
0
])
+
abs
(
x
[
1
]
-
y
[
1
])
+
abs
(
x
[
2
]
-
y
[
2
])
else
:
return
sum
([
abs
(
a
-
b
)
for
a
,
b
in
zip
(
x
,
y
)])
def
main
():
"""Check whether the output is correct by visualizing the difference of location."""
# Open the satellite file and log file
with
open
(
"UA/inputs/sat_20110320.csv"
,
'r'
,
encoding
=
"utf-8"
)
as
sat
:
with
open
(
"UA/output/sat_20110320_log.txt"
,
'r'
,
encoding
=
"utf-8"
)
as
log
:
# Skip the first two lines of satellite file and the first line of log file
next
(
sat
)
next
(
sat
)
next
(
log
)
# Initialize the times and percentage of error to plot
times_plot
=
[]
diff_plot
=
[]
sv
=
[]
lv
=
[]
# Use the iterator counter as time
iter_count
=
0
# Start the two-pointer approach
sat_val
=
sat_line
(
next
(
sat
,
None
))
log_val
=
log_line
(
next
(
log
,
None
))
while
sat_val
is
not
None
and
log_val
is
not
None
:
sat_time
=
sat_val
[:
6
]
log_time
=
log_val
[:
6
]
if
sat_time
==
log_time
:
# Add plot list, counter, and go to next for both
times_plot
.
append
(
iter_count
)
sv
.
append
(
sat_val
[
6
:])
lv
.
append
(
log_val
[
6
:])
diff_plot
.
append
(
calc_diff
(
sat_val
[
6
:],
log_val
[
6
:]))
iter_count
+=
1
sat_val
=
sat_line
(
next
(
sat
,
None
))
log_val
=
log_line
(
next
(
log
,
None
))
elif
sat_time
<
log_time
:
# Sat go to next
sat_val
=
sat_line
(
next
(
sat
,
None
))
else
:
# Log go to next, add counter
iter_count
+=
1
log_val
=
log_line
(
next
(
log
,
None
))
# Plot error vs time
fig
=
plt
.
figure
(
figsize
=
(
10
,
10
))
ax1
=
fig
.
add_subplot
(
211
)
ax2
=
fig
.
add_subplot
(
212
)
sv
=
np
.
array
(
sv
)
lv
=
np
.
array
(
lv
)
ax1
.
scatter
(
times_plot
,
sv
[:,
0
])
ax1
.
scatter
(
times_plot
,
lv
[:,
0
])
ax1
.
set_xlabel
(
"Time (15s)"
)
ax1
.
set_ylabel
(
"Longitudes (deg)"
)
ax2
.
plot
(
times_plot
,
diff_plot
)
ax1
.
set_xlabel
(
"Time (15s)"
)
ax2
.
set_ylabel
(
"Total Difference (deg + km)"
)
fig
.
savefig
(
"Satellite_log.png"
)
plt
.
close
()
if
__name__
==
"__main__"
:
main
()
Back
|
FazBrowse Home
|
New Git URL