# we're going to process all frames from the hour. We'll use the display() function
# and have it return the figure, then we'll add some timestamp and other text
# to our liking.
#
# we'll utilize multiprocessing and tqdm's progress bar functionality to do this
# using several worker processes
import os
import platform
import matplotlib.pyplot as plt
from tqdm.contrib.concurrent import process_map as tqdm_process_map
from tqdm.auto import tqdm
def process_frame(i):
fig, ax = at.display(images_scaled[:, :, i], cmap="gray", returnfig=True)
ax.text(5, 240, "THEMIS ASI", color="white", size=14)
ax.text(5, 225, "ATHA", color="white", size=14)
ax.text(145, 8, data.timestamp[i].strftime("%Y-%m-%d %H:%M:%S UTC"), color="white", size=11)
filename = "movie_frames/%s_atha_themis.png" % (data.timestamp[i].strftime("%Y%m%d_%H%M%S"))
os.makedirs(os.path.dirname(filename), exist_ok=True)
plt.savefig(filename, bbox_inches="tight")
plt.close()
return filename
if (platform.system() == "Windows"):
# pre-process frames serially
#
# NOTE: multiprocessing on Windows from within a notebook is not too easy, so we'll
# just do this serially.
frame_filename_list = []
for i in tqdm(range(0, images_scaled.shape[-1]), total=images_scaled.shape[-1], desc="Generating frame files: ", unit="frames"):
frame_filename_list.append(process_frame(i))
else:
frame_filename_list = tqdm_process_map(
process_frame,
range(0, images_scaled.shape[-1]),
max_workers=5,
chunksize=1,
desc="Generating frame files: ",
unit="frames",
)