Exporting data with cutout requests#

This example shows how to submit a data export request with a cutout request using im_patch.

import os
from pathlib import Path

import drms

First we will create a drms.Client, using the JSOC baseurl.

client = drms.Client()

This example requires a registered export email address You can register JSOC exports at: http://jsoc.stanford.edu/ajax/register_email.html You must supply your own email.

email = os.environ["JSOC_EMAIL"]

# Create download directory if it does not exist yet.
out_dir = Path("downloads")
if not out_dir.exists():

Construct the DRMS query string: "Series[timespan][wavelength]{data segments}"

qstr = "aia.lev1_euv_12s[2015-10-17T04:33:30.000/1m@12s][171]{image}"
print(f"Data export query:\n  {qstr}\n")
Data export query:

Construct the dictionary specifying that we want to request a cutout. This is done via the im_patch command. We request a 345.6 arcsecond cutout (on both sides) centered on the coordinate (-517.2, -246) arcseconds as defined in the helioprojective frame of SDO at time t_ref. The t controls whether tracking is disabled (1) or enabled (0). r controls the use of sub-pixel registration. c controls whether off-limb pixels are filled with NaNs. For additional details about im_patch, see the documentation.

process = {
    "im_patch": {
        "t_ref": "2015-10-17T04:33:30.000",
        "t": 0,
        "r": 0,
        "c": 0,
        "locunits": "arcsec",
        "boxunits": "arcsec",
        "x": -517.2,
        "y": -246,
        "width": 345.6,
        "height": 345.6,

# Submit export request using the 'fits' protocol
print("Submitting export request...")
result = client.export(

# Print request URL.
print(f"\nRequest URL: {result.request_url}")
print(f"{int(len(result.urls))} file(s) available for download.\n")

# Download selected files.
print("Download finished.")
print(f'\nDownload directory:\n  "{out_dir.resolve()}"\n')
Submitting export request...

Request URL: http://jsoc.stanford.edu/SUM14/D1740100028/S00000
5 file(s) available for download.

Download finished.

Download directory:

Total running time of the script: (0 minutes 9.159 seconds)

Gallery generated by Sphinx-Gallery