Requesting specific AIA images from the JSOC#

This example shows how to request a specific series of AIA images from the JSOC.

We will be filtering the data we require by keywords and requesting short exposure images from a recent (at time of writing) flare.

import os

import astropy.units as u
import matplotlib.pyplot as plt
from astropy.coordinates import SkyCoord
from astropy.visualization import AsinhStretch, ImageNormalize
from import Fido, attrs

from aiapy.calibrate import correct_degradation, register, update_pointing
from aiapy.calibrate.util import get_correction_table, get_pointing_table

Exporting data from the JSOC requires registering your email first. Please replace the text after the = with your email address once you have registered. See this page for more details.

jsoc_email = os.environ.get("JSOC_EMAIL")

Our goal is to request data of a recent X-class flare. The X-class flare occurred on the 2021/07/03 at 14:30:00 UTC. We will focus on the 5 minutes before and after this time. What we want to do is only get the shorter exposures, which are going to be the flare related.

query =
    attrs.Time("2021-07-03 14:25:00", "2021-07-03 14:35:00"),
    attrs.Wavelength(211 * u.AA),
    attrs.jsoc.Keyword("EXPTIME") <= 2,

Results from 1 Provider:

20 Results from the JSOCClient:

-------------------- -------- -------- -------- -------
2021-07-03T14:27:23Z  SDO/AIA    AIA_2      211    2245
2021-07-03T14:27:47Z  SDO/AIA    AIA_2      211    2245
2021-07-03T14:28:11Z  SDO/AIA    AIA_2      211    2245
2021-07-03T14:28:35Z  SDO/AIA    AIA_2      211    2245
2021-07-03T14:28:59Z  SDO/AIA    AIA_2      211    2245
2021-07-03T14:29:23Z  SDO/AIA    AIA_2      211    2245
2021-07-03T14:29:47Z  SDO/AIA    AIA_2      211    2245
2021-07-03T14:30:11Z  SDO/AIA    AIA_2      211    2245
2021-07-03T14:30:35Z  SDO/AIA    AIA_2      211    2245
2021-07-03T14:30:59Z  SDO/AIA    AIA_2      211    2245
2021-07-03T14:31:23Z  SDO/AIA    AIA_2      211    2245
2021-07-03T14:31:47Z  SDO/AIA    AIA_2      211    2245
2021-07-03T14:32:11Z  SDO/AIA    AIA_2      211    2245
2021-07-03T14:32:35Z  SDO/AIA    AIA_2      211    2245
2021-07-03T14:32:59Z  SDO/AIA    AIA_2      211    2245
2021-07-03T14:33:23Z  SDO/AIA    AIA_2      211    2245
2021-07-03T14:33:47Z  SDO/AIA    AIA_2      211    2245
2021-07-03T14:34:11Z  SDO/AIA    AIA_2      211    2245
2021-07-03T14:34:35Z  SDO/AIA    AIA_2      211    2245
2021-07-03T14:34:59Z  SDO/AIA    AIA_2      211    2245

Now we will download the data and “aia prep” the data with every feature of aiapy and plot the data sequence using sunpy.

files = Fido.fetch(query)

level_1_maps =
# We get the pointing table outside of the loop for the relevant time range.
# Otherwise you're making a call to the JSOC every single time.
pointing_table = get_pointing_table(level_1_maps[0].date - 3 * u.h, level_1_maps[-1].date + 3 * u.h)
# The same applies for the correction table.
correction_table = get_correction_table()

level_15_maps = []
for a_map in level_1_maps:
    map_updated_pointing = update_pointing(a_map, pointing_table=pointing_table)
    map_registered = register(map_updated_pointing)
    map_degradation = correct_degradation(map_registered, correction_table=correction_table)
    map_normalized = map_degradation / map_degradation.exposure_time
    bottom_left = SkyCoord(500 * u.arcsec, 100 * u.arcsec, frame=map_normalized.coordinate_frame)
    top_right = SkyCoord(1500 * u.arcsec, 700 * u.arcsec, frame=map_normalized.coordinate_frame)
    map_cropped = map_normalized.submap(bottom_left, top_right=top_right)
Export request pending. [id=JSOC_20240511_001972, status=2]
Waiting for 0 seconds...
20 URLs found for download. Full request totalling 151MB

Finally, we create a sequence of maps and animate it: