45 glob_str, render_gif=True, dpi=200, interval=50, repeat_delay=10, fig=None
48 Create a matplotlib animation from a sequence of image files.
50 Available only if matplotlib and PIL are installed.
55 Glob pattern matching image files.
56 render_gif : bool, optional
57 Whether to render the animation.
59 Dots per inch for the figure.
60 interval : int, optional
61 Delay between frames in milliseconds.
62 repeat_delay : int, optional
63 Delay before repeating the animation.
67 FileNotFoundError : if no images are found for the glob pattern
71 matplotlib.animation.FuncAnimation or None
72 Animation object on rank 0, otherwise None.
78 if shamrock.sys.world_rank() != 0:
81 files = sorted(glob.glob(glob_str))
85 with Image.open(my_file)
as image:
86 image_array.append(image.copy())
89 raise FileNotFoundError(f
"No images found for glob pattern: {glob_str}")
91 pixel_x, pixel_y = image_array[0].size
94 fig = plt.figure(dpi=dpi)
95 plt.gca().set_position((0, 0, 1, 1))
96 plt.gcf().set_size_inches(pixel_x / dpi, pixel_y / dpi)
99 im = plt.imshow(image_array[0], animated=
True, aspect=
"auto")
102 im.set_array(image_array[i])
105 ani = animation.FuncAnimation(
108 frames=len(image_array),
111 repeat_delay=repeat_delay,