spextra.downloads module#
Utility functions for downloads.
Cache locations are resolved through astar_utils.cache_dir, which knows
about ScopeSim_Data and the shared ~/.astar cache. All pooch-specific code
lives here in spextra, so that astar-utils stays dependency-free.
The pattern throughout is “check trusted local copies first, download only as a last resort”. Trusted local copies live in ScopeSim_Data (if installed) and in the package’s own bundled data (present in a clone / editable install). The home cache below them is managed by pooch for registry files, and written to directly for SVO files.
Registry database#
Via the module-level retriever using known hashes. Use the
fetch_data_file wrapper: it pre-checks the trusted local locations and
otherwise delegates to pooch, which owns the home cache (with hash + update
detection) and downloads from the remote database if needed.
SVO filter curves#
Via download_svo_filter. These have no known hash and are treated as
static: once a copy exists anywhere it is trusted. For now the actual download
uses pooch.retrieve(known_hash=None). This is a candidate to be replaced by
a reusable ecosystem-wide chunked downloader (e.g. niquests-based) later.
- spextra.downloads.download_file(remote_url, local_name)#
For backwards compatibility only.
- spextra.downloads.download_svo_filter(filter_name)#
Query the SVO service for the transmittance of a given filter.
The filter is looked for, in order, in ScopeSim_Data, the package’s bundled data, and the local download cache. Only if it is found nowhere is it downloaded from SVO and stored in the write cache. SVO curves are static, so an existing copy is always trusted.
- Parameters:
- filter_namestr
Name of the filter as available on the Spanish VO filter service, e.g.
"Paranal/HAWKI.Ks".
- Returns:
- wave, trans
Wavelength and transmission columns of the filter curve.
- spextra.downloads.fetch_data_file(filename: str, **kwargs) Path#
Return a registry data file, preferring trusted local copies.
Checks ScopeSim_Data and the package’s bundled data first (committed, trusted locations, returned as-is without re-downloading). Failing that, delegates to pooch, which manages the home download cache – including hash verification and update detection – and downloads from the remote database if the file is missing or stale.
The home cache is deliberately not pre-checked here: it is pooch’s
path, so pooch should own it (henceinclude_home_cache=False).