download_file#

gwpy.io.remote.download_file(
url: str,
*,
cache: bool | None = None,
show_progress: bool = False,
**kwargs,
) str[source]#

Download a file from a URL and optionally cache the result.

This function is a wrapper around astropy.utils.data.download_file with the following customisations:

  • File URLs (file://) and plain paths (without a URL scheme) are returned unmodified without being downloaded or cached.

  • Default to cache=True if the GWPY_CACHE environment variable is set to something ‘truthy’.

  • If the URL looks like a Pelican URL, hand off to a dedicated Pelican download wrapper to attempt the remote access.

Parameters:
urlstr, file-like

The name of the resource to access. Can be a local path, or a file:// URL, or any remote URL supported by Astropy.

cachebool

Whether to cache the contents of remote URLs. Default is True if the GWPY_CACHE environment variable is set to something ‘truthy’.

show_progress: `bool`, optional

Print verbose progress information to the screen.

kwargs

All other positional and keyword arguments are passed directly to astropy.utils.data.get_readable_fileobj.

Returns:
load_pathstr

The local path that the file was downloaded to.

See also

astropy.utils.data.download_file

For details of the underlying downloader.

gwpy.io.pelican.open_remote_file

For details of the Pelican-aware download wrapper.