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
6b29cce1
Commit
6b29cce1
authored
Nov 22, 2018
by
Quentin LOUIS
Browse files
Options
Browse Files
Download
Plain Diff
fix
parents
1a195a85
0c52506b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
10 deletions
+14
-10
Amaury/God/DataVisualisation.py
Amaury/God/DataVisualisation.py
+12
-8
Amaury/experiments.py
Amaury/experiments.py
+2
-2
No files found.
Amaury/God/DataVisualisation.py
View file @
6b29cce1
...
...
@@ -48,7 +48,7 @@ def get_layout(option: str = "default") -> Tuple[Any, Dict[str, Any], Dict[str,
subplots
[
"speed"
]
=
fig
.
add_subplot
(
gs
[
0
,
3
])
subplots
[
"angle"
]
=
subplots
[
"speed"
].
twinx
()
subplots
[
"polar"
]
=
fig
.
add_subplot
(
gs
[
0
,
4
],
projection
=
'polar'
)
subplots
[
"angle_pdf"
]
=
fig
.
add_subplot
(
gs
[
0
,
5
])
subplots
[
"angle_pdf"
]
=
fig
.
add_subplot
(
gs
[
0
,
5
]
,
projection
=
'polar'
)
subplots
[
"correlations"
]
=
fig
.
add_subplot
(
gs
[
1
,
3
])
subplots
[
"correlation_length"
]
=
subplots
[
"correlations"
].
twinx
()
subplots
[
"evolution_group_size"
]
=
fig
.
add_subplot
(
gs
[
1
,
4
])
...
...
@@ -297,6 +297,7 @@ class Visualiser:
if
self
.
to_draw
[
"angle_pdf"
]:
ax_angle_pdf
=
self
.
subplots
[
"angle_pdf"
]
ax_angle_pdf
.
set_ylim
(
0
,
1
)
ax_angle_pdf
.
set_title
(
"Angle PDF"
)
self
.
layout_artists
[
"angle_pdf"
],
=
ax_angle_pdf
.
plot
([],
[],
lw
=
2
)
...
...
@@ -313,7 +314,7 @@ class Visualiser:
ax_group_dimension
=
self
.
subplots
[
"group_dimension"
]
max_group_size
=
self
.
options
[
"max_group_size"
]
ax_group_dimension
.
set_xlim
(
1
,
max_group_size
)
ax_group_dimension
.
set_ylim
(
0
,
L
/
5
)
ax_group_dimension
.
set_ylim
(
0
,
L
**
2
/
100
)
self
.
layout_artists
[
"group_dimension_text"
]
=
ax_group_dimension
.
text
(
0.02
,
1.05
,
''
,
transform
=
ax_group_dimension
.
transAxes
)
if
self
.
to_draw
[
"group_dimension"
]:
...
...
@@ -388,10 +389,13 @@ class Visualiser:
Plot angle PDF
"""
frame
=
self
.
processed_data
[
"_simulation"
][
"frames"
][
frame_num
]
angles
=
np
.
array
([
np
.
array
(
bird
[
1
])
for
bird
in
frame
])
kde
=
gaussian_kde
(
angles
)
dist_space
=
np
.
linspace
(
min
(
angles
),
max
(
angles
),
100
)
self
.
layout_artists
[
"angle_pdf"
].
set_data
(
dist_space
,
kde
(
dist_space
))
angles
=
np
.
array
([
bird
[
1
]
for
bird
in
frame
])
angles_extended
=
np
.
concatenate
((
angles
,
angles
+
2
*
np
.
pi
,
angles
-
2
*
np
.
pi
))
kde
=
gaussian_kde
(
angles_extended
)
n_points
=
100
dist_space
=
np
.
linspace
(
0
,
2
*
np
.
pi
,
n_points
)
rescaling
=
np
.
sqrt
(
np
.
sum
(
kde
(
dist_space
)
**
2
)
*
np
.
pi
/
n_points
)
self
.
layout_artists
[
"angle_pdf"
].
set_data
(
dist_space
,
kde
(
dist_space
)
/
rescaling
)
def
plot_correlations
(
self
,
frame_num
:
int
)
->
None
:
"""
...
...
@@ -511,7 +515,7 @@ class Visualiser:
a
,
b
,
r_squared
=
data
x_data
=
np
.
array
(
range
(
len
(
self
.
processed_data
[
"group_hulls_dimensions_avg"
][
frame_num
])
+
1
))
self
.
layout_artists
[
"group_dimension_avg_fit"
].
set_data
(
x_data
,
fit
(
x_data
,
a
,
b
))
self
.
layout_artists
[
"group_dimension_text"
].
set_text
(
"$R^2$ = %.5f
\n
$bx^a$: a=%.2f
"
%
(
r_squared
,
a
))
self
.
layout_artists
[
"group_dimension_text"
].
set_text
(
"$R^2$ = %.5f
\n
$bx^a$: a=%.2f
, b=%.2f"
%
(
r_squared
,
a
,
b
))
def
plot_evolution_group_size
(
self
,
frame_num
:
int
)
->
None
:
"""
...
...
@@ -528,7 +532,7 @@ class Visualiser:
"""
frame
=
self
.
processed_data
[
"_simulation"
][
"frames"
][
frame_num
]
positions
=
np
.
array
([
np
.
array
(
bird
[
0
])
for
bird
in
frame
])
angles
=
np
.
array
([
np
.
array
(
bird
[
1
])
for
bird
in
frame
])
angles
=
np
.
array
([
bird
[
1
]
for
bird
in
frame
])
if
self
.
options
[
"quiver_color_by_group"
]:
groups
=
self
.
processed_data
[
"groups"
][
frame_num
]
quiver_colors
=
[]
...
...
Amaury/experiments.py
View file @
6b29cce1
...
...
@@ -37,20 +37,20 @@ def launch_two_groups(output_file: str, L: float, n_birds_1: int, n_birds_2: int
physics
=
Physics
(
sky
,
interaction_radius
,
eta
)
Life
.
simulate
(
physics
,
dt
,
total_time
,
verbose_prop
=
.
1
,
output_file
=
output_file
)
launch_simulation_random
(
"simulation_data/test-machine.json"
,
L
=
1000
,
n_birds
=
100000
,
eta
=
.
2
,
total_time
=
10
)
# , evolve=evolve)
#
# # launch_two_groups("simulation_data/test.json", L=100, n_birds_1=100, n_birds_2=0, radius_1=5, radius_2=5,
# # total_time=60, center_1=[50, 50], center_2=[80, 50], angle_1=0, angle_2=np.pi, eta=.4)
to_process
=
[
"avg_speed"
,
"avg_angle"
,
"group_size"
,
"group_size_avg"
,
"group_size_avg_fit"
,
"groups"
,
"correlations"
,
"correlations_fit"
,
"group_to_size"
,
"group_hulls"
]
Processor
().
process
(
"simulation_data/test-machine.json"
,
"processing_data/test-machine"
,
verbose_prop
=
.
1
,
to_process
=
to_process
,
options
=
{
"correlations_stochastic_points"
:
5000
})
to_draw
=
[
"avg_speed"
,
"avg_angle"
,
"avg_polar"
,
"angle_pdf"
,
"correlations"
,
"correlations_fit"
,
"correlation_length"
,
"group_size"
,
"group_size_avg"
,
"group_size_avg_fit"
,
"group_dimension"
,
"group_dimension_avg"
,
"quiver"
,
"evolution_group_size"
]
Visualiser
(
"processing_data/test-machine"
,
"visualisations/test-machine.mp4"
,
simulation_data_file
=
"simulation_data/test-machine.json"
,
verbose_prop
=
.
1
,
to_draw
=
to_draw
,
...
...
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