scopesim.server.database module

Functions to download instrument packages and example data

scopesim.server.database.create_github_url(url)[source]

From the given url, produce a URL that is compatible with Github’s REST API. Can handle blob or tree paths.

scopesim.server.database.download_example_data(file_path, save_dir=None, url=None, from_cache=None)[source]

Downloads 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_pathstr

The absolute path to the saved files

scopesim.server.database.download_github_folder(repo_url, output_dir='./')[source]

Downloads the files and directories in repo_url.

Re-written based on the on the download function here

scopesim.server.database.download_package(pkg_path, save_dir=None, url=None, from_cache=None)[source]

Downloads a package to the local disk

Parameters:
pkg_pathstr, list

A .zip package path as given by list_packages()

save_dirstr

The place on the local disk where the .zip package is to be saved. If left as None, defaults to the value in scopesim.rc.__config__[“!SIM.file.local_packages_path”]

urlstr

The URL of the IRDB 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 packages. If None, defaults to the RC value: !SIM.file.use_cached_downloads

Returns:
save_pathstr

The absolute path to the saved .zip package

scopesim.server.database.download_packages(pkg_names, release='stable', save_dir=None, from_cache=None)[source]

Download one or more packages to the local disk

  1. Download stable, dev

  2. Download specific version

  3. Download from github via url

Parameters:
pkg_namesstr, list

A list of package names, see list_packages()

releasestr, optional

By default, the most recent stable version of a package is downloaded. Other options are: - “stable” : the most recent stable version - “latest” : the latest development version to be published - a specific package filename as given by list_packages (see examples) - a github url for the specific branch and package (see examples)

save_dirstr, optional

The place on the local disk where the .zip package is to be saved. If left as None, defaults to the value in scopesim.rc.__config__[“!SIM.file.local_packages_path”]

from_cachebool, optional

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

Returns:
save_pathstr

The absolute path to the saved .zip package

Examples

::

from scopesim import download_packages, list_packages

# Stable release of a list of packages download_packages([“test_package”, “test_package”])

# Development release of a single package download_packages(“test_package”, release=”latest”)

# Specific version of the package list_packages(“test_package”) download_packages(“test_package”, release=”2022-04-09.dev”)

# Specific package from a Gtihub commit hash or branch/tag name (use “@” or “:”) download_packages(“ELT”, release=”github:728761fc76adb548696205139e4e9a4260401dfc”) download_packages(“ELT”, release=”github@728761fc76adb548696205139e4e9a4260401dfc”) download_packages(“ELT”, release=”github@dev_master”)

scopesim.server.database.get_server_elements(url, unique_str='/')[source]

Returns 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.database.get_server_folder_contents(dir_name, unique_str='.zip')[source]
scopesim.server.database.get_server_package_list()[source]
scopesim.server.database.list_example_data(url=None, return_files=False, silent=False)[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.

scopesim.server.database.list_packages(pkg_name=None)[source]

List all packages, or all variants of a single package

Parameters:
pkg_namestr, optional
  • None: lists all stable packages on the server

  • <PackageName>: lists all variants of <PackageName> on the server

Returns:
pkg_nameslist

Examples

::

from scopesim import list_packages

# list all stable packages on the server list_packages()

# list all variants of a specific package list_packages(“Armazones”)