File: animation.py

package info (click to toggle)
python-ase 3.21.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 13,936 kB
  • sloc: python: 122,428; xml: 946; makefile: 111; javascript: 47
file content (24 lines) | stat: -rw-r--r-- 693 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from ase.visualize.plot import animate


def write_animation(filename, images, writer=None,
                    interval=200, save_count=100,
                    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, save_count=save_count,
                        **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