1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
|
"""
==============================================
Requesting cutouts of AIA images from the JSOC
==============================================
This example shows how to request a cutout of a series of
AIA images from the JSOC.
"""
import os
import matplotlib.pyplot as plt
import astropy.units as u
from astropy.coordinates import SkyCoord
from astropy.time import Time
from astropy.visualization import ImageNormalize, SqrtStretch
import sunpy.coordinates # NOQA
import sunpy.map
from sunpy.net import Fido
from sunpy.net import attrs as a
#####################################################
# As this is an example, we have already worked out where
# we need to crop for the active region we want to showcase.
start_time = Time('2012-09-24T14:56:03', scale='utc', format='isot')
bottom_left = SkyCoord(-500*u.arcsec, -275*u.arcsec, obstime=start_time, observer="earth", frame="helioprojective")
top_right = SkyCoord(150*u.arcsec, 375*u.arcsec, obstime=start_time, observer="earth", frame="helioprojective")
#####################################################
# Now construct the cutout from the coordinates above
# above using the `~sunpy.net.jsoc.attrs.Cutout` attribute.
cutout = a.jsoc.Cutout(bottom_left, top_right=top_right, tracking=True)
#####################################################
# Exporting data from the JSOC requires registering your
# email first. Please replace this with your email
# address once you have registered.
# See `this page <http://jsoc.stanford.edu/ajax/register_email.html>`_
# for more details.
jsoc_email = os.environ["JSOC_EMAIL"]
#####################################################
# Now we are ready to construct the query. Note that all of this is
# the same for a full-frame image except for the
# cutout component. We will download images from a 12 hour interval
# centered on the time of the above cutout.
# We request one image every 2 hours.
query = Fido.search(
a.Time(start_time - 6*u.h, start_time + 6*u.h),
a.Wavelength(171*u.angstrom),
a.Sample(2*u.h),
a.jsoc.Series.aia_lev1_euv_12s,
a.jsoc.Notify(jsoc_email),
a.jsoc.Segment.image,
cutout,
)
print(query)
#####################################################
# Submit the export request and download the data.
files = Fido.fetch(query)
files.sort()
#####################################################
# Now that we've downloaded the files, we can create
# a `~sunpy.map.MapSequence` from them and animate
# them.
sequence = sunpy.map.Map(files, sequence=True)
plt.figure()
ani = sequence.plot(norm=ImageNormalize(vmin=0, vmax=5e3, stretch=SqrtStretch()))
plt.show()
|