Getting data from CDAWeb

How to download data from the Coordinated Data Analysis Web (CDAWeb).

CDAWeb stores data from from current and past space physics missions, and is full of heliospheric insitu datasets.

from sunpy.net import Fido
from sunpy.net import attrs as a
from sunpy.timeseries import TimeSeries

sunpy.net.Fido is the primary interface to search for and download data and will automatically search CDAWeb when the cdaweb.Dataset attribute is provided to the search. To lookup the different dataset IDs available, you can use the form at https://cdaweb.gsfc.nasa.gov/index.html/

trange = a.Time('2021/07/01', '2021/07/08')
dataset = a.cdaweb.Dataset('SOLO_L2_MAG-RTN-NORMAL-1-MINUTE')
result = Fido.search(trange, dataset)

Let’s inspect the results. We can see that there’s seven files, one for each day within the query.

print(result)

Out:

Results from 1 Provider:

7 Results from the CDAWEBClient:
Source: https://cdaweb.gsfc.nasa.gov/index.html

            Dataset                    Start time               End time
------------------------------- ----------------------- -----------------------
SOLO_L2_MAG-RTN-NORMAL-1-MINUTE 2021-07-01 00:00:29.000 2021-07-01 23:59:30.000
SOLO_L2_MAG-RTN-NORMAL-1-MINUTE 2021-07-02 00:00:29.000 2021-07-02 23:59:30.000
SOLO_L2_MAG-RTN-NORMAL-1-MINUTE 2021-07-03 00:00:29.000 2021-07-03 23:59:30.000
SOLO_L2_MAG-RTN-NORMAL-1-MINUTE 2021-07-04 00:00:29.000 2021-07-04 23:59:30.000
SOLO_L2_MAG-RTN-NORMAL-1-MINUTE 2021-07-05 00:00:29.000 2021-07-05 23:59:30.000
SOLO_L2_MAG-RTN-NORMAL-1-MINUTE 2021-07-06 00:00:29.000 2021-07-06 23:59:30.000
SOLO_L2_MAG-RTN-NORMAL-1-MINUTE 2021-07-07 00:00:29.000 2021-07-07 23:59:30.000

Let’s download the first two files

downloaded_files = Fido.fetch(result[0, 0:2])
print(downloaded_files)

Out:

['/home/docs/sunpy/data/solo_l2_mag-rtn-normal-1-minute_20210702_v01.cdf', '/home/docs/sunpy/data/solo_l2_mag-rtn-normal-1-minute_20210701_v01.cdf']

Finally we can load and take a look at the data using TimeSeries This requires an installation of the cdflib Python library to read the CDF file.

solo_mag = TimeSeries(downloaded_files, concatenate=True)
print(solo_mag.columns)
solo_mag.peek(['B_RTN_0', 'B_RTN_1', 'B_RTN_2'])
search cdaweb

Out:

['B_RTN_0', 'B_RTN_1', 'B_RTN_2', 'QUALITY_BITMASK', 'QUALITY_FLAG', 'VECTOR_RANGE', 'VECTOR_TIME_RESOLUTION']

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

Gallery generated by Sphinx-Gallery