class imod.visualize.GridAnimation3D(da, vertical_exaggeration=30.0, mesh_kwargs={}, plotter_kwargs={})[source]#

Class to easily setup 3D animations for transient data. Use the imod.visualize.StaticGridAnimation3D when the location of the displayed cells is constant over time: it will render much faster.

You can iteratively add or change settings to the plotter, until you’re satisfied. Call the .peek() method to take a look. When satisfied, call .output() to write to a file.

  • da (xr.DataArray) – The dataarray with transient data. Must contain a “time” dimension.

  • vertical_exaggeration (float, defaults to 30.0 mesh_kwargs : dict) – keyword arguments that are forwarded to the pyvista mesh representing “da”. If “stitle” is given as one of the arguments, the special keyword “timestamp” can be used to render the plotted time as part of the title. See example. For a full list of kwargs supported, see the plotter.add_mesh method documentation.

  • plotter_kwargs (dict) – keyword arguments that are forwarded to the pyvista plotter. For a full list of of kwargs supported, see the Plotter constructor documention.


Initialize the animation:

>>> animation = imod.visualize.GridAnimation3D(concentration, mesh_kwargs=dict(cmap="jet"))

Check what it looks like (if a window pops up: press “q” instead of the X to return):

>>> animation.peek()

Change the camera position, add bounding box, and check the result:

>>> animation.plotter.camera_position = (2, 1, 0.5)
>>> animation.plotter.add_bounding_box()
>>> animation.peek()

When it looks good, write to a file:

>>> animation.write("example.mp4")

If you’ve made some changes that don’t look good, call .reset() to start over:

>>> animation.reset()

Note that .reset() is automatically called when the animation has finished writing.

You can use “stitle” in mesh_kwargs in conjunction with the “timestamp” keyword to print a formatted timestamp in the animation:

>>> animation = imod.visualize.GridAnimation3D(concentration, mesh_kwargs=dict(stitle="Concentration on {timestamp:%Y-%m-%d}"))
__init__(da, vertical_exaggeration=30.0, mesh_kwargs={}, plotter_kwargs={})[source]#


__init__(da[, vertical_exaggeration, ...])


Display the current state of the animation plotter.


Reset the plotter to its base state.

write(filename[, framerate])

Write the animation to a video or gif.