32 glob_str, render_gif=True, dpi=200, interval=50, repeat_delay=10, fig=None
35 Create a matplotlib animation from a sequence of image files.
37 Available only if matplotlib and PIL are installed.
42 Glob pattern matching image files.
43 render_gif : bool, optional
44 Whether to render the animation.
46 Dots per inch for the figure.
47 interval : int, optional
48 Delay between frames in milliseconds.
49 repeat_delay : int, optional
50 Delay before repeating the animation.
54 FileNotFoundError : if no images are found for the glob pattern
58 matplotlib.animation.FuncAnimation or None
59 Animation object on rank 0, otherwise None.
65 if shamrock.sys.world_rank() != 0:
68 files = sorted(glob.glob(glob_str))
72 with Image.open(my_file)
as image:
73 image_array.append(image.copy())
76 raise FileNotFoundError(f
"No images found for glob pattern: {glob_str}")
78 pixel_x, pixel_y = image_array[0].size
81 fig = plt.figure(dpi=dpi)
82 plt.gca().set_position((0, 0, 1, 1))
83 plt.gcf().set_size_inches(pixel_x / dpi, pixel_y / dpi)
86 im = plt.imshow(image_array[0], animated=
True, aspect=
"auto")
89 im.set_array(image_array[i])
92 ani = animation.FuncAnimation(
95 frames=len(image_array),
98 repeat_delay=repeat_delay,