Getting the urls of a download#

This example prints the download URLs for files returned from an ‘as-is’ data export request.

Note that there is no “Request URL” for method ‘url_quick’.

import os

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"]

Construct the DRMS query string: “Series[timespan][wavelength]”

qstr = "hmi.ic_720s[2015.01.01_00:00:00_TAI/10d@1d]{continuum}"

# Submit export request, defaults to method='url_quick' and protocol='as-is'
print(f"Data export query:\n  {qstr}\n")
print("Submitting export request...")
result = client.export(qstr, email=email)
print(f"{len(result.urls)} file(s) available for download.\n")

# Print download URLs.
for _, row in result.urls[["record", "url"]].iterrows():
    print(f"REC(ORD): {row.record}")
    print(f"URL: {row.url}\n")
Traceback (most recent call last):
  File "/home/docs/checkouts/readthedocs.org/user_builds/drms/checkouts/stable/examples/export_print_urls.py", line 35, in <module>
    print(f"{len(result.urls)} file(s) available for download.\n")
                 ^^^^^^^^^^^
  File "/home/docs/checkouts/readthedocs.org/user_builds/drms/envs/stable/lib/python3.11/site-packages/drms/client.py", line 347, in urls
    self._download_urls_cache = self._generate_download_urls()
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/docs/checkouts/readthedocs.org/user_builds/drms/envs/stable/lib/python3.11/site-packages/drms/client.py", line 190, in _generate_download_urls
    res = self.data.copy()
          ^^^^^^^^^
  File "/home/docs/checkouts/readthedocs.org/user_builds/drms/envs/stable/lib/python3.11/site-packages/drms/client.py", line 295, in data
    self._raise_on_error()
  File "/home/docs/checkouts/readthedocs.org/user_builds/drms/envs/stable/lib/python3.11/site-packages/drms/client.py", line 184, in _raise_on_error
    raise DrmsExportError(msg)
drms.exceptions.DrmsExportError: User jsoc@sunpy.org has 1 pending export requests (JSOC_20240810_001925); please wait until at least one request has completed before submitting a new one. [status=7]

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

Gallery generated by Sphinx-Gallery