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