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
4c46b543
Commit
4c46b543
authored
3 years ago
by
Raphael
Browse files
Options
Downloads
Patches
Plain Diff
basic features operation
parent
cdc56f8a
No related branches found
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
+24
-5
24 additions, 5 deletions
skais/ais/ais_trajectory.py
skais/process/basic_features_operations.py
+4
-0
4 additions, 0 deletions
skais/process/basic_features_operations.py
with
28 additions
and
5 deletions
skais/ais/ais_trajectory.py
+
24
−
5
View file @
4c46b543
...
@@ -147,6 +147,7 @@ def angle_between_three_points(p1, p2, p3):
...
@@ -147,6 +147,7 @@ def angle_between_three_points(p1, p2, p3):
else
:
else
:
return
result
return
result
def
compute_point_angles
(
dat
):
def
compute_point_angles
(
dat
):
angles
=
np
.
zeros
(
dat
.
shape
[
0
])
angles
=
np
.
zeros
(
dat
.
shape
[
0
])
...
@@ -193,7 +194,7 @@ def angle_dispersion(dat, radius):
...
@@ -193,7 +194,7 @@ def angle_dispersion(dat, radius):
return
disp
return
disp
@jit
(
nopython
=
True
)
def
apply_func_on_window
(
dat
,
func
,
radius
,
on_edge
=
'
copy
'
):
def
apply_func_on_window
(
dat
,
func
,
radius
,
on_edge
=
'
copy
'
):
result
=
np
.
zeros
(
dat
.
shape
)
result
=
np
.
zeros
(
dat
.
shape
)
if
on_edge
==
'
copy
'
:
if
on_edge
==
'
copy
'
:
...
@@ -202,8 +203,15 @@ def apply_func_on_window(dat, func, radius, on_edge='copy'):
...
@@ -202,8 +203,15 @@ def apply_func_on_window(dat, func, radius, on_edge='copy'):
data
=
dat
[
i
-
radius
:
i
+
radius
+
1
]
data
=
dat
[
i
-
radius
:
i
+
radius
+
1
]
result
[
i
-
radius
]
=
func
(
data
)
result
[
i
-
radius
]
=
func
(
data
)
return
result
return
result
else
:
raise
ValueError
(
f
"
{
on_edge
}
not recognised, options are: [
'
copy
'
]
"
)
def
apply_time_sequence
(
dat
,
time
,
func
):
result
=
np
.
empty
(
dat
.
shape
[
0
])
result
[
0
]
=
func
(
dat
[
0
],
dat
[
1
],
time
[
0
],
time
[
1
])
for
i
in
range
(
1
,
dat
.
shape
[
0
]):
result
[
i
]
=
func
(
dat
[
i
-
1
],
dat
[
i
],
time
[
i
-
1
],
time
[
i
])
return
result
class
AISTrajectory
:
class
AISTrajectory
:
def
__init__
(
self
,
df
,
interpolation_time
=
None
):
def
__init__
(
self
,
df
,
interpolation_time
=
None
):
...
@@ -401,10 +409,21 @@ class AISTrajectory:
...
@@ -401,10 +409,21 @@ class AISTrajectory:
return
result
return
result
def
apply_func_on_time_window
(
self
,
func
,
radius
,
column
,
new_column
=
None
):
def
apply_func_on_time_window
(
self
,
func
,
radius
,
column
,
new_column
=
None
):
dat
=
self
.
df
[
column
]
dat
=
self
.
df
[
column
]
.
to_numpy
()
result
=
apply_func_on_window
(
dat
,
func
,
radius
,
on_edge
=
'
copy
'
)
result
=
apply_func_on_window
(
dat
,
func
,
radius
,
on_edge
=
'
copy
'
)
if
new_column
is
None
:
if
new_column
is
None
:
self
.
df
[
column
]
=
result
self
.
df
[
column
]
=
result
else
:
else
:
self
.
df
[
new_column
]
=
result
self
.
df
[
new_column
]
=
result
def
apply_time_sequence_func
(
self
,
func
,
column
,
new_column
=
None
):
dat
=
self
.
df
[
column
].
to_numpy
()
time
=
self
.
df
[
'
ts_sec
'
].
to_numpy
()
result
=
apply_time_sequence
(
dat
,
time
,
func
)
if
new_column
is
None
:
self
.
df
[
column
]
=
result
else
:
self
.
df
[
new_column
]
=
result
This diff is collapsed.
Click to expand it.
skais/process/basic_features_operations.py
+
4
−
0
View file @
4c46b543
...
@@ -40,3 +40,7 @@ def angular_time_derivative(angle1, angle2, ts1, ts2):
...
@@ -40,3 +40,7 @@ def angular_time_derivative(angle1, angle2, ts1, ts2):
z
=
z2
/
z1
z
=
z2
/
z1
return
cmath
.
polar
(
z
)[
1
]
/
(
ts2
-
ts1
)
return
cmath
.
polar
(
z
)[
1
]
/
(
ts2
-
ts1
)
def
time_derivative
(
f1
,
f2
,
ts1
,
ts2
):
return
(
f2
-
f1
)
/
(
ts2
-
ts1
)
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