Retrieves a data file from the standard locations for the package and provides a local filename for the data.
This function is similar to get_pkg_data_fileobj but returns the file name instead of a readable file-like object. This means that this function must always cache remote files locally, unlike get_pkg_data_fileobj.
Parameters: | data_name : str
show_progress : bool, optional
remote_timeout : float
|
---|---|
Returns: | filename : str
|
Raises: | urllib2.URLError, urllib.error.URLError
IOError
|
See also
Examples
This will retrieve the contents of the data file for the astropy.wcs tests:
from astropy.utils.data import get_pkg_data_filename
fn = get_pkg_data_filename('data/3d_cd.hdr')
with open(fn) as f:
fcontents = f.read()
This retrieves a data file by hash either locally or from the astropy data server:
from astropy.utils.data import get_pkg_data_filename
fn = get_pkg_data_filename('hash/da34a7b07ef153eede67387bf950bb32')
with open(fn) as f:
fcontents = f.read()