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
8b158d23
Commit
8b158d23
authored
Nov 13, 2018
by
Amaury BARRAL
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
group size evolution
parent
3be3903f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
8 deletions
+16
-8
Amaury/God/DataProcessing.py
Amaury/God/DataProcessing.py
+13
-5
Amaury/God/DataVisualisation.py
Amaury/God/DataVisualisation.py
+2
-2
Amaury/experiments.py
Amaury/experiments.py
+1
-1
No files found.
Amaury/God/DataProcessing.py
View file @
8b158d23
import
datetime
import
logging
import
time
from
typing
import
List
,
Dict
from
typing
import
List
,
Dict
,
Tuple
import
numpy
as
np
import
scipy.optimize
...
...
@@ -15,11 +15,11 @@ log.addHandler(logging.StreamHandler())
log
.
setLevel
(
logging
.
INFO
)
def
get_group_size_occurences
(
groups
:
List
[
list
])
->
List
[
int
]:
def
get_group_size_occurences
(
groups
:
List
[
list
])
->
Tuple
[
List
[
int
],
List
[
int
]
]:
size_groups
=
[
len
(
group
)
for
group
in
groups
if
len
(
group
)
>
0
]
max_size_group
=
np
.
max
(
size_groups
)
size_x
=
range
(
1
,
max_size_group
+
1
)
return
[
size_groups
.
count
(
i
)
for
i
in
size_x
]
return
size_groups
,
[
size_groups
.
count
(
i
)
for
i
in
size_x
]
class
Processor
:
...
...
@@ -47,6 +47,7 @@ class Processor:
def
chose_what_to_process
(
self
,
to_process
:
List
[
str
])
->
None
:
self
.
to_process
[
"groups"
]
=
"groups"
in
to_process
self
.
to_process
[
"group_size"
]
=
"group_size"
in
to_process
self
.
to_process
[
"group_to_size"
]
=
"group_to_size"
in
to_process
self
.
to_process
[
"group_size_avg"
]
=
"group_size_avg"
in
to_process
self
.
to_process
[
"group_size_avg_fit"
]
=
self
.
to_process
[
"group_size_avg"
]
and
(
"group_size_avg_fit"
in
to_process
)
...
...
@@ -65,6 +66,8 @@ class Processor:
self
.
data_holders
[
"avg_angle"
]
=
[]
if
self
.
to_process
[
"groups"
]:
self
.
data_holders
[
"groups"
]
=
[]
if
self
.
to_process
[
"group_to_size"
]:
self
.
data_holders
[
"group_to_size"
]
=
[]
if
self
.
to_process
[
"group_size"
]:
self
.
data_holders
[
"group_size"
]
=
[]
if
self
.
to_process
[
"group_size_avg"
]:
...
...
@@ -131,6 +134,9 @@ class Processor:
def
process_groups
(
self
,
sky
:
Sky
,
birds_to_group
:
dict
):
self
.
data_holders
[
"groups"
].
append
([
birds_to_group
[
bird
]
for
bird
in
sky
.
birds
])
def
process_group_to_size
(
self
,
group_to_size
:
List
[
int
])
->
None
:
self
.
data_holders
[
"group_to_size"
].
append
(
group_to_size
)
def
process_group_size
(
self
,
size_occurences
:
List
[
int
])
->
None
:
self
.
data_holders
[
"group_size"
].
append
(
size_occurences
)
...
...
@@ -232,7 +238,9 @@ class Processor:
if
self
.
to_process
[
"groups"
]
or
self
.
to_process
[
"group_size"
]
or
self
.
to_process
[
"group_size_avg"
]:
groups
,
bird_to_group
=
physics
.
get_groups
()
size_occurences
=
get_group_size_occurences
(
groups
)
group_to_size
,
size_occurences
=
get_group_size_occurences
(
groups
)
if
self
.
to_process
[
"group_to_size"
]:
self
.
process_group_to_size
(
group_to_size
)
if
self
.
to_process
[
"groups"
]:
self
.
process_groups
(
sky
,
bird_to_group
)
if
self
.
to_process
[
"group_size"
]:
...
...
@@ -252,7 +260,7 @@ class Processor:
SaveAndLoad
.
save_data_dirname
(
self
.
data_holders
[
prop_name
],
output_file
,
"%s.json"
%
prop_name
)
# save the actual data
simple_propreties
=
[
"avg_speed"
,
"avg_angle"
,
"groups"
,
"group_size"
,
"group_size_avg"
,
"group_size_avg_fit"
,
simple_propreties
=
[
"avg_speed"
,
"avg_angle"
,
"groups"
,
"group_size"
,
"group_
to_size"
,
"group_
size_avg"
,
"group_size_avg_fit"
,
"correlations"
,
"correlations_fit"
]
for
property_name
in
simple_propreties
:
if
self
.
to_process
[
property_name
]:
...
...
Amaury/God/DataVisualisation.py
View file @
8b158d23
...
...
@@ -68,7 +68,7 @@ drawable_to_data = {
"group_size"
:
[
"group_size"
],
"group_size_avg"
:
[
"group_size_avg"
],
"group_size_avg_fit"
:
[
"group_size_avg_fit"
],
"evolution_group_size"
:
[
"group_size"
,
"groups"
],
"evolution_group_size"
:
[
"group_
to_
size"
,
"groups"
],
}
...
...
@@ -372,7 +372,7 @@ class Visualiser:
def
plot_evolution_group_size
(
self
,
frame_num
:
int
)
->
None
:
times
=
self
.
timestamps
[:
frame_num
+
1
]
ydata
=
[
self
.
processed_data
[
"group_
size"
][
frame
][(
self
.
processed_data
[
"groups"
][
frame
][
0
])]
for
frame
in
range
(
frame_num
)]
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
:
...
...
Amaury/experiments.py
View file @
8b158d23
...
...
@@ -42,7 +42,7 @@ launch_two_groups("simulation_data/test.json", L=100, n_birds_1=200, n_birds_2=1
total_time
=
100
,
center_1
=
[
20
,
50
],
center_2
=
[
80
,
50
],
angle_1
=
0
,
angle_2
=
np
.
pi
)
to_process
=
[
"avg_speed"
,
"avg_angle"
,
"group_size"
,
"group_size_avg"
,
"group_size_avg_fit"
,
"groups"
,
"correlations"
,
"correlations_fit"
]
"correlations_fit"
,
"group_to_size"
]
Processor
().
process
(
"simulation_data/test.json"
,
"processing_data/test"
,
verbose_prop
=
.
1
,
to_process
=
to_process
,
options
=
{
"correlations_stochastic_points"
:
5000
})
...
...
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