| 1 |
""" |
| 2 |
============================== |
| 3 |
Getting the urls of a download |
| 4 |
============================== |
| 5 |
|
| 6 |
This example prints the download URLs for files returned from an 'as-is' data |
| 7 |
export request. |
| 8 |
|
| 9 |
Note that there is no "Request URL" for method 'url_quick'. |
| 10 |
""" |
| 11 |
|
| 12 |
import os |
| 13 |
|
| 14 |
import drms |
| 15 |
|
| 16 |
############################################################################### |
| 17 |
# First we will create a `drms.Client`, using the JSOC baseurl. |
| 18 |
|
| 19 |
client = drms.Client() |
| 20 |
|
| 21 |
# This example requires a registered export email address. You can register |
| 22 |
# JSOC exports at: http://jsoc.stanford.edu/ajax/register_email.html |
| 23 |
# You must supply your own email. |
| 24 |
email = os.environ["JSOC_EMAIL"] |
| 25 |
|
| 26 |
############################################################################### |
| 27 |
# Construct the DRMS query string: "Series[timespan][wavelength]" |
| 28 |
|
| 29 |
qstr = "hmi.ic_720s[2015.01.01_00:00:00_TAI/10d@1d]{continuum}" |
| 30 |
|
| 31 |
# Submit export request, defaults to method='url_quick' and protocol='as-is' |
| 32 |
print(f"Data export query:\n {qstr}\n") |
| 33 |
print("Submitting export request...") |
| 34 |
result = client.export(qstr, email=email) |
| 35 |
print(f"{len(result.urls)} file(s) available for download.\n") |
| 36 |
|
| 37 |
# Print download URLs. |
| 38 |
for _, row in result.urls[["record", "url"]].iterrows(): |
| 39 |
print(f"REC(ORD): {row.record}") |
| 40 |
print(f"URL: {row.url}\n") |