Астрозадача №8:
Решение
from matplotlib import pyplot as plt
import sunpy.map
from sunpy.instr.aia import aiaprep
from sunpy.net import Fido, attrs as a
from astropy.coordinates import SkyCoord
from astropy import units as u
import matplotlib.animation as animation
plt.rcParams['figure.figsize'] = [10, 9]
# Загрузка данных, берутся фотографии с шагом 10 минут
result = Fido.search(a.Time('2019-11-11T12:35:00', '2019-11-11T18:07:00'),
a.Instrument("aia"), a.Wavelength(171*u.angstrom),
a.Sample(10*u.minute))
file_download = Fido.fetch(result, site='ROB')
# Сортировка снимков по времени
file_download = sorted(file_download)
# Построение анимации
aia = sunpy.map.Map(file_download)
fig, ax = plt.subplots()
plot_obj = aia[len(aia)-1].plot()
def animate(i):
ax.set_title("AIA %s %s" % (aia[i].meta['wave_str'],
aia[i].meta['t_obs'][:-8]))
plot_obj.set_data(aia[i].data)
return (plot_obj,)
anim = animation.FuncAnimation(fig, animate, init_func=None,
frames=len(aia), interval=100, blit=True)
anim.save('Transit of Mercury.gif')
plt.close(fig)