Note
Go to the end to download the full example code
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)
Results from 1 Provider:
1 Results from the VSOClient:
Source: http://vso.stanford.edu/cgi-bin/search
Total estimated size: 2.108 Mbyte
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)
['/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)
Results from 2 Providers:
10 Results from the VSOClient:
Source: http://vso.stanford.edu/cgi-bin/search
Total estimated size: 677.888 Mbyte
Start Time End Time Source ... Extent Type Size
... Mibyte
----------------------- ----------------------- ------ ... ----------- --------
2020-03-04 00:00:09.000 2020-03-04 00:00:10.000 SDO ... FULLDISK 64.64844
2020-03-04 00:00:21.000 2020-03-04 00:00:22.000 SDO ... FULLDISK 64.64844
2020-03-04 00:00:33.000 2020-03-04 00:00:34.000 SDO ... FULLDISK 64.64844
2020-03-04 00:00:45.000 2020-03-04 00:00:46.000 SDO ... FULLDISK 64.64844
2020-03-04 00:00:57.000 2020-03-04 00:00:58.000 SDO ... FULLDISK 64.64844
2020-03-04 00:01:09.000 2020-03-04 00:01:10.000 SDO ... FULLDISK 64.64844
2020-03-04 00:01:21.000 2020-03-04 00:01:22.000 SDO ... FULLDISK 64.64844
2020-03-04 00:01:33.000 2020-03-04 00:01:34.000 SDO ... FULLDISK 64.64844
2020-03-04 00:01:45.000 2020-03-04 00:01:46.000 SDO ... FULLDISK 64.64844
2020-03-04 00:01:57.000 2020-03-04 00:01:58.000 SDO ... FULLDISK 64.64844
10 Results from the VSOClient:
Source: http://vso.stanford.edu/cgi-bin/search
Total estimated size: 677.888 Mbyte
Start Time End Time Source ... Extent Type Size
... Mibyte
----------------------- ----------------------- ------ ... ----------- --------
2020-03-04 00:00:11.000 2020-03-04 00:00:12.000 SDO ... FULLDISK 64.64844
2020-03-04 00:00:23.000 2020-03-04 00:00:24.000 SDO ... FULLDISK 64.64844
2020-03-04 00:00:35.000 2020-03-04 00:00:36.000 SDO ... FULLDISK 64.64844
2020-03-04 00:00:47.000 2020-03-04 00:00:48.000 SDO ... FULLDISK 64.64844
2020-03-04 00:00:59.000 2020-03-04 00:01:00.000 SDO ... FULLDISK 64.64844
2020-03-04 00:01:11.000 2020-03-04 00:01:12.000 SDO ... FULLDISK 64.64844
2020-03-04 00:01:23.000 2020-03-04 00:01:24.000 SDO ... FULLDISK 64.64844
2020-03-04 00:01:35.000 2020-03-04 00:01:36.000 SDO ... FULLDISK 64.64844
2020-03-04 00:01:47.000 2020-03-04 00:01:48.000 SDO ... FULLDISK 64.64844
2020-03-04 00:01:59.000 2020-03-04 00:02:00.000 SDO ... FULLDISK 64.64844
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)
Results from 2 Providers:
41 Results from the VSOClient:
Source: http://vso.stanford.edu/cgi-bin/search
Total estimated size: 2.779 Gbyte
Start Time End Time Source ... Extent Type Size
... Mibyte
----------------------- ----------------------- ------ ... ----------- --------
2020-03-04 00:00:00.000 2020-03-04 00:00:01.000 SDO ... FULLDISK 64.64844
2020-03-04 00:00:04.000 2020-03-04 00:00:05.000 SDO ... FULLDISK 64.64844
2020-03-04 00:00:05.000 2020-03-04 00:00:06.000 SDO ... FULLDISK 64.64844
2020-03-04 00:00:05.000 2020-03-04 00:00:06.000 SDO ... FULLDISK 64.64844
2020-03-04 00:00:06.000 2020-03-04 00:00:07.000 SDO ... FULLDISK 64.64844
2020-03-04 00:00:09.000 2020-03-04 00:00:10.000 SDO ... FULLDISK 64.64844
2020-03-04 00:00:09.000 2020-03-04 00:00:10.000 SDO ... FULLDISK 64.64844
2020-03-04 00:00:11.000 2020-03-04 00:00:12.000 SDO ... FULLDISK 64.64844
2020-03-04 00:00:12.000 2020-03-04 00:00:13.000 SDO ... FULLDISK 64.64844
2020-03-04 00:00:14.000 2020-03-04 00:00:15.000 SDO ... FULLDISK 64.64844
... ... ... ... ... ...
2020-03-04 00:00:47.000 2020-03-04 00:00:48.000 SDO ... FULLDISK 64.64844
2020-03-04 00:00:48.000 2020-03-04 00:00:49.000 SDO ... FULLDISK 64.64844
2020-03-04 00:00:52.000 2020-03-04 00:00:53.000 SDO ... FULLDISK 64.64844
2020-03-04 00:00:52.000 2020-03-04 00:00:53.000 SDO ... FULLDISK 64.64844
2020-03-04 00:00:53.000 2020-03-04 00:00:54.000 SDO ... FULLDISK 64.64844
2020-03-04 00:00:54.000 2020-03-04 00:00:55.000 SDO ... FULLDISK 64.64844
2020-03-04 00:00:57.000 2020-03-04 00:00:58.000 SDO ... FULLDISK 64.64844
2020-03-04 00:00:57.000 2020-03-04 00:00:58.000 SDO ... FULLDISK 64.64844
2020-03-04 00:00:59.000 2020-03-04 00:01:00.000 SDO ... FULLDISK 64.64844
2020-03-04 00:01:00.000 2020-03-04 00:01:01.000 SDO ... FULLDISK 64.64844
Length = 41 rows
1 Results from the VSOClient:
Source: http://vso.stanford.edu/cgi-bin/search
Start Time End Time Source ... Extent Type Size
... Mibyte
----------------------- ----------------------- ------ ... ----------- --------
2020-03-04 00:00:26.000 2020-03-04 00:00:27.000 SDO ... FULLDISK -0.00098
Total running time of the script: ( 0 minutes 15.721 seconds)