How-To SPICE: Get archived kernels

This is a brief How-To on using the planetarypy.spice.archived_kernels module to download a SPICE kernels set for a specific mission and time range.

For a longer tutorial that explains more about what happens, go to the tutorials section of the docs.

from planetarypy.spice.archived_kernels import (
    datasets,
    get_metakernel_and_files,
)
import spiceypy as spice

The mission datasets

The datasets object is a dataframe that lists all supported missions and time ranges. It also links to the README for the given kernel set.

datasets.head()
Mission Name Archive Readme Archive Link PDS3 or PDS4 Data Size (GB) Start Time Stop Time Subset Link
shorthand
bc BepiColombo https://naif.jpl.nasa.gov/pub/naif/pds/pds4/bc... https://naif.jpl.nasa.gov/pub/naif/pds/pds4/bc... 4 4.5 2018-10-20 2025-05-31 https://naif.jpl.nasa.gov/cgi-bin/subsetds.pl?...
clps CLPS https://naif.jpl.nasa.gov/pub/naif/pds/pds4/cl... https://naif.jpl.nasa.gov/pub/naif/pds/pds4/cl... 4 0.2 2024-01-08 2024-02-22 https://naif.jpl.nasa.gov/cgi-bin/subsetds.pl?...
cassini Cassini Orbiter https://naif.jpl.nasa.gov/pub/naif/pds/data/co... https://naif.jpl.nasa.gov/pub/naif/pds/data/co... 3 73.5 1997-10-15 2017-09-15 https://naif.jpl.nasa.gov/cgi-bin/subsetds.pl?...
clementine Clementine https://naif.jpl.nasa.gov/pub/naif/pds/data/cl... https://naif.jpl.nasa.gov/pub/naif/pds/data/cl... 3 0.8 1994-01-26 1994-05-07 https://naif.jpl.nasa.gov/cgi-bin/subsetds.pl?...
dart DART https://naif.jpl.nasa.gov/pub/naif/pds/pds4/da... https://naif.jpl.nasa.gov/pub/naif/pds/pds4/da... 4 10.1 2021-11-09 2050-01-01 https://naif.jpl.nasa.gov/cgi-bin/subsetds.pl?...

Use theshorthands index or the “Mission Name” to get the mission data of your interest:

datasets.loc["cassini"]
Mission Name                                        Cassini Orbiter
Archive Readme    https://naif.jpl.nasa.gov/pub/naif/pds/data/co...
Archive Link      https://naif.jpl.nasa.gov/pub/naif/pds/data/co...
PDS3 or PDS4                                                      3
Data Size (GB)                                                 73.5
Start Time                                               1997-10-15
Stop Time                                                2017-09-15
Subset Link       https://naif.jpl.nasa.gov/cgi-bin/subsetds.pl?...
Name: cassini, dtype: object

Supported missions

Look at the index to get the list of all supported missions:

datasets.index
Index(['bc', 'clps', 'cassini', 'clementine', 'dart', 'dawn', 'di', 'ds1',
       'epoxi', 'em16', 'grail', 'hayabusa', 'hayabusa2', 'insight', 'juno',
       'ladee', 'lucy', 'lro', 'maven', 'opportunity', 'mer1', 'spirit',
       'mer2', 'messenger', 'mars2020', 'mex', 'mgs', 'ody', 'mro', 'msl',
       'near', 'nh', 'orex', 'psyche', 'rosetta', 'stardust',
       'venus_climate_orbiter', 'vex', 'vo'],
      dtype='object', name='shorthand')

Retrieve kernels and metakernel

The clue of this function is, that it will download and store the kernels at intelligent locations within the planetarypy.storage_root/spice_kernels directory. Once the download is finished, it will edit the metakernel file from NAIF for the local storage paths and return the path to the metakernel to the user.

get_metakernel_and_files?
Signature:

get_metakernel_and_files(

    mission: str,

    start: str,

    stop: str,

    save_location: str = None,

    quiet: bool = False,

) -> str

Docstring:

For a given mission and start/stop times, download the kernels and get metakernel path.



Parameters

----------

mission : str

    Mission shorthand in datasets dataframe.

start : str

    Start time in either ISO or yyyy-jjj format.

stop : str

    Stop time in either ISO or yyyy-jjj format.

save_location : str, optional

    Overwrite default storing in planetarypy archive. Defaults to None.

quiet : bool, optional

    Suppress download feedback. Defaults to False.

File:      ~/Dropbox/src/planetarypy/src/planetarypy/spice/archived_kernels.py

Type:      function
path = get_metakernel_and_files("cassini", "2015-01-01", "2015-01-02")
path
'/Users/maye/planetarypy_data/spice_kernels/cassini/cas_2015_v09_150101_150102.tm'
!tail {path}
                         '$KERNELS/ck/14351_15052py_as_flown.bc'
                         '$KERNELS/ck/14363_15003ra.bc'
                         '$KERNELS/ck/cas_cda_20170627.bc'
                         '$KERNELS/ck/cas_lemms_05109_20001_v2.bc'
                         '$KERNELS/dsk/cas_enceladus_ssd_spc_0128icq_v1.bds'
                        )
 
   \begintext
 

Load the returned path directly into spice.furnsh:

spice.furnsh(str(path))