Commit c8aab711 authored by Amaury BARRAL's avatar Amaury BARRAL

lint

parent 3b019945
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment