open_remote_file#

gwpy.io.pelican.open_remote_file(
url: str,
*,
federation: str | None = None,
cache: bool | Literal['update'] = False,
show_progress: bool = False,
**kwargs,
) AbstractContextManager[BinaryIO][source]#

Download a remote file from a Pelican federation (and open it).

This function is a wrapper around astropy.utils.data.get_readable_fileobj that uses requests-pelican to resolve the actual HTTP(S) URLs and pass those as the sources keyword to get_readable_fileobj().

Also, if the Pelican director informs that an authorisation token is required, this function attempts to an HTTP Authorization header using a locally-discovered SciToken (requires igwn-auth-utils).

Parameters:
urlstr

The name of the resource to access. Must be a Pelican federation URL, either using the pelican:// scheme or a federation scheme understood by requests-pelican (e.g. osdf://), or the federation keyword must be provided.

federation: `str`, optional

The URL of the federation. This is required if url does not include federation information.

cachebool, "update", optional

Whether to cache the contents of remote URLs.

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:
filefile-like

The file opened in binary format.