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
9a94e525
Commit
9a94e525
authored
3 years ago
by
Raphael Sturgis
Browse files
Options
Downloads
Patches
Plain Diff
reorganised file
parent
d29c2006
No related branches found
No related tags found
1 merge request
!6
Develop
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
skais/ais/ais_points.py
+16
-15
16 additions, 15 deletions
skais/ais/ais_points.py
with
16 additions
and
15 deletions
skais/ais/ais_points.py
+
16
−
15
View file @
9a94e525
...
@@ -50,18 +50,20 @@ class AISPoints:
...
@@ -50,18 +50,20 @@ class AISPoints:
self
.
df
=
df
self
.
df
=
df
@staticmethod
# cleaning functions
def
load_from_csv
(
file_name
):
df
=
pd
.
read_csv
(
file_name
)
ais_points
=
AISPoints
(
df
)
return
ais_points
def
remove_outliers
(
self
,
features
,
rank
=
4
):
def
remove_outliers
(
self
,
features
,
rank
=
4
):
if
rank
<=
0
:
if
rank
<=
0
:
raise
ValueError
(
f
"
Rank is equal to
{
rank
}
, must be positive and superior to 0
"
)
raise
ValueError
(
f
"
Rank is equal to
{
rank
}
, must be positive and superior to 0
"
)
for
feature
in
features
:
for
feature
in
features
:
self
.
df
=
self
.
df
.
drop
(
self
.
df
[(
np
.
abs
(
stats
.
zscore
(
self
.
df
[
feature
]))
>
rank
)].
index
)
self
.
df
=
self
.
df
.
drop
(
self
.
df
[(
np
.
abs
(
stats
.
zscore
(
self
.
df
[
feature
]))
>
rank
)].
index
)
def
clean_angles
(
self
):
self
.
df
=
self
.
df
[
self
.
df
[
"
cog
"
]
<=
360
]
self
.
df
=
self
.
df
[
self
.
df
[
"
cog
"
]
>=
0
]
self
.
df
=
self
.
df
[
self
.
df
[
"
heading
"
]
<=
360
]
self
.
df
=
self
.
df
[
self
.
df
[
"
heading
"
]
>=
0
]
def
normalize
(
self
,
features
,
normalization_type
=
"
min-max
"
):
def
normalize
(
self
,
features
,
normalization_type
=
"
min-max
"
):
normalization_dict
=
{}
normalization_dict
=
{}
if
normalization_type
==
"
min-max
"
:
if
normalization_type
==
"
min-max
"
:
...
@@ -93,20 +95,12 @@ class AISPoints:
...
@@ -93,20 +95,12 @@ class AISPoints:
f
"
standardization]
"
)
f
"
standardization]
"
)
return
normalization_type
,
normalization_dict
return
normalization_type
,
normalization_dict
# New features
# TODO: rename
# TODO: rename
def
compute_diff_heading_cog
(
self
):
def
compute_diff_heading_cog
(
self
):
self
.
df
[
"
diff
"
]
=
self
.
df
.
apply
(
lambda
x
:
180
-
abs
(
abs
(
x
[
'
heading
'
]
-
x
[
'
cog
'
])
-
180
),
self
.
df
[
"
diff
"
]
=
self
.
df
.
apply
(
lambda
x
:
180
-
abs
(
abs
(
x
[
'
heading
'
]
-
x
[
'
cog
'
])
-
180
),
axis
=
1
)
axis
=
1
)
def
clean_angles
(
self
):
self
.
df
=
self
.
df
[
self
.
df
[
"
cog
"
]
<=
360
]
self
.
df
=
self
.
df
[
self
.
df
[
"
cog
"
]
>=
0
]
self
.
df
=
self
.
df
[
self
.
df
[
"
heading
"
]
<=
360
]
self
.
df
=
self
.
df
[
self
.
df
[
"
heading
"
]
>=
0
]
# TODO: redo
# TODO: redo
def
get_trajectories
(
self
,
time_gap
=
30
,
min_size
=
50
,
interpolation_time
=
None
):
def
get_trajectories
(
self
,
time_gap
=
30
,
min_size
=
50
,
interpolation_time
=
None
):
...
@@ -139,6 +133,7 @@ class AISPoints:
...
@@ -139,6 +133,7 @@ class AISPoints:
return
stats
return
stats
# Static methods
@staticmethod
@staticmethod
def
fuse
(
*
args
):
def
fuse
(
*
args
):
if
len
(
args
)
==
1
:
if
len
(
args
)
==
1
:
...
@@ -153,3 +148,9 @@ class AISPoints:
...
@@ -153,3 +148,9 @@ class AISPoints:
dfs
.
append
(
aisPosition
.
df
)
dfs
.
append
(
aisPosition
.
df
)
return
AISPoints
(
pd
.
concat
(
dfs
).
reindex
())
return
AISPoints
(
pd
.
concat
(
dfs
).
reindex
())
@staticmethod
def
load_from_csv
(
file_name
):
df
=
pd
.
read_csv
(
file_name
)
ais_points
=
AISPoints
(
df
)
return
ais_points
\ No newline at end of file
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