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, 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
       str19               str19         str4  ...   str8      float64
------------------- ------------------- ------ ... -------- --------------
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:

/home/docs/checkouts/readthedocs.org/user_builds/sunpy/conda/v1.1.4/lib/python3.8/site-packages/parfive/downloader.py:100: DeprecationWarning: The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.
  self.http_queue = asyncio.Queue(loop=self.loop)
/home/docs/checkouts/readthedocs.org/user_builds/sunpy/conda/v1.1.4/lib/python3.8/asyncio/queues.py:48: DeprecationWarning: The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.
  self._finished = locks.Event(loop=loop)
/home/docs/checkouts/readthedocs.org/user_builds/sunpy/conda/v1.1.4/lib/python3.8/site-packages/parfive/downloader.py:101: DeprecationWarning: The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.
  self.http_tokens = asyncio.Queue(maxsize=self.max_conn, loop=self.loop)
/home/docs/checkouts/readthedocs.org/user_builds/sunpy/conda/v1.1.4/lib/python3.8/asyncio/queues.py:48: DeprecationWarning: The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.
  self._finished = locks.Event(loop=loop)
/home/docs/checkouts/readthedocs.org/user_builds/sunpy/conda/v1.1.4/lib/python3.8/site-packages/parfive/downloader.py:102: DeprecationWarning: The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.
  self.ftp_queue = asyncio.Queue(loop=self.loop)
/home/docs/checkouts/readthedocs.org/user_builds/sunpy/conda/v1.1.4/lib/python3.8/asyncio/queues.py:48: DeprecationWarning: The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.
  self._finished = locks.Event(loop=loop)
/home/docs/checkouts/readthedocs.org/user_builds/sunpy/conda/v1.1.4/lib/python3.8/site-packages/parfive/downloader.py:103: DeprecationWarning: The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.
  self.ftp_tokens = asyncio.Queue(maxsize=self.max_conn, loop=self.loop)
/home/docs/checkouts/readthedocs.org/user_builds/sunpy/conda/v1.1.4/lib/python3.8/asyncio/queues.py:48: DeprecationWarning: The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.
  self._finished = locks.Event(loop=loop)

Files Downloaded:   0%|          | 0/1 [00:00<?, ?file/s]/home/docs/checkouts/readthedocs.org/user_builds/sunpy/conda/v1.1.4/lib/python3.8/site-packages/parfive/downloader.py:312: DeprecationWarning: The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.
  done, _ = await asyncio.wait(futures, loop=self.loop)
/home/docs/checkouts/readthedocs.org/user_builds/sunpy/conda/v1.1.4/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/v1.1.4/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/v1.1.4/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/v1.1.4/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/v1.1.4/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/v1.1.4/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/v1.1.4/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        | 339k/2.11M [00:00<00:00, 2.72MB/s]

efz20050101.001210:  62%|######1   | 1.31M/2.11M [00:00<00:00, 3.47MB/s]

                                                                        
Files Downloaded: 100%|##########| 1/1 [00:00<00:00,  2.80file/s]
Files Downloaded: 100%|##########| 1/1 [00:00<00:00,  2.79file/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('2012/03/04 00:00', '2012/03/04 00:02'),
                     a.Instrument('aia'),
                     a.Wavelength(171*u.angstrom) | a.Wavelength(94*u.angstrom))
print(result)

Out:

Results from 2 Providers:

11 Results from the VSOClient:
   Start Time [1]       End Time [1]    Source ...   Type   Wavelength [2]
                                               ...             Angstrom
       str19               str19         str3  ...   str8      float64
------------------- ------------------- ------ ... -------- --------------
2012-03-04 00:00:00 2012-03-04 00:00:01    SDO ... FULLDISK 171.0 .. 171.0
2012-03-04 00:00:12 2012-03-04 00:00:13    SDO ... FULLDISK 171.0 .. 171.0
2012-03-04 00:00:24 2012-03-04 00:00:25    SDO ... FULLDISK 171.0 .. 171.0
2012-03-04 00:00:36 2012-03-04 00:00:37    SDO ... FULLDISK 171.0 .. 171.0
2012-03-04 00:00:48 2012-03-04 00:00:49    SDO ... FULLDISK 171.0 .. 171.0
2012-03-04 00:01:00 2012-03-04 00:01:01    SDO ... FULLDISK 171.0 .. 171.0
2012-03-04 00:01:12 2012-03-04 00:01:13    SDO ... FULLDISK 171.0 .. 171.0
2012-03-04 00:01:24 2012-03-04 00:01:25    SDO ... FULLDISK 171.0 .. 171.0
2012-03-04 00:01:36 2012-03-04 00:01:37    SDO ... FULLDISK 171.0 .. 171.0
2012-03-04 00:01:48 2012-03-04 00:01:49    SDO ... FULLDISK 171.0 .. 171.0
2012-03-04 00:02:00 2012-03-04 00:02:01    SDO ... FULLDISK 171.0 .. 171.0

10 Results from the VSOClient:
   Start Time [1]       End Time [1]    Source ...   Type   Wavelength [2]
                                               ...             Angstrom
       str19               str19         str3  ...   str8      float64
------------------- ------------------- ------ ... -------- --------------
2012-03-04 00:00:02 2012-03-04 00:00:03    SDO ... FULLDISK   94.0 .. 94.0
2012-03-04 00:00:14 2012-03-04 00:00:15    SDO ... FULLDISK   94.0 .. 94.0
2012-03-04 00:00:26 2012-03-04 00:00:27    SDO ... FULLDISK   94.0 .. 94.0
2012-03-04 00:00:38 2012-03-04 00:00:39    SDO ... FULLDISK   94.0 .. 94.0
2012-03-04 00:00:50 2012-03-04 00:00:51    SDO ... FULLDISK   94.0 .. 94.0
2012-03-04 00:01:02 2012-03-04 00:01:03    SDO ... FULLDISK   94.0 .. 94.0
2012-03-04 00:01:14 2012-03-04 00:01:15    SDO ... FULLDISK   94.0 .. 94.0
2012-03-04 00:01:26 2012-03-04 00:01:27    SDO ... FULLDISK   94.0 .. 94.0
2012-03-04 00:01:38 2012-03-04 00:01:39    SDO ... FULLDISK   94.0 .. 94.0
2012-03-04 00:01:50 2012-03-04 00:01:51    SDO ... FULLDISK   94.0 .. 94.0

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

Gallery generated by Sphinx-Gallery