VSOClient

class sunpy.net.vso.VSOClient(url=None, port=None, api=None)[source]

Bases: sunpy.net.base_client.BaseClient

Allows queries and downloads from the Virtual Solar Observatory (VSO).

Parameters
  • url (str, optional) – The VSO url to use. If not specified will use the first online known URL.

  • port (str, optional) – The VSO port name to use. If not specified will use the first online known URL.

  • api (zeep.Client, optional) – The zeep.Client instance to use for interacting with the VSO. If not specified one will be created.

Attributes Summary

method_order

Methods Summary

by_fileid(response)

Returns a dictionary of fileids corresponding to records in the response.

by_provider(response)

Returns a dictionary of provider corresponding to records in the response.

create_getdatarequest(maps, methods[, info])

Create datarequest from maps mapping data provider to fileids and methods,

create_parse_vso_values()

Makes a network call to the VSO API that returns what keywords they support.

download(method, url, downloader, *args)

Enqueue a file to be downloaded, extra args are passed to mk_filename

download_all(response, methods, downloader, …)

fetch(query_response[, path, methods, site, …])

Download data specified in the query_response.

link(query_response, maps)

Return list of paths with records associated with them in the meta attribute.

load_vso_values()

We take this list and register all the keywords as corresponding Attrs.

make(atype, **kwargs)

Create a new SOAP object.

make_getdatarequest(response[, methods, info])

Make datarequest with methods from response.

merge(queryresponses)

Merge responses into one.

missing_information(info, field)

Override to provide missing information.

mk_filename(pattern, queryresponse, resp, url)

Generate the best possible (or least-worse) filename for a VSO download.

multiple_choices(choices, response)

Override to pick between multiple download choices.

register_values()

This enables the client to register what kind of Attrs it can use directly.

search(*query)

Query data from the VSO with the new API.

unknown_method(response)

Override to pick a new method if the current one is unknown.

Attributes Documentation

method_order = ['URL-FILE_Rice', 'URL-FILE', 'URL-packaged', 'URL-TAR_GZ', 'URL-ZIP', 'URL-TAR']

Methods Documentation

static by_fileid(response)[source]

Returns a dictionary of fileids corresponding to records in the response.

static by_provider(response)[source]

Returns a dictionary of provider corresponding to records in the response.

create_getdatarequest(maps, methods, info=None)[source]

Create datarequest from maps mapping data provider to fileids and methods,

static create_parse_vso_values()[source]

Makes a network call to the VSO API that returns what keywords they support. We take this list and register all the keywords as corresponding Attrs.

download(method, url, downloader, *args)[source]

Enqueue a file to be downloaded, extra args are passed to mk_filename

download_all(response, methods, downloader, path, qr, info=None)[source]
fetch(query_response, path=None, methods=None, site=None, progress=True, overwrite=False, downloader=None, wait=True)[source]

Download data specified in the query_response.

Parameters
  • query_response (sunpy.net.vso.QueryResponse) – QueryResponse containing the items to be downloaded.

  • path (str) – Specify where the data is to be downloaded. Can refer to arbitrary fields of the QueryResponseItem (instrument, source, time, …) via string formatting, moreover the file-name of the file downloaded can be referred to as file, e.g. “{source}/{instrument}/{time.start}/{file}”.

  • methods ({list of str}) – Download methods, defaults to URL-FILE_Rice then URL-FILE. Methods are a concatenation of one PREFIX followed by any number of SUFFIXES i.e. PREFIX-SUFFIX_SUFFIX2_SUFFIX3. The full list of PREFIXES and SUFFIXES are listed on the VSO site.

  • site (str) –

    There are a number of caching mirrors for SDO and other instruments, some available ones are listed below.

    NSO

    National Solar Observatory, Tucson (US)

    SAO (aka CFA)

    Smithonian Astronomical Observatory, Harvard U. (US)

    SDAC (aka GSFC)

    Solar Data Analysis Center, NASA/GSFC (US)

    ROB

    Royal Observatory of Belgium (Belgium)

    MPS

    Max Planck Institute for Solar System Research (Germany)

    UCLan

    University of Central Lancashire (UK)

    IAS

    Institut Aeronautique et Spatial (France)

    KIS

    Kiepenheuer-Institut fur Sonnenphysik Germany)

    NMSU

    New Mexico State University (US)

  • progress (bool, optional) – If True show a progress bar showing how many of the total files have been downloaded. If False, no progress bars will be shown at all.

  • overwrite (bool or str, optional) – Determine how to handle downloading if a file already exists with the same name. If False the file download will be skipped and the path returned to the existing file, if True the file will be downloaded and the existing file will be overwritten, if 'unique' the filename will be modified to be unique.

  • downloader (parfive.Downloader, optional) – The download manager to use.

  • wait (bool, optional) – If False downloader.download() will not be called. Only has any effect if downloader is not None.

Returns

out (parfive.Results) – Object that supplies a list of filenames and any errors.

Examples

>>> files = fetch(qr) 

Return list of paths with records associated with them in the meta attribute.

static load_vso_values()[source]

We take this list and register all the keywords as corresponding Attrs.

Returns

dict – The constructed Attrs dictionary ready to be passed into Attr registry.

make(atype, **kwargs)[source]

Create a new SOAP object.

make_getdatarequest(response, methods=None, info=None)[source]

Make datarequest with methods from response.

merge(queryresponses)[source]

Merge responses into one.

missing_information(info, field)[source]

Override to provide missing information.

static mk_filename(pattern, queryresponse, resp, url)[source]

Generate the best possible (or least-worse) filename for a VSO download.

  • Use the content-disposition header.

  • Use fileid to generate a file name if content-disposition fails

  • If everything else fails use the last segment of the URL and hope.

multiple_choices(choices, response)[source]

Override to pick between multiple download choices.

classmethod register_values()[source]

This enables the client to register what kind of Attrs it can use directly.

Returns

dict – A dictionary with key values of Attrs and the values are a tuple of (“Attr Type”, “Name”, “Description”).

search(*query)[source]

Query data from the VSO with the new API. Takes a variable number of attributes as parameter, which are chained together using AND.

The new query language allows complex queries to be easily formed.

Examples

Query all data from eit or aia between 2010-01-01T00:00 and 2010-01-01T01:00.

>>> from datetime import datetime
>>> from sunpy.net import vso, attrs as a
>>> client = vso.VSOClient()  
>>> client.search(
...    a.Time(datetime(2010, 1, 1), datetime(2010, 1, 1, 1)),
...    a.Instrument.eit | a.Instrument.aia)   
<sunpy.net.vso.vso.QueryResponse object at ...>
   Start Time [1]       End Time [1]    Source ...   Type   Wavelength [2]
                                               ...             Angstrom
------------------- ------------------- ------ ... -------- --------------
2010-01-01 00:00:08 2010-01-01 00:00:20   SOHO ... FULLDISK 195.0 .. 195.0
2010-01-01 00:12:08 2010-01-01 00:12:20   SOHO ... FULLDISK 195.0 .. 195.0
2010-01-01 00:24:10 2010-01-01 00:24:22   SOHO ... FULLDISK 195.0 .. 195.0
2010-01-01 00:36:08 2010-01-01 00:36:20   SOHO ... FULLDISK 195.0 .. 195.0
2010-01-01 00:48:09 2010-01-01 00:48:21   SOHO ... FULLDISK 195.0 .. 195.0
Returns

out (QueryResult (enhanced list)) – Matched items. Return value is of same type as the one of VSOClient.search().

unknown_method(response)[source]

Override to pick a new method if the current one is unknown.