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:
   Start Time [1]       End Time [1]    Source ...   Type   Wavelength [2]
                                               ...             Angstrom
------------------- ------------------- ------ ... -------- --------------
2005-01-01 00:12:10 2005-01-01 00:12:22   SOHO ... FULLDISK 195.0 .. 195.0

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:

Files Downloaded:   0%|          | 0/1 [00:00<?, ?file/s]/home/docs/checkouts/readthedocs.org/user_builds/sunpy/conda/stable/lib/python3.8/site-packages/aiohttp/connector.py:964: DeprecationWarning: The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.
  hosts = await asyncio.shield(self._resolve_host(
/home/docs/checkouts/readthedocs.org/user_builds/sunpy/conda/stable/lib/python3.8/site-packages/aiohttp/locks.py:21: DeprecationWarning: The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.
  self._event = asyncio.Event(loop=loop)


efz20050101.001210:   0%|          | 0.00/2.11M [00:00<?, ?B/s]/home/docs/checkouts/readthedocs.org/user_builds/sunpy/conda/stable/lib/python3.8/site-packages/aiohttp/connector.py:964: DeprecationWarning: The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.
  hosts = await asyncio.shield(self._resolve_host(
/home/docs/checkouts/readthedocs.org/user_builds/sunpy/conda/stable/lib/python3.8/site-packages/aiohttp/connector.py:964: DeprecationWarning: The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.
  hosts = await asyncio.shield(self._resolve_host(
/home/docs/checkouts/readthedocs.org/user_builds/sunpy/conda/stable/lib/python3.8/site-packages/aiohttp/connector.py:964: DeprecationWarning: The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.
  hosts = await asyncio.shield(self._resolve_host(
/home/docs/checkouts/readthedocs.org/user_builds/sunpy/conda/stable/lib/python3.8/site-packages/aiohttp/connector.py:964: DeprecationWarning: The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.
  hosts = await asyncio.shield(self._resolve_host(
/home/docs/checkouts/readthedocs.org/user_builds/sunpy/conda/stable/lib/python3.8/site-packages/aiohttp/connector.py:964: DeprecationWarning: The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.
  hosts = await asyncio.shield(self._resolve_host(


efz20050101.001210:  16%|#6        | 345k/2.11M [00:00<00:00, 3.45MB/s]

efz20050101.001210:  57%|#####7    | 1.21M/2.11M [00:00<00:00, 4.20MB/s]
Files Downloaded: 100%|##########| 1/1 [00:00<00:00,  2.77file/s]
Files Downloaded: 100%|##########| 1/1 [00:00<00:00,  2.77file/s]
['/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:
   Start Time [1]       End Time [1]    Source ...   Type   Wavelength [2]
                                               ...             Angstrom
------------------- ------------------- ------ ... -------- --------------
2020-03-04 00:00:09 2020-03-04 00:00:10    SDO ... FULLDISK 171.0 .. 171.0
2020-03-04 00:00:21 2020-03-04 00:00:22    SDO ... FULLDISK 171.0 .. 171.0
2020-03-04 00:00:33 2020-03-04 00:00:34    SDO ... FULLDISK 171.0 .. 171.0
2020-03-04 00:00:45 2020-03-04 00:00:46    SDO ... FULLDISK 171.0 .. 171.0
2020-03-04 00:00:57 2020-03-04 00:00:58    SDO ... FULLDISK 171.0 .. 171.0
2020-03-04 00:01:09 2020-03-04 00:01:10    SDO ... FULLDISK 171.0 .. 171.0
2020-03-04 00:01:21 2020-03-04 00:01:22    SDO ... FULLDISK 171.0 .. 171.0
2020-03-04 00:01:33 2020-03-04 00:01:34    SDO ... FULLDISK 171.0 .. 171.0
2020-03-04 00:01:45 2020-03-04 00:01:46    SDO ... FULLDISK 171.0 .. 171.0
2020-03-04 00:01:57 2020-03-04 00:01:58    SDO ... FULLDISK 171.0 .. 171.0

10 Results from the VSOClient:
   Start Time [1]       End Time [1]    Source ...   Type   Wavelength [2]
                                               ...             Angstrom
------------------- ------------------- ------ ... -------- --------------
2020-03-04 00:00:11 2020-03-04 00:00:12    SDO ... FULLDISK   94.0 .. 94.0
2020-03-04 00:00:23 2020-03-04 00:00:24    SDO ... FULLDISK   94.0 .. 94.0
2020-03-04 00:00:35 2020-03-04 00:00:36    SDO ... FULLDISK   94.0 .. 94.0
2020-03-04 00:00:47 2020-03-04 00:00:48    SDO ... FULLDISK   94.0 .. 94.0
2020-03-04 00:00:59 2020-03-04 00:01:00    SDO ... FULLDISK   94.0 .. 94.0
2020-03-04 00:01:11 2020-03-04 00:01:12    SDO ... FULLDISK   94.0 .. 94.0
2020-03-04 00:01:23 2020-03-04 00:01:24    SDO ... FULLDISK   94.0 .. 94.0
2020-03-04 00:01:35 2020-03-04 00:01:36    SDO ... FULLDISK   94.0 .. 94.0
2020-03-04 00:01:47 2020-03-04 00:01:48    SDO ... FULLDISK   94.0 .. 94.0
2020-03-04 00:01:59 2020-03-04 00:02:00    SDO ... FULLDISK   94.0 .. 94.0

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

Gallery generated by Sphinx-Gallery