[plotter] add basic movie feature
This commit is contained in:
+11
@@ -26,6 +26,7 @@ if os.environ.get("DISPLAY", "") == "":
|
||||
import datetime
|
||||
|
||||
import matplotlib.pyplot as plt
|
||||
from moviepy.video.io import ImageSequenceClip
|
||||
|
||||
import pspec_read
|
||||
from baseprocessor import Rule, BaseProcessor
|
||||
@@ -265,6 +266,8 @@ class Plotter(Aggregator, BaseProcessor):
|
||||
select=None,
|
||||
ax=None,
|
||||
from_cells=False,
|
||||
movie=False,
|
||||
movie_fps=15,
|
||||
**kwargs,
|
||||
):
|
||||
"""
|
||||
@@ -373,6 +376,14 @@ class Plotter(Aggregator, BaseProcessor):
|
||||
self.simulations[run].snapshots.add(snap)
|
||||
|
||||
datafiles.append(df)
|
||||
|
||||
if movie:
|
||||
filenames = [df[filetype] for df in datafiles]
|
||||
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)
|
||||
|
||||
return datafiles
|
||||
|
||||
def _plot_rule(
|
||||
|
||||
Reference in New Issue
Block a user