VideoWriter#

class fridom.framework.modules.animation.video_writer.VideoWriter(model_plotter: ModelPlotter, model_time_per_second: timedelta64 | float, filename: str = 'output.mp4', fps: int = 30, parallel: bool = True, max_jobs: float = 0.2)[source]#

Bases: Module

Create a mp4 video from the model.

Description#

To create a mp4 video from the model, one must provide a ModelPlotter that will be used to create the figure. The video writer does not support MPI parallelism.

Parameters#

model_plotterModelPlotter

The model plotter that will be used to create the figure.

write_intervalnp.timedelta64 | float

The interval at which the data should be written to the file.

filenamestr, optional (default=”output.mp4”)

The filename of the video (will be stored in videos/filename).

fpsint, optional (default=30)

The frames per second of the video.

parallelbool, optional (default=True)

If True, the video writer will use parallelism to create the video.

max_jobsfloat, optional (default=0.4)

The maximum fraction of the available threads that will be used.

__init__(model_plotter: ModelPlotter, model_time_per_second: timedelta64 | float, filename: str = 'output.mp4', fps: int = 30, parallel: bool = True, max_jobs: float = 0.2) None[source]#

Methods

__init__(model_plotter, model_time_per_second)

collect_figures()

disable()

Disable the module.

enable()

Enable the module.

is_enabled()

Whether the module is enabled or not.

p_make_figure()

Parallel function that gets a ModelPlotter object, makes the image of it and puts it in the output queue.

parallel_update(mz)

reset()

Stop and start the module.

setup(mset[, setup_mode])

Set the module up.

show_video([width])

single_update(mz)

start()

Start the module.

stop()

Stop the module.

update(mz)

Update the model state.

Attributes

diff_module

The differentiation module to be used by this module.

grid

The grid of the model settings.

info

Return a dictionary with information about the time stepper.

interp_module

The interpolation module to be used by this module.

is_setup

Whether the module is set up.

mset

The model settings.

name

required_halo

The required halo points for this module.

Examples using fridom.framework.modules.animation.VideoWriter#

Barotropic Jet

Barotropic Jet

Convection and Closures

Convection and Closures

Dancing Eddies

Dancing Eddies

Internal Gravity Wave Maker

Internal Gravity Wave Maker

Multiple Wave Makers

Multiple Wave Makers

Rayleigh-Bénard Convection

Rayleigh-Bénard Convection

Rayleigh-Taylor Instability

Rayleigh-Taylor Instability

Single Internal Wave

Single Internal Wave

Symmetric Instability

Symmetric Instability

Tracers and Eddies

Tracers and Eddies

Reflecting Wave Package

Reflecting Wave Package

Barotropic Instability.

Barotropic Instability.

Equatorial Waves.

Equatorial Waves.
name = 'Video Writer'#
start() None[source]#

Start the module.

Description#

This method is called at the beginning of the model run. Child classes that require a start method (for example to start an output writer) should overwrite this method. Make sure to decorate the method with the @module_method decorator.

stop() None[source]#

Stop the module.

Description#

This method is called by the model at the end of the model run or when the model is reset. Child classes that require a stop method (for example to close an output file) should overwrite this method. Make sure to decorate the method with the @module_method decorator.

update(mz: ModelState) ModelState[source]#

Update the model state.

Description#

This method is called by the model at each time step. Child classes should overwrite this method to update the module. Make sure to decorate the method with the @module_method decorator.

Parameters#

mzfr.ModelState

The model state at the current time step.

Returns#

fr.ModelState

The updated model state.

parallel_update(mz: ModelState) None[source]#
single_update(mz: ModelState) None[source]#
collect_figures() None[source]#
show_video(width=600)[source]#
property info: dict#

Return a dictionary with information about the time stepper.

Description#

This method should be overridden by the child class to return a dictionary with information about the time stepper. This information is used to print the time stepper in the __repr__ method.

p_make_figure()[source]#

Parallel function that gets a ModelPlotter object, makes the image of it and puts it in the output queue.

Arguments:

modelplot (ModelPlotter): model plotter object output_queue (mp.Queue) : output queue