download_uri_to_path#
- jdaviz.utils.download_uri_to_path(possible_uri, cache=None, local_path='.', timeout=None, dryrun=False)[source]#
Retrieve data from a URI (or a URL). Return the input if it cannot be parsed as a URI.
If
possible_uri
is a MAST URI, the file will be retrieved via astroquery’sdownload_file
. Ifpossible_uri
is a URL, it will be retrieved via astropy withdownload_file
.- Parameters:
- possible_uristr or other
This input will be returned without changes if it is not a string, or if it is a local file path to an existing file. Otherwise, it will be parsed as a URI. Local file URIs beginning with
file://
are not supported by this method – nor are they necessary, since string paths without the scheme work fine! Cloud FITS are not yet supported.- cache: None, bool, or ``”update”``, optional
Cache file after download. If
possible_uri
is a URL,cache
may be a boolean or"update"
, see documentation fordownload_file
for details. If cache is None, the file is cached and a warning is raised suggesting to setcache
explicitly in the future.- local_pathstr, optional
Save the downloaded file to this path. Default is to save the file with its remote filename in the current working directory. This is only used if data is requested from
astroquery.mast
.- timeoutfloat, optional
If downloading from a remote URI, set the timeout limit for remote requests in seconds (passed to
download_file
ortimeout
).- dryrunbool
Set to
True
to skip downloading data from MAST. This is only used for debugging.
- Returns:
- possible_uristr or other
If
possible_uri
cannot be retrieved as a URI, returns the input argument unchanged. Ifpossible_uri
can be retrieved as a URI, returns the local path to the downloaded file.