File: animation.py

package info (click to toggle)
python-ase 3.24.0-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 15,448 kB
  • sloc: python: 144,945; xml: 2,728; makefile: 113; javascript: 47
file content (25 lines) | stat: -rw-r--r-- 730 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from ase.visualize.plot import animate


def write_animation(filename, images, writer=None,
                    interval=200,
                    save_count=None,  # ignored for newer matplotlib (2023)
                    save_parameters=None, ax=None, **kwargs):
    import matplotlib.pyplot as plt

    if save_parameters is None:
        save_parameters = {}

    if ax is None:
        ax = plt.gca()

    animation = animate(images, ax=ax,
                        interval=interval,
                        **kwargs)
    animation.save(filename, writer=writer,
                   **save_parameters)


# Shortcuts for ase.io.formats (guessing file type from extension):
write_gif = write_animation
write_mp4 = write_animation