Searching and downloading from the VSO

How to download data from the VSO with Fido.

import astropy.units as u

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

sunpy.net.Fido is the primary interface to search for and download data and will search the VSO when appropriate. The following example searches for all SOHO/EIT images between the times defined below by defining a timerange (Time) and the instrument (Instrument).

attrs_time = a.Time('2005/01/01 00:10', '2005/01/01 00:15')
result = Fido.search(attrs_time, a.Instrument.eit)

Let’s inspect the results.

print(result)

Out:

Results from 1 Provider:

1 Results from the VSOClient:
Source: http://vso.stanford.edu/cgi-bin/search

       Start Time               End Time        Source ... Extent Type   Size
                                                       ...              Mibyte
----------------------- ----------------------- ------ ... ----------- -------
2005-01-01 00:12:10.000 2005-01-01 00:12:22.000   SOHO ...    FULLDISK 2.01074

The following shows how to download the results. If we don’t provide a path it will download the file into the sunpy data directory. The output provides the path of the downloaded files.

downloaded_files = Fido.fetch(result)
print(downloaded_files)

Out:

['/home/docs/sunpy/data/efz20050101.001210']

More complicated queries can be constructed by using relational operators. For example, it is possible to query two wavelengths at the same time with the OR operator (|).

result = Fido.search(a.Time('2020/03/04 00:00', '2020/03/04 00:02'),
                     a.Instrument.aia,
                     a.Wavelength(171*u.angstrom) | a.Wavelength(94*u.angstrom))
print(result)

Out:

Results from 2 Providers:

10 Results from the VSOClient:
Source: http://vso.stanford.edu/cgi-bin/search

       Start Time       ...
                        ...
----------------------- ...
2020-03-04 00:00:09.000 ...
2020-03-04 00:00:21.000 ...
2020-03-04 00:00:33.000 ...
2020-03-04 00:00:45.000 ...
2020-03-04 00:00:57.000 ...
2020-03-04 00:01:09.000 ...
2020-03-04 00:01:21.000 ...
2020-03-04 00:01:33.000 ...
2020-03-04 00:01:45.000 ...
2020-03-04 00:01:57.000 ...

10 Results from the VSOClient:
Source: http://vso.stanford.edu/cgi-bin/search

       Start Time       ...
                        ...
----------------------- ...
2020-03-04 00:00:11.000 ...
2020-03-04 00:00:23.000 ...
2020-03-04 00:00:35.000 ...
2020-03-04 00:00:47.000 ...
2020-03-04 00:00:59.000 ...
2020-03-04 00:01:11.000 ...
2020-03-04 00:01:23.000 ...
2020-03-04 00:01:35.000 ...
2020-03-04 00:01:47.000 ...
2020-03-04 00:01:59.000 ...

We can even combine entire queries in this manner. Here we will define two searches for the AIA and HMI data. But unlike other examples, we have to & the individual queries.

search_aia = (a.Time('2020/03/04 00:00', '2020/03/04 00:01') & a.Instrument.aia)
search_hmi = (a.Time('2020/03/04 00:00', '2020/03/04 00:01')
              & a.Instrument.hmi & a.Physobs.los_magnetic_field)

result = Fido.search(search_aia | search_hmi)
print(result)

Out:

Results from 2 Providers:

41 Results from the VSOClient:
Source: http://vso.stanford.edu/cgi-bin/search

       Start Time       ...
                        ...
----------------------- ...
2020-03-04 00:00:00.000 ...
2020-03-04 00:00:04.000 ...
2020-03-04 00:00:05.000 ...
2020-03-04 00:00:05.000 ...
2020-03-04 00:00:06.000 ...
2020-03-04 00:00:09.000 ...
2020-03-04 00:00:09.000 ...
2020-03-04 00:00:11.000 ...
2020-03-04 00:00:12.000 ...
2020-03-04 00:00:14.000 ...
                    ... ...
2020-03-04 00:00:47.000 ...
2020-03-04 00:00:48.000 ...
2020-03-04 00:00:52.000 ...
2020-03-04 00:00:52.000 ...
2020-03-04 00:00:53.000 ...
2020-03-04 00:00:54.000 ...
2020-03-04 00:00:57.000 ...
2020-03-04 00:00:57.000 ...
2020-03-04 00:00:59.000 ...
2020-03-04 00:01:00.000 ...
Length = 41 rows

1 Results from the VSOClient:
Source: http://vso.stanford.edu/cgi-bin/search

       Start Time               End Time        ...   Size          Info
                                                ...  Mibyte
----------------------- ----------------------- ... -------- ------------------
2020-03-04 00:00:26.000 2020-03-04 00:00:27.000 ... -0.00098 45sec. Magnetogram

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

Gallery generated by Sphinx-Gallery