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
fe5d61db
Commit
fe5d61db
authored
3 years ago
by
Raphael
Browse files
Options
Downloads
Patches
Plain Diff
add test + change of node_size
parent
fe57f69e
No related branches found
No related tags found
3 merge requests
!12
version 0.2a
,
!10
Resolve "Image creation bugs with 0 size windows"
,
!9
Resolve "Creation of images from AIS"
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
skais/ais/ais_trajectory.py
+15
-6
15 additions, 6 deletions
skais/ais/ais_trajectory.py
skais/tests/ais/test_ais_trajectory.py
+54
-4
54 additions, 4 deletions
skais/tests/ais/test_ais_trajectory.py
with
69 additions
and
10 deletions
skais/ais/ais_trajectory.py
+
15
−
6
View file @
fe5d61db
...
@@ -224,7 +224,7 @@ class AISTrajectory(AISPoints):
...
@@ -224,7 +224,7 @@ class AISTrajectory(AISPoints):
result
.
append
((
row
[
'
ts_sec
'
],
current_label
))
result
.
append
((
row
[
'
ts_sec
'
],
current_label
))
return
result
return
result
def
generate_array_from_positions
(
self
,
height
=
256
,
width
=
256
,
link
=
True
,
bounding_box
=
'
fit
'
,
features
=
None
):
def
generate_array_from_positions
(
self
,
height
=
256
,
width
=
256
,
link
=
True
,
bounding_box
=
'
fit
'
,
features
=
None
,
node_size
=
0
):
nb_channels
=
1
nb_channels
=
1
if
features
is
not
None
:
if
features
is
not
None
:
nb_channels
=
len
(
features
)
nb_channels
=
len
(
features
)
...
@@ -234,10 +234,19 @@ class AISTrajectory(AISPoints):
...
@@ -234,10 +234,19 @@ class AISTrajectory(AISPoints):
if
bounding_box
!=
'
fit
'
:
if
bounding_box
!=
'
fit
'
:
raise
ValueError
(
"
feature not implemented
"
)
raise
ValueError
(
"
feature not implemented
"
)
positions
=
self
.
df
[[
'
longitude
'
,
'
latitude
'
]].
to_numpy
()
positions
=
self
.
df
[[
'
longitude
'
,
'
latitude
'
]].
to_numpy
()
range_longitude
=
(
min
(
positions
[
0
,
:
]),
max
(
positions
[
0
,
:
]))
range_longitude
=
(
min
(
positions
[
:
,
0
]),
max
(
positions
[
:
,
0
]))
range_latitude
=
(
min
(
positions
[
1
,
:
]),
max
(
positions
[
1
,
:
]))
range_latitude
=
(
min
(
positions
[
:
,
1
]),
max
(
positions
[
:
,
1
]))
for
longitude
,
latitude
in
positions
:
for
longitude
,
latitude
in
positions
:
x_coord
=
width
*
(
longitude
-
range_longitude
[
0
])
/
(
range_longitude
[
1
]
-
range_longitude
[
0
])
x_coord
=
max
(
min
(
height
-
int
(
height
*
(
latitude
-
range_latitude
[
0
])
/
(
range_latitude
[
1
]
-
range_latitude
[
0
]))
-
1
,
height
-
1
),
0
)
y_coord
=
height
*
(
longitude
-
range_latitude
[
0
])
/
(
range_latitude
[
1
]
-
range_latitude
[
0
])
y_coord
=
max
(
min
(
int
((
width
-
1
)
*
(
longitude
-
range_longitude
[
0
])
/
(
range_longitude
[
1
]
-
range_longitude
[
0
])),
width
-
1
),
0
)
data
[
x_coord
,
y_coord
,
:]
=
1
x_lower_bound
=
max
(
0
,
x_coord
-
node_size
)
x_upper_bound
=
min
(
height
-
1
,
x_coord
+
node_size
)
y_lower_bound
=
max
(
0
,
y_coord
-
node_size
)
y_upper_bound
=
min
(
width
-
1
,
y_coord
+
node_size
)
for
x
in
range
(
x_lower_bound
,
x_upper_bound
+
1
):
for
y
in
range
(
y_lower_bound
,
y_upper_bound
+
1
):
data
[
x
,
y
]
=
[
1
]
return
data
return
data
This diff is collapsed.
Click to expand it.
skais/tests/ais/test_ais_trajectory.py
+
54
−
4
View file @
fe5d61db
...
@@ -379,3 +379,53 @@ class TestAISTrajectory(unittest.TestCase):
...
@@ -379,3 +379,53 @@ class TestAISTrajectory(unittest.TestCase):
expected
=
[(
0
,
1
),
(
6600
,
2
),
(
12600
,
1
)]
expected
=
[(
0
,
1
),
(
6600
,
2
),
(
12600
,
1
)]
self
.
assertListEqual
(
result
,
expected
)
self
.
assertListEqual
(
result
,
expected
)
def
test_generate_array_from_positions
(
self
):
trajectory
=
AISTrajectory
(
pd
.
DataFrame
(
{
"
latitude
"
:
[
0
,
10
,
0
,
-
10
],
"
longitude
"
:
[
0
,
10
,
10
,
-
10
],
"
ts_sec
"
:
[
i
for
i
in
range
(
4
)]
}
)
)
result
=
trajectory
.
generate_array_from_positions
(
height
=
9
,
width
=
9
,
link
=
False
,
bounding_box
=
'
fit
'
,
features
=
None
,
node_size
=
0
).
reshape
((
9
,
9
))
expected
=
np
.
array
([[
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
1
],
[
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
],
[
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
],
[
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
],
[
0
,
0
,
0
,
0
,
1
,
0
,
0
,
0
,
1
],
[
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
],
[
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
],
[
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
],
[
1
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
]])
np
.
testing
.
assert_array_equal
(
result
,
expected
)
def
test_generate_array_from_positions_node_size
(
self
):
trajectory
=
AISTrajectory
(
pd
.
DataFrame
(
{
"
latitude
"
:
[
0
,
10
,
0
,
-
10
],
"
longitude
"
:
[
0
,
10
,
10
,
-
10
],
"
ts_sec
"
:
[
i
for
i
in
range
(
4
)]
}
)
)
result
=
trajectory
.
generate_array_from_positions
(
height
=
9
,
width
=
9
,
link
=
False
,
bounding_box
=
'
fit
'
,
features
=
None
,
node_size
=
1
).
reshape
((
9
,
9
))
expected
=
np
.
array
([[
0
,
0
,
0
,
0
,
0
,
0
,
0
,
1
,
1
],
[
0
,
0
,
0
,
0
,
0
,
0
,
0
,
1
,
1
],
[
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
],
[
0
,
0
,
0
,
1
,
1
,
1
,
0
,
1
,
1
],
[
0
,
0
,
0
,
1
,
1
,
1
,
0
,
1
,
1
],
[
0
,
0
,
0
,
1
,
1
,
1
,
0
,
1
,
1
],
[
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
],
[
1
,
1
,
0
,
0
,
0
,
0
,
0
,
0
,
0
],
[
1
,
1
,
0
,
0
,
0
,
0
,
0
,
0
,
0
]])
np
.
testing
.
assert_array_equal
(
result
,
expected
)
\ 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