Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
io
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
bioroboticslab
robofish
io
Commits
122d1888
Commit
122d1888
authored
4 years ago
by
marc131183
Browse files
Options
Downloads
Patches
Plain Diff
final commit
parent
e9ea3fe2
No related branches found
No related tags found
1 merge request
!11
Develop marc
Pipeline
#37756
passed
4 years ago
Stage: package
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/conversion_scripts/convert_marc.py
+1
-1
1 addition, 1 deletion
src/conversion_scripts/convert_marc.py
src/robofish/evaluate/evaluate.py
+29
-22
29 additions, 22 deletions
src/robofish/evaluate/evaluate.py
with
30 additions
and
23 deletions
src/conversion_scripts/convert_marc.py
+
1
−
1
View file @
122d1888
...
...
@@ -19,7 +19,7 @@ import robofish.io
def
convertTrajectory
(
path
,
save_path
,
categories
):
ar
=
pd
.
read_csv
(
path
,
sep
=
"
;
"
).
to_numpy
()
new
=
robofish
.
io
.
File
(
world_size_cm
=
[
100
,
100
],
frequency_hz
=
2
0
)
new
=
robofish
.
io
.
File
(
world_size_cm
=
[
100
,
100
],
frequency_hz
=
2
5
)
# convert x,y from m to cm
ar
[:,
[
0
,
1
,
3
,
4
]]
=
ar
[:,
[
0
,
1
,
3
,
4
]]
*
100
...
...
This diff is collapsed.
Click to expand it.
src/robofish/evaluate/evaluate.py
+
29
−
22
View file @
122d1888
...
...
@@ -87,7 +87,7 @@ def evaluate_speed(
if
labels
is
None
:
labels
=
paths
plt
.
hist
(
speeds
,
bins
=
20
,
label
=
labels
,
density
=
True
,
range
=
[
0
,
5
0
])
plt
.
hist
(
speeds
,
bins
=
20
,
label
=
labels
,
density
=
True
,
range
=
[
0
,
2
5
])
plt
.
title
(
"
Agent speeds
"
)
plt
.
xlabel
(
"
Speed [cm/s]
"
)
plt
.
ylabel
(
"
Frequency
"
)
...
...
@@ -147,7 +147,7 @@ def evaluate_turn(
labels
=
paths
# TODO: Quantil range
plt
.
hist
(
turns
,
bins
=
4
0
,
label
=
labels
,
density
=
True
,
range
=
[
-
30
,
30
])
plt
.
hist
(
turns
,
bins
=
4
1
,
label
=
labels
,
density
=
True
,
range
=
[
-
30
,
30
])
plt
.
title
(
"
Agent turns
"
)
plt
.
xlabel
(
"
Change in orientation [Degree / timestep at %dhz]
"
%
frequency
)
plt
.
ylabel
(
"
Frequency
"
)
...
...
@@ -193,8 +193,8 @@ def evaluate_orientation(
world_size
[
0
]
/
2
,
world_size
[
1
]
/
2
,
]
xbins
=
np
.
linspace
(
world_bounds
[
0
],
world_bounds
[
2
],
1
0
)
ybins
=
np
.
linspace
(
world_bounds
[
1
],
world_bounds
[
3
],
1
0
)
xbins
=
np
.
linspace
(
world_bounds
[
0
],
world_bounds
[
2
],
1
1
)
ybins
=
np
.
linspace
(
world_bounds
[
1
],
world_bounds
[
3
],
1
1
)
ret_1
=
stats
.
binned_statistic_2d
(
poses
[:,
0
],
poses
[:,
1
],
poses
[:,
2
],
"
mean
"
,
bins
=
[
xbins
,
ybins
]
)
...
...
@@ -226,13 +226,13 @@ def evaluate_orientation(
plot
=
ax
[
i
].
pcolormesh
(
xx
,
yy
*
(
-
1
)
,
yy
,
np
.
arctan2
(
s_2
,
s_1
).
T
,
vmin
=-
np
.
pi
,
vmax
=
np
.
pi
,
cmap
=
"
twilight
"
,
)
#
cbar = plt.colorbar(plot, ax=ax[i], pad=0.015, aspect=10)
cbar
=
plt
.
colorbar
(
plot
,
ax
=
ax
[
i
],
pad
=
0.015
,
aspect
=
10
)
show_values
(
plot
)
if
save_path
is
None
:
...
...
@@ -419,7 +419,10 @@ def evaluate_tankpositions(
ax
[
i
].
set_xlim
(
-
world_bounds
[
i
][
0
]
/
2
,
world_bounds
[
i
][
0
]
/
2
)
ax
[
i
].
set_ylim
(
-
world_bounds
[
i
][
1
]
/
2
,
world_bounds
[
i
][
1
]
/
2
)
sns
.
kdeplot
(
x
=
x_pos
[
i
],
y
=
y_pos
[
i
]
*
(
-
1
),
n_levels
=
25
,
shade
=
True
,
ax
=
ax
[
i
])
ax
[
i
].
set_xlabel
(
"
x [cm]
"
)
ax
[
i
].
set_ylabel
(
"
y [cm]
"
)
sns
.
kdeplot
(
x
=
x_pos
[
i
],
y
=
y_pos
[
i
],
n_levels
=
25
,
shade
=
True
,
ax
=
ax
[
i
])
if
save_path
is
None
:
plt
.
show
()
...
...
@@ -450,21 +453,26 @@ def evaluate_trajectories(
pos
=
[]
world_bounds
=
[]
for
k
,
files
in
enumerate
(
files_per_path
):
path_poses
=
[]
for
p
,
file
in
files
.
items
():
poses
=
file
.
select_entity_poses
(
None
if
predicate
is
None
else
predicate
[
k
]
)
world_bounds
.
append
(
file
.
attrs
[
"
world_size_cm
"
])
path_pos
=
{
fish
:
pd
.
DataFrame
({
"
x
"
:
poses
[
fish
,
:,
0
],
"
y
"
:
poses
[
fish
,
:,
1
]})
for
fish
in
range
(
len
(
poses
))
}
combined
=
pd
.
concat
(
[
path_pos
[
fish
].
assign
(
Agent
=
f
"
Agent
{
fish
}
"
)
for
fish
in
path_pos
.
keys
()
]
)
path_poses
.
append
(
poses
[:,
:,
:
2
])
poses
=
np
.
concatenate
(
path_poses
,
axis
=
1
)
path_pos
=
{
fish
:
pd
.
DataFrame
({
"
x
"
:
poses
[
fish
,
:,
0
],
"
y
"
:
poses
[
fish
,
:,
1
]})
for
fish
in
range
(
len
(
poses
))
}
combined
=
pd
.
concat
(
[
path_pos
[
fish
].
assign
(
Agent
=
f
"
Agent
{
fish
}
"
)
for
fish
in
path_pos
.
keys
()
]
)
pos
.
append
((
path_pos
,
combined
))
fig
,
ax
=
plt
.
subplots
(
1
,
len
(
pos
),
figsize
=
(
len
(
pos
)
*
8
,
8
))
...
...
@@ -481,7 +489,7 @@ def evaluate_trajectories(
ax
[
i
].
set_title
(
"
Trajectories (%s)
"
%
labels
[
i
])
ax
[
i
].
set_xlim
(
-
world_bounds
[
i
][
0
]
/
2
,
world_bounds
[
i
][
0
]
/
2
)
ax
[
i
].
set_ylim
(
-
world_bounds
[
i
][
1
]
/
2
,
world_bounds
[
i
][
1
]
/
2
)
ax
[
i
].
invert_yaxis
()
#
ax[i].invert_yaxis()
ax
[
i
].
xaxis
.
set_ticks_position
(
"
top
"
)
ax
[
i
].
xaxis
.
set_label_position
(
"
top
"
)
ax
[
i
].
yaxis
.
set_ticks_position
(
"
left
"
)
...
...
@@ -557,11 +565,10 @@ def evaluate_positionVec(
worldBoundsX
,
worldBoundsY
=
max
(
worldBoundsX
),
max
(
worldBoundsY
)
for
i
in
range
(
len
(
posVec
)):
df
=
pd
.
DataFrame
({
"
x
"
:
posVec
[
i
][:,
0
],
"
y
"
:
posVec
[
i
][:,
1
]
*
(
-
1
)
})
df
=
pd
.
DataFrame
({
"
x
"
:
posVec
[
i
][:,
0
],
"
y
"
:
posVec
[
i
][:,
1
]})
grid
=
sns
.
displot
(
df
,
x
=
"
x
"
,
y
=
"
y
"
,
binwidth
=
(
10
,
10
),
cbar
=
True
)
grid
.
axes
[
0
,
0
].
set_xlabel
(
"
x [cm]
"
)
grid
.
axes
[
0
,
0
].
set_ylabel
(
"
y [cm]
"
)
# print(worldBoundsX, worldBoundsY)
grid
.
set
(
xlim
=
(
-
worldBoundsX
,
worldBoundsX
))
grid
.
set
(
ylim
=
(
-
worldBoundsY
,
worldBoundsY
))
grids
.
append
(
grid
)
...
...
@@ -636,12 +643,12 @@ def evaluate_follow_iid(
}
)
plt
.
rcParams
[
"
lines.markersize
"
]
=
1
grid
=
sns
.
jointplot
(
x
=
"
IID [cm]
"
,
y
=
"
Follow
"
,
data
=
follow_iid_data
,
linewidth
=
0
,
s
=
1
,
kind
=
"
scatter
"
,
xlim
=
(
0
,
maxDist
),
ylim
=
(
-
5
,
5
),
...
...
@@ -682,7 +689,7 @@ def evaluate_all(
predicate: a lambda function, selecting entities
(example: lambda e: e.category ==
"
fish
"
)
"""
save_folder
=
Path
(
save_folder
)
#
save_folder = Path(save_folder)
evaluate_speed
(
paths
,
labels
,
save_folder
+
"
speed.png
"
,
predicate
)
evaluate_turn
(
paths
,
labels
,
save_folder
+
"
turn.png
"
,
predicate
)
evaluate_orientation
(
paths
,
labels
,
save_folder
+
"
orientation.png
"
,
predicate
)
...
...
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