punchbowl.data.sample#

Module for downloading sample data files.

This module provides the following sample data files. When a sample shortname is accessed, the corresponding file is downloaded if needed. All files can be downloaded by calling download_all().

Code adapted from SunPy.

Attributes#

Functions#

get_and_create_sample_dir(→ pathlib.Path)

Get the config of download directory and create one if not present.

_download_sample_data(→ parfive.Results)

Download a list of files.

_retry_sample_data(→ parfive.Results)

Retry failed downloads.

_handle_final_errors(→ None)

_get_sampledata_dir(→ pathlib.Path)

_get_sample_files(→ list[pathlib.Path])

Return a list of disk locations for a list of sample data filenames, downloading sample data files as needed.

__dir__()

__getattr__(name)

download_all(→ list[pathlib.Path])

Download all sample data at once that has not already been downloaded.

Module Contents#

punchbowl.data.sample._BASE_URLS = 'https://data.boulder.swri.edu/lowder/PUNCH/sample/'#
punchbowl.data.sample._SAMPLE_DATA#
punchbowl.data.sample._SAMPLE_FILES#
punchbowl.data.sample.get_and_create_sample_dir() pathlib.Path#

Get the config of download directory and create one if not present.

punchbowl.data.sample._download_sample_data(base_url: str, sample_files: list, overwrite: bool) parfive.Results#

Download a list of files.

Parameters:
  • base_url (str) – Base URL for each file.

  • sample_files (list of tuples) – List of tuples that are (URL_NAME, SAVE_NAME).

  • overwrite (bool) – Will overwrite a file on disk if True.

Returns:

Download results. Will behave like a list of files.

Return type:

parfive.Results

punchbowl.data.sample._retry_sample_data(results: parfive.Results, new_url_base: str) parfive.Results#

Retry failed downloads.

Parameters:
  • results (parfive.Results) – Download results.

  • new_url_base (str) – Base URL for each file.

Returns:

Download results. Will behave like a list of files.

Return type:

parfive

punchbowl.data.sample._handle_final_errors(results: parfive.Results) None#
punchbowl.data.sample._get_sampledata_dir() pathlib.Path#
punchbowl.data.sample._get_sample_files(filename_list: list, no_download: bool = False, force_download: bool = False) list[pathlib.Path]#

Return a list of disk locations for a list of sample data filenames, downloading sample data files as needed.

Parameters:
  • filename_list (list of str) – List of filenames for sample data

  • no_download (bool) – If True, do not download any files, even if they are not present. Default is False.

  • force_download (bool) – If True, download all files, and overwrite any existing ones. Default is False.

Returns:

List of disk locations corresponding to the list of filenames. An entry will be None if no_download == True and the file is not present.

Return type:

list of pathlib.Path

Raises:

RuntimeError – Raised if any of the files cannot be downloaded from any of the mirrors.

punchbowl.data.sample.__all__#
punchbowl.data.sample.__dir__()#
punchbowl.data.sample.__getattr__(name)#
punchbowl.data.sample.download_all(force_download: bool = False) list[pathlib.Path]#

Download all sample data at once that has not already been downloaded.

Parameters:

force_download (bool) – If True, files are downloaded even if they already exist. Default is False.

Returns:

List of filepaths for sample data

Return type:

list of pathlib.Path