VSOClient

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

Bases: object

Main VSO Client.

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,
download(method, url, dw, callback, errback, …) Override to costumize download action.
download_all(response, methods, dw, path, …)
fetch(query_response[, path, methods, …]) Download data specified in the query_response.
get(query_response[, path, methods, …])

Deprecated since version 0.8.

latest() Return newest record (limited to last week).
link(query_response, maps) Return list of paths with records associated with them in the meta attribute.
make(atype, **kwargs) Create new SOAP object with attributes specified in kwargs.
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, response, sock, url[, …])
multiple_choices(choices, response) Override to pick between multiple download choices.
query(*query)

Deprecated since version 0.8.

query_legacy([tstart, tend]) Query data from the VSO mocking the IDL API as close as possible.
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-TAR_GZ', 'URL-ZIP', 'URL-TAR', 'URL-FILE', 'URL-packaged']

Methods Documentation

static by_fileid(response)[source] [edit on github]

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

static by_provider(response)[source] [edit on github]

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

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

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

download(method, url, dw, callback, errback, *args)[source] [edit on github]

Override to costumize download action.

download_all(response, methods, dw, path, qr, res, info=None)[source] [edit on github]
fetch(query_response, path=None, methods=('URL-FILE_Rice', 'URL-FILE'), downloader=None, site=None)[source] [edit on github]

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.
  • downloader (sunpy.net.downloader.Downloader) – Downloader used to download the data.
  • 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)
Returns:

out (Results) – Object that supplies a list of filenames with meta attributes containing the respective QueryResponse.

Examples

>>> res = fetch(qr).wait() # doctest:+SKIP
get(query_response, path=None, methods=('URL-FILE_Rice', 'URL-FILE'), downloader=None, site=None)[source] [edit on github]

Deprecated since version 0.8: The get function is deprecated and may be removed in a future version. Use VSOClient.fetch instead.

See fetch

latest()[source] [edit on github]

Return newest record (limited to last week).

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

make(atype, **kwargs)[source] [edit on github]

Create new SOAP object with attributes specified in kwargs. To assign subattributes, use foo__bar=1 to assign [‘foo’][‘bar’] = 1.

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

Make datarequest with methods from response.

merge(queryresponses)[source] [edit on github]

Merge responses into one.

missing_information(info, field)[source] [edit on github]

Override to provide missing information.

static mk_filename(pattern, response, sock, url, overwrite=False)[source] [edit on github]
multiple_choices(choices, response)[source] [edit on github]

Override to pick between multiple download choices.

query(*query)[source] [edit on github]

Deprecated since version 0.8: The query function is deprecated and may be removed in a future version. Use VSOClient.search instead.

See search

query_legacy(tstart=None, tend=None, **kwargs)[source] [edit on github]

Query data from the VSO mocking the IDL API as close as possible. Either tstart and tend or date_start and date_end or date have to be supplied.

Parameters:
  • tstart (datetime.datetime) – Start of the time-range in which records are searched.
  • tend (datetime.datetime) – Start of the time-range in which records are searched.
  • date (str) – (start date) - (end date)
  • start_date (datetime) – the start date
  • end_date (datetime) – the end date
  • wave (str) – (min) - (max) (unit)
  • min_wave (str) – minimum spectral range
  • max_wave (str) – maximum spectral range
  • unit_wave (str) – spectral range units (Angstrom, GHz, keV)
  • extent (str) – VSO ‘extent type’ … (FULLDISK, CORONA, LIMB, etc)
  • physobj (str) – VSO ‘physical observable’
  • provider (str) – VSO ID for the data provider (SDAC, NSO, SHA, MSU, etc)
  • source (str) – spacecraft or observatory (SOHO, YOHKOH, BBSO, etc) synonyms : spacecraft, observatory
  • instrument (str) – instrument ID (EIT, SXI-0, SXT, etc) synonyms : telescope, inst
  • detector (str) – detector ID (C3, EUVI, COR2, etc.)
  • layout (str) – layout of the data (image, spectrum, time_series, etc.)
  • level (str) – level of the data product (numeric range, see below)
  • pixels (str) – number of pixels (numeric range, see below)
  • resolution (str) – effective resolution (1 = full, 0.5 = 2x2 binned, etc) numeric range, see below.
  • pscale (str) – pixel scale, in arcseconds (numeric range, see below)
  • near_time (datetime) – return record closest to the time. See below.
  • sample (int) – attempt to return only one record per SAMPLE seconds. See below.
  • Ranges (Numeric) –
    • May be entered as a string or any numeric type for equality matching
    • May be a string of the format ‘(min) - (max)’ for range matching
    • May be a string of the form ‘(operator) (number)’ where operator is one of: lt gt le ge < > <= >=

Examples

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

>>> from datetime import datetime
>>> from sunpy.net import vso
>>> client = vso.VSOClient()  # doctest: +REMOTE_DATA
>>> qr = client.query_legacy(datetime(2010, 1, 1),
...                          datetime(2010, 1, 1, 1), instrument='eit')  # doctest: +REMOTE_DATA
Returns:out (QueryResult (enhanced list)) – Matched items. Return value is of same type as the one of VSOClient.query.
search(*query)[source] [edit on github]

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
>>> client = vso.VSOClient()  # doctest: +REMOTE_DATA
>>> client.search(
...    vso.attrs.Time(datetime(2010, 1, 1), datetime(2010, 1, 1, 1)),
...    vso.attrs.Instrument('eit') | vso.attrs.Instrument('aia'))   # doctest:  +REMOTE_DATA
<QTable length=5>
   Start Time [1]       End Time [1]    Source ...   Type   Wavelength [2]
                                               ...             Angstrom
       str19               str19         str4  ...   str8      float64
------------------- ------------------- ------ ... -------- --------------
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.query().
unknown_method(response)[source] [edit on github]

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