There are two ways of downloading JSOC data. - One way is using
Sunpy’s unified search interface, known asFido. Fido supplies a single, easy and consistent way to to
obtain most forms of solar physics data. - An alternative way to fetch
data from JSOC is by using the underlying JSOCClient.
This option can be preferred when the complex searches are to be made,
or when you need to separate the staging and downloading steps, which is
not supported by Fido.
res = Fido.fetch(response, path='./data') # Will output a progress bar by default
JSOCClient
The JSOC stages data before you can download it, so a JSOC query is a
three stage process. 1.
search: query the JSOC for records and a
table of these records is returned. The result is
UnifiedResponse for Fido while
JSOCResponse for JSOCClient -
request_data: request these records to be
staged for download. - get_request:
download.
(Fido combines the stages into 2, search
and fetch.)
Searching for data
1 2
from sunpy.net import jsoc client = jsoc.JSOCClient()
from astropy.table.table import Table Table(response[2].table)
Table length=1
T_REC
TELESCOP
INSTRUME
WAVELNTH
CAR_ROT
str20
str7
str5
int64
int64
2014-01-01T00:00:01Z
SDO/AIA
AIA_3
171
2145
Other examples:
1
response[::2]
Table length=2
T_REC
TELESCOP
INSTRUME
WAVELNTH
CAR_ROT
str20
str7
str5
int64
int64
2014-01-01T00:00:01Z
SDO/AIA
AIA_4
304
2145
2014-01-01T00:00:01Z
SDO/AIA
AIA_3
171
2145
1
response[:2]
Table length=2
T_REC
TELESCOP
INSTRUME
WAVELNTH
CAR_ROT
str20
str7
str5
int64
int64
2014-01-01T00:00:01Z
SDO/AIA
AIA_4
304
2145
2014-01-01T00:00:13Z
SDO/AIA
AIA_4
304
2145
1
response[[0, 2]]
Table length=2
T_REC
TELESCOP
INSTRUME
WAVELNTH
CAR_ROT
str20
str7
str5
int64
int64
2014-01-01T00:00:01Z
SDO/AIA
AIA_4
304
2145
2014-01-01T00:00:01Z
SDO/AIA
AIA_3
171
2145
Downloading data
Download the entire results:
1
res = client.fetch(response, path='./data')
Export request pending. [id="JSOC_20180710_1151", status=2]
Waiting for 0 seconds...
Export request pending. [id="JSOC_20180710_1151", status=1]
Waiting for 5 seconds...
4 URLs found for download. Full request totalling 17MB
Export request pending. [id="JSOC_20180710_1152", status=2]
Waiting for 0 seconds...
4 URLs found for download. Full request totalling 24MB
1
res.wait() # Show the progress bar & wait to finish downloading.
Or separate out the staging to request_data &
get_request:
1
requests = client.request_data(response)
1
requests.id
'JSOC_20180708_435'
1
requests.status
0
1
res = client.get_request(requests, path='./data')
1
res.wait()
So far, the best way to download a subset of the results is to
make a query again.
Or use JSOCClient (and a custom
function) instead of Fido to search for
data.
See details below:
If slice the result as response[2], everything is OK
except query_args is lost.
http://docs.sunpy.org/en/stable/guide/acquiring_data/jsoc.html
> Start and end times for the query (any date/time format understood
by SunPy’s parse_time function can be used to specify dates
and time). The Time attribute takes UTC time, as
default. If you need to pass a Time in some other time
scale, such as TAI, pass an Astropy Time object
If sunpy.time doesn't inlude this format:
"%Y-%m-%dT%H:%M:%SZ", use a
bash script to add it:
1
!sunpy-add-time-fmt
Added this format to
/home/lydia/miniconda3/lib/python3.6/site-packages/sunpy/time/time.py:
[01;31m[K"%Y-%m-%dT%H:%M:%SZ"[m[K, # Example 2007-05-04T21:08:12Z
=== Done!(sunpy-add-time-fmt) ===
1
parse_time('2014-01-01T00:00:00Z')
datetime.datetime(2014, 1, 1, 0, 0)
For convenience, use a custom function to pass a time string in 'TAI'
scale:
1
from usr_sunpy import tai
1
tai('2014-01-01T00:00:00') # Returns a single object