fluidsim_core.output.movies
Movies output
Contains base classes which acts as a framework to
implement the method animate
to make movies.
Provides:
- class fluidsim_core.output.movies.MoviesBase(output)[source]
Bases:
object
Base class defining most generic functions for movies.
- _set_font(family='serif', size=12)[source]
Use to set font attribute. May be either an alias (generic name is CSS parlance), such as serif, sans-serif, cursive, fantasy, or monospace, a real font name or a list of real font names.
- init_animation(key_field, numfig, dt_equations, tmin, tmax, fig_kw, **kwargs)[source]
Initializes animated fig. and list of times of save files to load.
- _init_ani_times(tmin, tmax, dt_equations)[source]
Initialization of the variable ani_times for one animation.
- abstract update_animation(frame, **fargs)[source]
Replace this function to load data for next frame and update the figure.
- get_field_to_plot(time=None, key=None, equation=None)[source]
Once a saved file is loaded, this selects the field and mpi-gathers.
- Returns:
- fieldnd array or string
- animate(key_field=None, dt_frame_in_sec=0.3, dt_equations=None, tmin=None, tmax=None, repeat=True, save_file=False, numfig=None, interactive=None, fargs={}, fig_kw={}, **kwargs)[source]
Load the key field from multiple save files and display as an animated plot or save as a movie file.
- Parameters:
- key_fieldstr
Specifies which field to animate
- dt_frame_in_secfloat
Interval between animated frames in seconds
- dt_equationsfloat
Approx. interval between saved files to load in simulation time units
- tmaxfloat
Animate till time tmax.
- repeatbool
Loop the animation
- save_filestr or bool
Path to save the movie. When True saves into a file instead of plotting it on screen (default: ~/fluidsim_movie.mp4). Specify a string to save to another file location. Format is autodetected from the filename extension.
- numfigint
Figure number on the window
- interactivebool
Add player buttons (pause, step by step and forward/backward)
- fargsdict
Dictionary of arguments for update_animation. Matplotlib requirement.
- fig_kwdict
Dictionary for arguments for the figure.
- Other Parameters:
- All `kwargs` are passed on to `init_animation` and `_ani_save`
- xmaxfloat
Set x-axis limit for 1D animated plots
- ymaxfloat
Set y-axis limit for 1D animated plots
- climtuple
Set colorbar limits for 2D animated plots
- stepint
Set step value to get a coarse 2D field
- QUIVERbool
Set quiver on or off on top of 2D pcolor plots
- normalize_vectorsbool (default True)
Normalize the vectors at each time by the instantaneous maximum
- quiver_kw: dict
Dictionary for arguments for the quiver call.
- pcolor_kw: dict
Dictionary for arguments for the pcolormesh call.
- codecstr
Codec used to save into a movie file (default: ffmpeg)
Notes
This method is kept as generic as possible. Any arguments specific to 1D, 2D or 3D animations or specific to a type of output are be passed via keyword arguments (
kwargs
) into its respectiveinit_animation
orupdate_animation
methods.Examples
>>> import fluidsim as fls >>> sim = fls.load_sim_for_plot() >>> animate = sim.output.spectra.animate >>> animate('E') >>> animate('rot') >>> animate('rot', dt_equations=0.1, dt_frame_in_sec=50, clim=(-5, 5)) >>> animate('rot', clim=(-300, 300), fig_kw={"figsize": (14, 4)}) >>> animate('rot', tmax=25, clim=(-5, 5), save_file='True') >>> animate('rot', clim=(-5, 5), save_file='~/fluidsim.gif', codec='imagemagick')
- interact(key_field=None, dt_equations=None, tmin=None, tmax=None, fig_kw={}, **kwargs)[source]
Launches an interactive plot.
- Parameters:
- key_fieldstr
Specifies which field to animate
- dt_equationsfloat
Approx. interval between saved files to load in simulation time units
- tmaxfloat
Animate till time tmax.
- fig_kwdict
Dictionary for arguments for the figure.
- Other Parameters:
- All `kwargs` are passed on to `init_animation` and `_ani_save`
- xmaxfloat
Set x-axis limit for 1D animated plots
- ymaxfloat
Set y-axis limit for 1D animated plots
- climtuple
Set colorbar limits for 2D animated plots
- stepint
Set step value to get a coarse 2D field
- QUIVERbool
Set quiver on or off on top of 2D pcolor plots
- quiver_kw: dict
Dictionary for arguments for the quiver call.
Notes
Installation instructions for notebook:
pip install ipywidgets jupyter nbextension enable --py widgetsnbextension
Restart the notebook and call the function using:
>>> %matplotlib notebook
For JupyterLab:
pip install ipywidgets ipympl jupyter labextension install @jupyter-widgets/jupyterlab-manager
Restart JupyterLab and call the function using:
>>> %matplotlib widget
- class fluidsim_core.output.movies.MoviesBase1D(output)[source]
Bases:
MoviesBase
Base class defining most generic functions for movies for 1D data.
- init_animation(key_field, numfig, dt_equations, tmin, tmax, fig_kw, **kwargs)[source]
Initializes animated figure.
- class fluidsim_core.output.movies.MoviesBase2D(output)[source]
Bases:
MoviesBase
Base class defining most generic functions for movies for 2D data.
- class fluidsim_core.output.movies.MoviesBasePhysFields(output, phys_fields)[source]
Bases:
MoviesBase2D
- init_animation(key_field, numfig, dt_equations, tmin, tmax, fig_kw, **kwargs)[source]
Initialize list of files and times, pcolor plot, quiver and colorbar.
- class fluidsim_core.output.movies.MoviesBasePhysFieldsHexa(output, phys_fields)[source]
Bases:
MoviesBasePhysFields
Classes
|
Base class defining most generic functions for movies. |
|
Base class defining most generic functions for movies for 1D data. |
|
Base class defining most generic functions for movies for 2D data. |
|
|
|