planetmapper.kernel_downloader

Utility to help downloading spice kernels.

Will download local copy of kernels with same directory structure as on https://naif.jpl.nasa.gov/. Use planetmapper.set_kernel_path() to choose the location that the kernels are downloaded to.

These functions can be used to download a set of URLS. For example:

from planetmapper.kernel_downloader import download_urls

# Download all kernel files in generic_kernels/pck
download_urls('https://naif.jpl.nasa.gov/pub/naif/generic_kernels/pck/')

# Download specific kernel file
download_urls('https://naif.jpl.nasa.gov/pub/naif/generic_kernels/lsk/naif0012.tls')

# Download multiple sets of kernel files
download_urls(
    'https://naif.jpl.nasa.gov/pub/naif/generic_kernels/spk/planets/',
    'https://naif.jpl.nasa.gov/pub/naif/generic_kernels/spk/satellites/',
)
planetmapper.kernel_downloader.download_urls(*urls: str, **kwargs) None[source]

Download data from naif.jpl.nasa.gov and save locally.

urls can either be a the url of a single kernel, or the index page containing multiple kernels.

If a single kernel, download the kernel using download_kernel().

If an index page, download all first-level files using download_kernels_from_webpage().

Parameters:
planetmapper.kernel_downloader.download_kernels_from_webpage(index_url: str, **kwargs) None[source]

Download all first-level kernels listed in the page given by index_url.

URL must be on https://naif.jpl.nasa.gov/pub/. This will break if JPL changes the format of the webpage.

Warning

This function will only download kernels found immediately on index_url. Kernels in nested folders must therefore be downloaded manually.

Parameters:
  • index_url – URL of index page on naif.jpl.nasa.gov.

  • **kwargs – passed to download_kernel().

planetmapper.kernel_downloader.download_kernel(url: str, force_download: bool = False, note: str = '') None[source]

Download single kernel given by url.

URL must be on https://naif.jpl.nasa.gov/pub/. By default will only download file if if does not already exist locally. Set force_download=True to override this check and download the file even if it already exists locally.

Parameters:
  • url – URL of kernel on naif.jpl.nasa.gov.

  • force_download – toggle overwriting already downloaded kernels.

  • note – string to include in progress message.

planetmapper.kernel_downloader.get_kernel_paths_from_webpage(index_url: str) list[str][source]

Get list of kernel urls from an index page on https://naif.jpl.nasa.gov/pub/.

This is a bit of a hack and will break if JPL changes the format of the webpage.

Parameters:

index_url – URL of webpage.

Returns:

List of URL strings corresponding to kernels on the webpage.

planetmapper.kernel_downloader.download_file(url: str, local_path: str) None[source]

Download kernel file to local system.

Parameters:
  • url – URL of kernel file.

  • local_path – File path to save kernel file on local system.