xmovie.Movie
xmovie.Movie#
- class xmovie.Movie(da, plotfunc=None, framedim='time', pixelwidth=1920, pixelheight=1080, dpi=200, frame_pattern='frame_%05d.png', fieldname=None, input_check=True, **kwargs)#
Movie class, describing how to construct an animation from associated data.
- __init__(da, plotfunc=None, framedim='time', pixelwidth=1920, pixelheight=1080, dpi=200, frame_pattern='frame_%05d.png', fieldname=None, input_check=True, **kwargs)#
- Parameters
da (
DataArray
) – Data to be plotted.plotfunc (
Callable
) – Function to plot a single frame, with the same signature as the presets.Default:
basic()
.framedim (
str
) – Dimension name along which frames will be generated.pixelwidth, pixelheight (
int
) – Movie size.dpi (
int
) – Movie resolution.frame_pattern (
str
) – Filename pattern when saving frames.fieldname – Currently unused.
**kwargs – Passed on to plotfunc.
Methods
__init__
(da[, plotfunc, framedim, ...])- Parameters
da (
DataArray
) -- Data to be plotted.
preview
(timestep)Create (plot) preview frame of the movie.
render_single_frame
(timestep)renders complete figure (frame) for given timestep.
save
(filename[, remove_frames, ...])Save out animation from Movie object.
save_frames_parallel
(odir[, ...])Saves all frames in parallel using dask.map_blocks.
save_frames_serial
(odir[, progress])Save movie frames as picture files.
- preview(timestep)#
Create (plot) preview frame of the movie.
- Parameters
timestep (
int
) – Timestep (frame) to preview.
- render_single_frame(timestep)#
renders complete figure (frame) for given timestep.
- save(filename, remove_frames=True, remove_movie=True, progress=False, verbose=False, overwrite_existing=False, parallel=False, parallel_compute_kwargs={}, framerate=15, ffmpeg_options='-c:v libx264 -preset veryslow -crf 10 -pix_fmt yuv420p', gif_palette=False, gif_resolution_factor=0.5, gif_framerate=10)#
Save out animation from Movie object.
- Parameters
filename (
str
) – Pathname to final movie/animation. Output is dependent on filetype: creates movie for*.mp4
and gif for*.gif
.remove_frames (
bool
) – Optional removal of frame pictures (the default isTrue
;False
will leave all picture files in folder).remove_movie (
bool
) – As remove_frames but for movie file. Only applies when filename is given as .gif (the default isTrue
).progress (
bool
) – Experimental switch to show progress output. This will be refined in future version and currently only works withparallel=False
(the default value isFalse
).verbose (
bool
) – Experimental switch to show output of ffmpeg commands. Useful for debugging but can quickly flood your notebook (the default isFalse
).overwrite_existing (
bool
) – Set to overwrite existing files with filename (the default isFalse
).parallel (
bool
) – Whether or not to use Dask to save the frames in parallel.parallel_compute_kwargs (
dict
) – Keyword arguments to pass to Dask’scompute()
.framerate (
int
) – Frames per second for the output movie file. Only relevant for.mp4
files. (The default is 15).ffmpeg_options (
str
) – Encoding options to pass to ffmpeg call. Defaults to:"-c:v libx264 -preset veryslow -crf 10 -pix_fmt yuv420p"
.gif_palette (
bool
) – Use a gif colorpalette to improve quality. Can lead to artifacts in very contrasty situations (the default isFalse
).gif_resolution_factor (
float
) – Factor used to reduce gif resolution compared to movie. Use 1.0 to put out the same resolutions for both products. (the default is 0.5).Note
Currently unused
gif_framerate (
int
) – As framerate but for the gif output file. Only relevant to .gif files. (The default is 10).
- save_frames_parallel(odir, parallel_compute_kwargs={})#
Saves all frames in parallel using dask.map_blocks.