scopesim.server.example_data_utils module

Store the example data functions here instead of polluting database.py.

scopesim.server.example_data_utils.download_example_data(file_path: Union[Iterable[str], str], save_dir: Optional[Union[Path, str]] = None, url: Optional[str] = None, from_cache: Optional[bool] = None) list[pathlib.Path][source]

Download example fits files to the local disk.

Parameters:
file_pathstr, list

Name(s) of FITS file(s) as given by list_example_data()

save_dirstr

The place on the local disk where the downloaded files are to be saved. If left as None, defaults to the current working directory.

urlstr

The URL of the database HTTP server. If left as None, defaults to the value in scopesim.rc.__config__[“!SIM.file.server_base_url”]

from_cachebool

Use the cached versions of the files. If None, defaults to the RC value: !SIM.file.use_cached_downloads

Returns:
save_pathPath or list of Paths

The absolute path(s) to the saved files

scopesim.server.example_data_utils.get_server_elements(url: str, unique_str: str = '/') list[str][source]

Return a list of file and/or directory paths on the HTTP server url.

Parameters:
urlstr

The URL of the IRDB HTTP server.

unique_strstr, list

A unique string to look for in the beautiful HTML soup: “/” for directories this, “.zip” for packages

Returns:
pathslist

List of paths containing in url which contain unique_str

scopesim.server.example_data_utils.list_example_data(url: Optional[str] = None, return_files: bool = False, silent: bool = False) list[str][source]

List all example files found under url.

Parameters:
urlstr

The URL of the database HTTP server. If left as None, defaults to the value in scopesim.rc.__config__[“!SIM.file.server_base_url”]

return_filesbool

If True, returns a list of file names

silentbool

If True, does not print the list of file names

Returns:
all_fileslist of str

A list of paths to the example files relative to url. The full string should be passed to download_example_data.