From a4d2be22d277584a5b9faf46c208c1057a907ac6 Mon Sep 17 00:00:00 2001 From: Noe Brucy Date: Tue, 6 Jul 2021 17:51:38 +0200 Subject: [PATCH] [plotter] bugfix --- plotter.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/plotter.py b/plotter.py index b325624..3939f0c 100644 --- a/plotter.py +++ b/plotter.py @@ -301,15 +301,21 @@ class Plotter(Aggregator, BaseProcessor): nums = self.nums datafiles = [] - if movie: - filenames = [] if rule.kind == "snapshot" or rule.kind == "cells": 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": run_num = [(None, None)] + if movie: + self._log(f"No movie possible for rule {name}", "WARNING") + movie = False else: 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 if ax is not None: @@ -365,7 +371,7 @@ class Plotter(Aggregator, BaseProcessor): df = rule.datafile(name, arg) df[filetype] = plot_filename if movie: - filenames.append(plot_filename) + filenames[run].append(plot_filename) if plot_info is not None: df.plot_info = plot_info if num is not None: @@ -382,10 +388,11 @@ class Plotter(Aggregator, BaseProcessor): datafiles.append(df) if movie: - clip = ImageSequenceClip(filenames, fps=movie_fps) - movie_filename = self._find_filename(name_full) - movie.filename = os.path.splitext(movie_filename)[0] + ".mp4" - clip.write_videofile(movie_filename) + for run in runs: + clip = ImageSequenceClip(filenames[run], fps=movie_fps) + movie_filename = self._find_filename(name_full, run=run) + movie_filename = os.path.splitext(movie_filename)[0] + ".mp4" + clip.write_videofile(movie_filename) return datafiles