GenericClient#

class sunpy.net.dataretriever.GenericClient[source]#

Bases: BaseClient

Base class for simple web clients for the data retriever module. This class is mainly designed for downloading data from FTP and HTTP type data sources, although should in theory be general enough to get data from any web service.

This class has two user facing methods search and fetch the former generates a set of results for files available through the service the client is querying and the latter downloads that data.

Search uses two hooks as helper functions; these are pre_search_hook() and post_search_hook(). They help to translate the attrs for scraper before and after the search respectively.

Attributes Summary

baseurl

enqueue_file_kwargs

pattern

required

Methods Summary

fetch(qres[, path, overwrite, progress, ...])

Download a set of results.

post_search_hook(exdict, matchdict)

Helper function used after search() which makes the extracted metadata representable in a query response table.

pre_search_hook(*args, **kwargs)

Helper function to return the baseurl, pattern and matchdict for the client required by search() before using the scraper.

search(*args, **kwargs)

Query this client for a list of results.

Attributes Documentation

baseurl = None#
enqueue_file_kwargs = {}#
pattern = None#
required = {<class 'sunpy.net.attrs.Instrument'> sunpy.net.attrs.Instrument  Specifies the Instrument name for the search.         Attribute Name       ... --------------------------- ... aia                         ... bcs                         ... be_continuum                ... be_halpha                   ... bigbear                     ... caii                        ... cds                         ... celias                      ... cerrotololo                 ... chp                         ... cook                        ... costep                      ... cp                          ... dpm                         ... eis                         ... eit                         ... elteide                     ... erne                        ... eui                         ... eve                         ... eve                         ... film                        ... five_12_channelmagnetograph ... foxsi                       ... gbm                         ... goes                        ... golf                        ... gong                        ... ha2                         ... hi_c                        ... hi_c21                      ... hmi                         ... hxeclipse                   ... hxt                         ... imax                        ... impact                      ... iris                        ... isoon                       ... iss                         ... ivm                         ... k_cor                       ... kpdc                        ... lasco                       ... learmonth                   ... longwave_lobe_06            ... longwave_lobe_07            ... longwave_slit_06            ... longwave_slit_07            ... lyra                        ... lyra                        ... maunaloa                    ... mdi                         ... mees                        ... mergedgong                  ... meudonspectroheliograph     ... mk4                         ... noaa_indices                ... noaa_predict                ... norh                        ... phoenix                     ... phoka                       ... plastic                     ... ptmc                        ... rhessi                      ... rhessi                      ... secchi                      ... shortwave_lobe_06           ... shortwave_lobe_07           ... shortwave_slit_06           ... shortwave_slit_07           ... six_0_ftshg                 ... sj                          ... solarftsspectrometer        ... solohi                      ... soon                        ... sot                         ... sp1                         ... sp2                         ... spectroheliograph           ... spectromagnetograph         ... spice                       ... srs_table                   ... sufi                        ... sumer                       ... sutri                       ... suvi                        ... suvi                        ... swan                        ... swap                        ... swaves                      ... sxt                         ... t1_halpha                   ... tm_1001                     ... tm_1010                     ... trace                       ... udaipur                     ... uvcs                        ... vault_1999                  ... vault_2002                  ... vault_2014                  ... virgo                       ... vsm                         ... wbs                         ... wispr                       ... x123                        ... xrs                         ... xrt                         ..., <class 'sunpy.net.attrs.Time'> sunpy.net.attrs.Time  Specify the time range of the query.  Attribute Name    Client   Full Name              Description               -------------- ----------- --------- -------------------------------------- all            NOAAIndices all       All values of this type are supported. all            NOAAPredict all       All values of this type are supported.}#

Methods Documentation

fetch(qres, path=None, overwrite=False, progress=True, downloader=None, wait=True, **kwargs)[source]#

Download a set of results.

Parameters:
  • qres (QueryResponse) – Results to download.

  • path (str or pathlib.Path, optional) – Path to the download directory, or file template including the {file} string which will be replaced with the filename.

  • 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.

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

  • 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:

parfive.Results

post_search_hook(exdict, matchdict)[source]#

Helper function used after search() which makes the extracted metadata representable in a query response table.

Parameters:
  • exdict (dict) – Represents metadata extracted from files.

  • matchdict (dict) – Contains attr values accessed from register_values() and the search query itself.

Returns:

rowdict (OrderedDict) – An Ordered Dictionary which is used by QueryResponse to show results.

classmethod pre_search_hook(*args, **kwargs)[source]#

Helper function to return the baseurl, pattern and matchdict for the client required by search() before using the scraper.

search(*args, **kwargs)[source]#

Query this client for a list of results.

Parameters:
  • *args (tuple) – sunpy.net.attrs objects representing the query.

  • **kwargs (dict) – Any extra keywords to refine the search.

Returns:

A QueryResponse instance containing the query result.