Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
skais
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Raphael Sturgis
skais
Commits
750d79a2
Commit
750d79a2
authored
3 years ago
by
Raphael
Browse files
Options
Downloads
Plain Diff
Merge branch '2-angles-calculated-using-compute_point_angles-seem-incorect-2' into develop
parents
88a7af3e
abcce8ac
Branches
Branches containing commit
No related tags found
1 merge request
!6
Develop
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
skais/ais/ais_trajectory.py
+16
-4
16 additions, 4 deletions
skais/ais/ais_trajectory.py
skais/tests/ais/test_ais_trajectory.py
+31
-1
31 additions, 1 deletion
skais/tests/ais/test_ais_trajectory.py
with
47 additions
and
5 deletions
skais/ais/ais_trajectory.py
+
16
−
4
View file @
750d79a2
...
@@ -137,17 +137,28 @@ def compute_position_dist_std(dat, radius):
...
@@ -137,17 +137,28 @@ def compute_position_dist_std(dat, radius):
return
dist_means
return
dist_means
@jit
(
nopython
=
True
)
def
angle_between_three_points
(
p1
,
p2
,
p3
):
alpha
=
bearing
(
p2
,
p1
)
beta
=
bearing
(
p2
,
p3
)
result
=
alpha
-
beta
if
result
>
180
:
return
180
-
result
else
:
return
result
def
compute_point_angles
(
dat
):
def
compute_point_angles
(
dat
):
angles
=
np
.
zeros
(
dat
.
shape
[
0
])
angles
=
np
.
zeros
(
dat
.
shape
[
0
])
p1
=
(
dat
[
0
][
0
],
dat
[
0
][
1
])
p2
=
(
dat
[
1
][
0
],
dat
[
1
][
1
])
angles
[
0
]
=
bearing
(
p1
,
p2
)
for
i
in
range
(
1
,
dat
.
shape
[
0
]
-
1
):
for
i
in
range
(
1
,
dat
.
shape
[
0
]
-
1
):
p1
=
(
dat
[
i
-
1
][
0
],
dat
[
i
-
1
][
1
])
p1
=
(
dat
[
i
-
1
][
0
],
dat
[
i
-
1
][
1
])
p2
=
(
dat
[
i
][
0
],
dat
[
i
][
1
])
p2
=
(
dat
[
i
][
0
],
dat
[
i
][
1
])
p3
=
(
dat
[
i
+
1
][
0
],
dat
[
i
+
1
][
1
])
p3
=
(
dat
[
i
+
1
][
0
],
dat
[
i
+
1
][
1
])
alpha
=
bearing
(
p2
,
p1
)
angles
[
i
]
=
angle_between_three_points
(
p1
,
p2
,
p3
)
beta
=
bearing
(
p2
,
p3
)
angles
[
i
]
=
180
-
abs
(
abs
(
alpha
-
beta
)
-
180
)
return
angles
return
angles
...
@@ -182,6 +193,7 @@ def angle_dispersion(dat, radius):
...
@@ -182,6 +193,7 @@ def angle_dispersion(dat, radius):
return
disp
return
disp
class
AISTrajectory
:
class
AISTrajectory
:
def
__init__
(
self
,
df
,
interpolation_time
=
None
):
def
__init__
(
self
,
df
,
interpolation_time
=
None
):
df
=
df
.
drop_duplicates
(
subset
=
[
'
ts_sec
'
])
df
=
df
.
drop_duplicates
(
subset
=
[
'
ts_sec
'
])
...
...
This diff is collapsed.
Click to expand it.
skais/tests/ais/test_ais_trajectory.py
+
31
−
1
View file @
750d79a2
...
@@ -4,7 +4,8 @@ import unittest
...
@@ -4,7 +4,8 @@ import unittest
import
pandas
as
pd
import
pandas
as
pd
import
numpy
as
np
import
numpy
as
np
from
skais.ais.ais_trajectory
import
AISTrajectory
,
compute_std
,
to_rad
,
bearing
,
to_deg
,
compute_point_angles
from
skais.ais.ais_trajectory
import
AISTrajectory
,
compute_std
,
to_rad
,
bearing
,
to_deg
,
compute_point_angles
,
\
angle_between_three_points
class
TestAISTrajectory
(
unittest
.
TestCase
):
class
TestAISTrajectory
(
unittest
.
TestCase
):
...
@@ -354,6 +355,35 @@ class TestAISTrajectory(unittest.TestCase):
...
@@ -354,6 +355,35 @@ class TestAISTrajectory(unittest.TestCase):
self
.
assertAlmostEqual
(
result
,
expected
)
self
.
assertAlmostEqual
(
result
,
expected
)
def
test_angle_between_three_points_1
(
self
):
p1
=
(
0
,
-
10
)
p2
=
(
0
,
0
)
p3
=
(
10
,
0
)
self
.
assertAlmostEqual
(
90
,
angle_between_three_points
.
py_func
(
p1
,
p2
,
p3
),
places
=
3
)
def
test_angle_between_three_points_2
(
self
):
p1
=
(
0
,
-
10
)
p2
=
(
0
,
0
)
p3
=
(
-
10
,
0
)
self
.
assertAlmostEqual
(
-
90
,
angle_between_three_points
.
py_func
(
p1
,
p2
,
p3
),
places
=
3
)
def
test_angle_between_three_points_3
(
self
):
p1
=
(
0
,
-
10
)
p2
=
(
0
,
0
)
p3
=
(
10
,
10
)
self
.
assertAlmostEqual
(
180
-
44.56139
,
angle_between_three_points
.
py_func
(
p1
,
p2
,
p3
),
places
=
3
)
def
test_angle_between_three_points_4
(
self
):
p1
=
(
0
,
0
)
p2
=
(
0
,
10
)
p3
=
(
0
,
0
)
self
.
assertAlmostEqual
(
0
,
abs
(
angle_between_three_points
.
py_func
(
p1
,
p2
,
p3
)),
places
=
3
)
# def test_compute_position_angle_std(self):
# def test_compute_position_angle_std(self):
# dat = [(0, i * 10) for i in range(5)] + [(0, 50 - i * 10) for i in range(5)]
# dat = [(0, i * 10) for i in range(5)] + [(0, 50 - i * 10) for i in range(5)]
# result = compute_position_angle_std(dat, 2)
# result = compute_position_angle_std(dat, 2)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment