def make_aia_animation(aia, start_time: u.s, stop_time: u.s, root_dir, figsize=None, norm=None, fontsize=14, **kwargs):
"""
Build animation from a series of synthesized AIA observations
"""
with h5py.File(aia.counts_file, 'r') as hf:
reference_time = u.Quantity(hf['time'], hf['time'].attrs['units'])
start_index = np.where(reference_time == start_time)[0][0]
stop_index = np.where(reference_time == stop_time)[0][0]
fig_format = os.path.join(root_dir, f'{aia.name}', '{}', 'map_t{:06d}.fits')
fig, ims = plot_aia_channels(aia, start_time, root_dir, figsize=figsize, norm=norm, fontsize=fontsize,
use_with_animation=True)
def update_fig(i):
for channel in aia.channels:
tmp = Map(fig_format.format(channel['name'], i))
ims[channel['name']].set_array(tmp.data)
fig.suptitle(r'$t={:.0f}$ {}'.format(reference_time[i].value, reference_time.unit.to_string()),
fontsize=fontsize)
return [ims[k] for k in ims]
animator_settings = {'interval': 50, 'blit': True}
animator_settings.update(kwargs.get('animator_settings', {}))
animation = matplotlib.animation.FuncAnimation(fig, update_fig, frames=range(start_index, stop_index),
**animator_settings)
return animation
评论列表
文章目录