Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
P
PHY571 Birds flocking
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Quentin LOUIS
PHY571 Birds flocking
Commits
c8aab711
Commit
c8aab711
authored
Nov 13, 2018
by
Amaury BARRAL
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lint
parent
3b019945
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
16 deletions
+21
-16
Amaury/God/DataVisualisation.py
Amaury/God/DataVisualisation.py
+21
-16
No files found.
Amaury/God/DataVisualisation.py
View file @
c8aab711
...
...
@@ -359,7 +359,7 @@ class Visualiser:
def
plot_group_size_avg_fit
(
self
,
frame_num
:
int
)
->
None
:
def
fit
(
x
,
a1
,
b1
):
return
np
.
exp
(
b1
)
*
x
**
a1
return
np
.
exp
(
b1
)
*
x
**
a1
data
=
self
.
processed_data
[
"group_size_avg_fit"
][
frame_num
]
if
data
is
None
:
...
...
@@ -372,8 +372,9 @@ class Visualiser:
def
plot_evolution_group_size
(
self
,
frame_num
:
int
)
->
None
:
times
=
self
.
timestamps
[:
frame_num
+
1
]
ydata
=
[
self
.
processed_data
[
"group_to_size"
][
frame
][(
self
.
processed_data
[
"groups"
][
frame
][
0
])]
for
frame
in
range
(
frame_num
+
1
)]
self
.
layout_artists
[
"evolution_group_size"
].
set_data
(
times
,
ydata
)
ydata
=
[
self
.
processed_data
[
"group_to_size"
][
frame
][(
self
.
processed_data
[
"groups"
][
frame
][
0
])]
for
frame
in
range
(
frame_num
+
1
)]
self
.
layout_artists
[
"evolution_group_size"
].
set_data
(
times
,
ydata
)
def
plot_quiver
(
self
,
frame_num
:
int
)
->
None
:
frame
=
self
.
processed_data
[
"_simulation"
][
"frames"
][
frame_num
]
...
...
@@ -394,14 +395,15 @@ class Visualiser:
if
self
.
options
[
"quiver_draw_by_group"
]:
L
=
self
.
simulation_parameters
[
"L"
]
groups
=
self
.
processed_data
[
"groups"
][
frame_num
]
indexes_of_bird_by_group
=
[[
i
for
i
in
range
(
len
(
groups
))
if
groups
[
i
]
==
j
]
for
j
in
range
(
len
(
groups
))]
indexes_of_bird_by_group
=
[[
i
for
i
in
range
(
len
(
groups
))
if
groups
[
i
]
==
j
]
for
j
in
range
(
len
(
groups
))]
for
group
in
range
(
len
(
groups
)):
birds_indexes
=
indexes_of_bird_by_group
[
group
]
if
len
(
birds_indexes
)
==
0
:
continue
elif
len
(
birds_indexes
)
==
1
:
pos
=
positions
[
birds_indexes
[
0
]]
hull_plot_points
,
=
self
.
subplots
[
"quiver"
].
plot
([
pos
[
0
]],
[
pos
[
1
]],
'ro'
,
markersize
=
3
,
color
=
"blue"
)
hull_plot_points
,
=
self
.
subplots
[
"quiver"
].
plot
([
pos
[
0
]],
[
pos
[
1
]],
'ro'
,
markersize
=
3
,
color
=
"blue"
)
self
.
to_unblit
.
append
(
hull_plot_points
)
self
.
layout_artists
[
"quiver_hull_%s_points"
%
group
]
=
hull_plot_points
continue
...
...
@@ -412,18 +414,20 @@ class Visualiser:
hull
=
list
(
range
(
len
(
birds_indexes
)))
else
:
hull
=
scipy
.
spatial
.
ConvexHull
(
positions_hull
).
vertices
x
=
list
(
positions_hull
[
hull
,
0
])
+
[
positions_hull
[
hull
[
0
],
0
]]
y
=
list
(
positions_hull
[
hull
,
1
])
+
[
positions_hull
[
hull
[
0
],
1
]]
x
=
list
(
positions_hull
[
hull
,
0
])
+
[
positions_hull
[
hull
[
0
],
0
]]
y
=
list
(
positions_hull
[
hull
,
1
])
+
[
positions_hull
[
hull
[
0
],
1
]]
angles_hull
=
list
(
angles_hull
[
hull
])
+
[
angles_hull
[
hull
[
0
]]]
for
point
in
range
(
len
(
list
(
x
))
-
1
):
for
point
in
range
(
len
(
list
(
x
))
-
1
):
distance_x
=
abs
(
x
[
point
+
1
]
-
x
[
point
])
distance_y
=
abs
(
y
[
point
+
1
]
-
y
[
point
])
if
self
.
options
[
"quiver_color_by_group"
]:
color
=
self
.
cm
(
self
.
group_colors
[
group
%
len
(
self
.
group_colors
)])
else
:
color
=
self
.
cm
(
self
.
norm
((
angles_hull
[
point
]
+
angles_hull
[
point
+
1
])
/
2
))
if
distance_x
<
L
/
2
and
distance_y
<
L
/
2
:
hull_plot_segment
,
=
self
.
subplots
[
"quiver"
].
plot
([
x
[
point
],
x
[
point
+
1
]],
[
y
[
point
],
y
[
point
+
1
]],
linewidth
=
2
,
color
=
color
)
color
=
self
.
cm
(
self
.
norm
((
angles_hull
[
point
]
+
angles_hull
[
point
+
1
])
/
2
))
if
distance_x
<
L
/
2
and
distance_y
<
L
/
2
:
hull_plot_segment
,
=
self
.
subplots
[
"quiver"
].
plot
([
x
[
point
],
x
[
point
+
1
]],
[
y
[
point
],
y
[
point
+
1
]],
linewidth
=
2
,
color
=
color
)
self
.
to_unblit
.
append
(
hull_plot_segment
)
self
.
layout_artists
[
"quiver_hull_%s_%s"
%
(
group
,
point
)]
=
hull_plot_segment
# hull_plot_points, = self.subplots["quiver"].plot([x[point], x[point+1]], [y[point], y[point+1]], 'ro', markersize=3, color="blue")
...
...
@@ -438,7 +442,8 @@ class Visualiser:
new_offsets
[
i
][
1
]
=
y
[
i
]
u
=
np
.
cos
(
angles
)
v
=
np
.
sin
(
angles
)
quiver
=
self
.
subplots
[
"quiver"
].
quiver
(
x
,
y
,
u
,
v
,
color
=
self
.
cm
(
quiver_colors
),
angles
=
'xy'
,
scale_units
=
'xy'
,
quiver
=
self
.
subplots
[
"quiver"
].
quiver
(
x
,
y
,
u
,
v
,
color
=
self
.
cm
(
quiver_colors
),
angles
=
'xy'
,
scale_units
=
'xy'
,
scale
=
1
)
self
.
layout_artists
[
"quiver"
]
=
quiver
self
.
to_unblit
.
append
(
quiver
)
...
...
@@ -457,9 +462,9 @@ class Visualiser:
time_per_frame
=
(
time
.
time
()
-
start_t
)
/
(
frame_number
+
1
)
remaining_time
=
time_per_frame
*
(
total_frames
-
frame_number
)
log
.
info
(
"Drawing frame %d/%d - remaining est. %dh %dm %ds"
%
(
frame_number
,
total_frames
,
remaining_time
//
3600
%
24
,
remaining_time
//
60
%
60
,
remaining_time
%
60
,))
remaining_time
//
3600
%
24
,
remaining_time
//
60
%
60
,
remaining_time
%
60
,))
# unblit artists created on the spot
for
artist
in
list
(
self
.
to_unblit
):
...
...
@@ -515,7 +520,7 @@ class Visualiser:
log
.
info
(
"Drawing start at t=%s"
%
datetime
.
datetime
.
fromtimestamp
(
start_t
).
strftime
(
'%Y-%m-%d %H:%M:%S'
))
anim
=
animation
.
FuncAnimation
(
self
.
fig
,
self
.
update_animation
,
init_func
=
lambda
:
(),
frames
=
total_frames
,
interval
=
200
,
blit
=
True
,
repeat
=
True
,
fargs
=
(
start_t
,
))
interval
=
200
,
blit
=
True
,
repeat
=
True
,
fargs
=
(
start_t
,))
SaveAndLoad
.
make_path_available
(
self
.
output_file
)
anim
.
save
(
self
.
output_file
,
writer
=
self
.
writer
)
elapsed
=
time
.
time
()
-
start_t
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment