[plotter] bugfix

This commit is contained in:
Noe Brucy
2021-07-06 17:51:38 +02:00
parent fa156a13b4
commit a4d2be22d2
+13 -6
View File
@@ -301,15 +301,21 @@ class Plotter(Aggregator, BaseProcessor):
nums = self.nums nums = self.nums
datafiles = [] datafiles = []
if movie:
filenames = []
if rule.kind == "snapshot" or rule.kind == "cells": if rule.kind == "snapshot" or rule.kind == "cells":
run_num = [(run, num) for run in runs for num in nums[run]] run_num = [(run, num) for run in runs for num in nums[run]]
if movie:
filenames = {run : [] for run in runs}
elif rule.kind == "comp": elif rule.kind == "comp":
run_num = [(None, None)] run_num = [(None, None)]
if movie:
self._log(f"No movie possible for rule {name}", "WARNING")
movie = False
else: else:
run_num = [(run, None) for run in runs] run_num = [(run, None) for run in runs]
if movie:
self._log(f"No movie possible for rule {name}", "WARNING")
movie = False
onefigure = False # If axes are provided, only save/close once onefigure = False # If axes are provided, only save/close once
if ax is not None: if ax is not None:
@@ -365,7 +371,7 @@ class Plotter(Aggregator, BaseProcessor):
df = rule.datafile(name, arg) df = rule.datafile(name, arg)
df[filetype] = plot_filename df[filetype] = plot_filename
if movie: if movie:
filenames.append(plot_filename) filenames[run].append(plot_filename)
if plot_info is not None: if plot_info is not None:
df.plot_info = plot_info df.plot_info = plot_info
if num is not None: if num is not None:
@@ -382,9 +388,10 @@ class Plotter(Aggregator, BaseProcessor):
datafiles.append(df) datafiles.append(df)
if movie: if movie:
clip = ImageSequenceClip(filenames, fps=movie_fps) for run in runs:
movie_filename = self._find_filename(name_full) clip = ImageSequenceClip(filenames[run], fps=movie_fps)
movie.filename = os.path.splitext(movie_filename)[0] + ".mp4" movie_filename = self._find_filename(name_full, run=run)
movie_filename = os.path.splitext(movie_filename)[0] + ".mp4"
clip.write_videofile(movie_filename) clip.write_videofile(movie_filename)
return datafiles return datafiles