SPICE Kernels

Tools to manage SPICE kernels

Intro

Feature list for this module:

  • Receive the list of supported datasets for automatic retrieval of archived SPICE kernels
    • The supported datasets are tabled here at NAIF: https://naif.jpl.nasa.gov/naif/data_archived.html
  • Receive the list of required SPICE kernels for a given mission and time range
  • Automatic download of kernels for a given mission and time range either into a given location or the planetarypy local archive.

As always in planetarypy the general design philosophy is to first develop a management class to give the user full control over all the details, and then add easy-to-use function for the end-user that do the most frequently used things in one go. (See section “User Functions”)

Identifying and downloading kernel sets

One repeating task for SPICE calculations is the identification and retrieval of all SPICE kernels for a mission for a given time interval.

The folks at NAIF offer a “Subset” feature at their servers. Here we set up a table of the currently supported datasets:

datasets
path Mission Name PDS3 or PDS4 Data Size (GB) Start Time Stop Time
shorthand
bc bc/bc_spice BepiColombo 4 1.1 2018-10-20 2023-01-01
cassini co-s_j_e_v-spice-6-v1.0/cosp_1000 Cassini Orbiter 3 62.5 1997-10-15 2017-09-15
clementine clem1-l-spice-6-v1.0/clsp_1000 Clementine 3 0.8 1994-01-26 1994-05-07
dart dart/dart_spice DART 4 9.1 2021-11-09 2050-01-01
dawn dawn-m_a-spice-6-v1.0/dawnsp_1000 DAWN 3 86.4 2007-09-27 2018-10-31
di di-c-spice-6-v1.0/disp_1000 Deep Impact 3 0.7 2005-01-12 2005-08-09
ds1 ds1-a_c-spice-6-v1.0/ds1sp_1000 Deep Space 1 3 0.9 1998-10-24 2001-12-18
epoxi dif-c_e_x-spice-6-v1.0/epxsp_1000 EPOXI 3 1.0 2005-08-23 2011-03-01
em16 em16/em16_spice ExoMars TGO 2016 4 9.4 2016-03-14 2023-01-01
grail grail-l-spice-6-v1.0/grlsp_1000 GRAIL 3 4.3 2011-09-10 2012-12-17
hayabusa hay-a-spice-6-v1.0/haysp_1000 Hayabusa 3 0.3 2005-09-11 2005-11-19
insight insight/insight_spice InSight 4 0.9 2018-05-05 2022-12-15
juno jno-j_e_ss-spice-6-v1.0/jnosp_1000 JUNO 3 46.9 2011-08-05 2022-08-17
ladee ladee/ladee_spice LADEE 4 0.6 2013-09-07 2050-01-01
lro lro-l-spice-6-v1.0/lrosp_1000 Lunar Reconnaissance Orbiter 3 595.7 2009-06-18 2023-03-15
maven maven/maven_spice MAVEN 4 54.4 2013-11-18 2023-04-01
opportunity mer1-m-spice-6-v1.0/mer1sp_1000 MER 1 (Opportunity) 3 4.1 2003-07-07 2018-06-10
spirit mer2-m-spice-6-v1.0/mer2sp_1000 MER 2 (Spirit) 3 2.6 2003-06-10 2010-05-03
messenger mess-e_v_h-spice-6-v1.0/messsp_1000 MESSENGER 3 44.8 2004-08-03 2015-04-30
mars2020 mars2020/mars2020_spice Mars 2020 4 0.6 2020-07-30 2022-12-28
mex mex-e_m-spice-6-v2.0/mexsp_2000 Mars Express 3 8.5 2003-06-02 2022-11-30
mgs mgs-m-spice-6-v1.0/mgsp_1000 Mars Global Surveyor 3 15.4 1996-11-06 2006-11-02
ody ody-m-spice-6-v1.0/odsp_1000 Mars Odyssey 3 33.2 2001-04-07 2022-10-01
mro mro-m-spice-6-v1.0/mrosp_1000 Mars Reconnaissance Orbiter 3 314.9 2005-08-12 2023-04-01
msl msl-m-spice-6-v1.0/mslsp_1000 Mars Science Laboratory 3 0.6 2011-11-26 2022-11-06
near near-a-spice-6-v1.0/nearsp_1000 NEAR 3 2.4 1996-05-30 2001-02-28
nh nh-j_p_ss-spice-6-v1.0/nhsp_1000 New Horizons 3 1.6 2006-01-19 2019-12-30
orex orex/orex_spice OSIRIS-REx 4 418.4 2016-09-08 2021-02-22
rosetta ro_rl-e_m_a_c-spice-6-v1.0/rossp_1000 Rosetta 3 5.9 2004-03-02 2017-01-01
stardust sdu-c-spice-6-v1.0/sdsp_1000 Stardust 3 1.9 1999-02-07 2011-05-01
venus_climate_orbiter vco/vco_spice Venus Climate Orbiter 4 1.7 2010-05-21 2022-01-01
vex vex-e_v-spice-6-v2.0/vexsp_2000 Venus Express 3 5.0 2005-11-09 2015-02-06
vo vo1_vo2-m-spice-6-v1.0/vosp_1000 Viking Orbiter 3 0.1 1976-06-16 1980-07-30

To receive this dataframe:

from planetarypy.spice.kernels import datasets

Some validation helpers:


source

is_stop_valid

 is_stop_valid (mission:str, stop:astropy.time.core.Time)
Type Details
mission str mission shorthand label of datasets dataframe
stop Time stop time in astropy.Time format

source

is_start_valid

 is_start_valid (mission:str, start:astropy.time.core.Time)
Type Details
mission str mission shorthand label of datasets dataframe
start Time start time in astropy.Time format
assert is_start_valid("cassini", Time("1998-01-01")) is True
assert is_start_valid("cassini", Time("1997-01-01")) is False
assert is_stop_valid("cassini", "2017-01-01") is True
assert is_stop_valid("cassini", "2018-01-01") is False

Now we build a management class for wrapping the Perl script available at below’s URL for accessing subsets of these datasets.

First, the basic URLs we will use:

The Perl script subsetds.pl (the name at the end of the BASE_URL) requires as input:

  • the dataset name
  • start and stop of the time interval
  • a constant named “Subset” to identify the action for this Perl script

We can assemble these parameters into a payload dictionary for the requests.get call and we manage different potential actions on the zipfile with a Subsetter class, that only requires the mission identifier, start and stop as parameters.

/home/runner/micromamba/envs/my-env/lib/python3.12/site-packages/fastcore/docscrape.py:225: UserWarning: Unknown section Attributes
  else: warn(msg)

source

Subsetter

 Subsetter (mission:str, start:str, stop=None, save_location=None)

Class to manage retrieving subset SPICE kernel lists

Type Default Details
mission str mission shorthand in datasets dataframe
start str start time in either ISO or yyyy-jjj format
stop NoneType None stop time in either ISO or yyyy-jjj format
save_location NoneType None overwrite default storing in planetarpy archive

source

download_one_url

 download_one_url (url, local_path, overwrite:bool=False)
subset = Subsetter("cassini", "2014-270")
subset.kernel_names
['ck/14001_15001pa_gapfill_v14.bc',
 'ck/14212_14279py_as_flown.bc',
 'ck/14268_14273ra.bc',
 'ck/cas_cda_20150318.bc',
 'ck/cas_lemms_05109_20001_v2.bc',
 'fk/cas_dyn_v03.tf',
 'fk/cas_mimi_v202.tf',
 'fk/cas_rocks_v18.tf',
 'fk/cas_v41.tf',
 'ik/cas_caps_v03.ti',
 'ik/cas_cda_v01.ti',
 'ik/cas_cirs_v09.ti',
 'ik/cas_inms_v02.ti',
 'ik/cas_iss_v10.ti',
 'ik/cas_mag_v01.ti',
 'ik/cas_mimi_v11.ti',
 'ik/cas_radar_v11.ti',
 'ik/cas_rpws_v01.ti',
 'ik/cas_rss_v03.ti',
 'ik/cas_sru_v02.ti',
 'ik/cas_uvis_v06.ti',
 'ik/cas_vims_v06.ti',
 'lsk/naif0012.tls',
 'pck/pck00010.tpc',
 'sclk/cas00172.tsc',
 'spk/140809BP_IRRE_00256_25017.bsp',
 'spk/150122R_SCPSE_14251_14283.bsp',
 'spk/180927AP_RE_90165_18018.bsp']
# this should fail:
def _failing():
    Subsetter("cassini", "2019-01-01")


test_fail(_failing, contains="start/stop")
subset = Subsetter("cassini", "2011-02-13", "2011-02-14")
subset.urls_file
'urls_cosp_1000_110213_110214.txt'
subset.metakernel_file
'cas_2011_v17_110213_110214.tm'

source

Subsetter.kernel_names

 Subsetter.kernel_names ()

Return list of names of kernels for the given time range.

subset.kernel_names
['ck/11001_12001pa_gapfill_v14.bc',
 'ck/11017_11066py_as_flown.bc',
 'ck/11044_11049ra.bc',
 'ck/cas_cda_20120517.bc',
 'ck/cas_lemms_05109_20001_v2.bc',
 'fk/cas_dyn_v03.tf',
 'fk/cas_mimi_v202.tf',
 'fk/cas_rocks_v18.tf',
 'fk/cas_v41.tf',
 'ik/cas_caps_v03.ti',
 'ik/cas_cda_v01.ti',
 'ik/cas_cirs_v09.ti',
 'ik/cas_inms_v02.ti',
 'ik/cas_iss_v10.ti',
 'ik/cas_mag_v01.ti',
 'ik/cas_mimi_v11.ti',
 'ik/cas_radar_v11.ti',
 'ik/cas_rpws_v01.ti',
 'ik/cas_rss_v03.ti',
 'ik/cas_sru_v02.ti',
 'ik/cas_uvis_v06.ti',
 'ik/cas_vims_v06.ti',
 'lsk/naif0012.tls',
 'pck/pck00010.tpc',
 'sclk/cas00172.tsc',
 'spk/110504R_SCPSE_11041_11093.bsp',
 'spk/140809BP_IRRE_00256_25017.bsp',
 'spk/180927AP_RE_90165_18018.bsp']
subset.kernel_urls
['https://naif.jpl.nasa.gov/pub/naif/pds/data/co-s_j_e_v-spice-6-v1.0/cosp_1000/data/ck/11001_12001pa_gapfill_v14.bc',
 'https://naif.jpl.nasa.gov/pub/naif/pds/data/co-s_j_e_v-spice-6-v1.0/cosp_1000/data/ck/11017_11066py_as_flown.bc',
 'https://naif.jpl.nasa.gov/pub/naif/pds/data/co-s_j_e_v-spice-6-v1.0/cosp_1000/data/ck/11044_11049ra.bc',
 'https://naif.jpl.nasa.gov/pub/naif/pds/data/co-s_j_e_v-spice-6-v1.0/cosp_1000/data/ck/cas_cda_20120517.bc',
 'https://naif.jpl.nasa.gov/pub/naif/pds/data/co-s_j_e_v-spice-6-v1.0/cosp_1000/data/ck/cas_lemms_05109_20001_v2.bc',
 'https://naif.jpl.nasa.gov/pub/naif/pds/data/co-s_j_e_v-spice-6-v1.0/cosp_1000/data/fk/cas_dyn_v03.tf',
 'https://naif.jpl.nasa.gov/pub/naif/pds/data/co-s_j_e_v-spice-6-v1.0/cosp_1000/data/fk/cas_mimi_v202.tf',
 'https://naif.jpl.nasa.gov/pub/naif/pds/data/co-s_j_e_v-spice-6-v1.0/cosp_1000/data/fk/cas_rocks_v18.tf',
 'https://naif.jpl.nasa.gov/pub/naif/pds/data/co-s_j_e_v-spice-6-v1.0/cosp_1000/data/fk/cas_v41.tf',
 'https://naif.jpl.nasa.gov/pub/naif/pds/data/co-s_j_e_v-spice-6-v1.0/cosp_1000/data/ik/cas_caps_v03.ti',
 'https://naif.jpl.nasa.gov/pub/naif/pds/data/co-s_j_e_v-spice-6-v1.0/cosp_1000/data/ik/cas_cda_v01.ti',
 'https://naif.jpl.nasa.gov/pub/naif/pds/data/co-s_j_e_v-spice-6-v1.0/cosp_1000/data/ik/cas_cirs_v09.ti',
 'https://naif.jpl.nasa.gov/pub/naif/pds/data/co-s_j_e_v-spice-6-v1.0/cosp_1000/data/ik/cas_inms_v02.ti',
 'https://naif.jpl.nasa.gov/pub/naif/pds/data/co-s_j_e_v-spice-6-v1.0/cosp_1000/data/ik/cas_iss_v10.ti',
 'https://naif.jpl.nasa.gov/pub/naif/pds/data/co-s_j_e_v-spice-6-v1.0/cosp_1000/data/ik/cas_mag_v01.ti',
 'https://naif.jpl.nasa.gov/pub/naif/pds/data/co-s_j_e_v-spice-6-v1.0/cosp_1000/data/ik/cas_mimi_v11.ti',
 'https://naif.jpl.nasa.gov/pub/naif/pds/data/co-s_j_e_v-spice-6-v1.0/cosp_1000/data/ik/cas_radar_v11.ti',
 'https://naif.jpl.nasa.gov/pub/naif/pds/data/co-s_j_e_v-spice-6-v1.0/cosp_1000/data/ik/cas_rpws_v01.ti',
 'https://naif.jpl.nasa.gov/pub/naif/pds/data/co-s_j_e_v-spice-6-v1.0/cosp_1000/data/ik/cas_rss_v03.ti',
 'https://naif.jpl.nasa.gov/pub/naif/pds/data/co-s_j_e_v-spice-6-v1.0/cosp_1000/data/ik/cas_sru_v02.ti',
 'https://naif.jpl.nasa.gov/pub/naif/pds/data/co-s_j_e_v-spice-6-v1.0/cosp_1000/data/ik/cas_uvis_v06.ti',
 'https://naif.jpl.nasa.gov/pub/naif/pds/data/co-s_j_e_v-spice-6-v1.0/cosp_1000/data/ik/cas_vims_v06.ti',
 'https://naif.jpl.nasa.gov/pub/naif/pds/data/co-s_j_e_v-spice-6-v1.0/cosp_1000/data/lsk/naif0012.tls',
 'https://naif.jpl.nasa.gov/pub/naif/pds/data/co-s_j_e_v-spice-6-v1.0/cosp_1000/data/pck/pck00010.tpc',
 'https://naif.jpl.nasa.gov/pub/naif/pds/data/co-s_j_e_v-spice-6-v1.0/cosp_1000/data/sclk/cas00172.tsc',
 'https://naif.jpl.nasa.gov/pub/naif/pds/data/co-s_j_e_v-spice-6-v1.0/cosp_1000/data/spk/110504R_SCPSE_11041_11093.bsp',
 'https://naif.jpl.nasa.gov/pub/naif/pds/data/co-s_j_e_v-spice-6-v1.0/cosp_1000/data/spk/140809BP_IRRE_00256_25017.bsp',
 'https://naif.jpl.nasa.gov/pub/naif/pds/data/co-s_j_e_v-spice-6-v1.0/cosp_1000/data/spk/180927AP_RE_90165_18018.bsp']

source

Subsetter.get_local_path

 Subsetter.get_local_path (url)

*Calculate local storage path from Kernel URL, using save_location if given.

If self.save_location is None, the planetarypy archive is being used.*

Type Details
url kernel url to determine local storage path
Returns Path full local path where kernel in URL will be stored
subset.get_local_path(subset.kernel_urls[0])
Path('/home/ayek72/mnt/slowdata/planetarypy/spice_kernels/cassini/ck/11001_12001pa_gapfill_v14.bc')
subset.save_location = Path(".")
subset.get_local_path(subset.kernel_urls[0])
Path('ck/11001_12001pa_gapfill_v14.bc')

source

Subsetter.download_kernels

 Subsetter.download_kernels (overwrite:bool=False,
                             non_blocking:bool=False, quiet:bool=False)
Type Default Details
overwrite bool False switch to control if kernels should be downloaded over existing ones
non_blocking bool False
quiet bool False
# reset save_location to prevent additional download
subset.save_location = None
subset.download_kernels()
ck 11001_12001pa_gapfill_v14.bc locally available.
ck 11017_11066py_as_flown.bc locally available.
ck 11044_11049ra.bc locally available.
ck cas_cda_20120517.bc locally available.
ck cas_lemms_05109_20001_v2.bc locally available.
fk cas_dyn_v03.tf locally available.
fk cas_mimi_v202.tf locally available.
fk cas_rocks_v18.tf locally available.
fk cas_v41.tf locally available.
ik cas_caps_v03.ti locally available.
ik cas_cda_v01.ti locally available.
ik cas_cirs_v09.ti locally available.
ik cas_inms_v02.ti locally available.
ik cas_iss_v10.ti locally available.
ik cas_mag_v01.ti locally available.
ik cas_mimi_v11.ti locally available.
ik cas_radar_v11.ti locally available.
ik cas_rpws_v01.ti locally available.
ik cas_rss_v03.ti locally available.
ik cas_sru_v02.ti locally available.
ik cas_uvis_v06.ti locally available.
ik cas_vims_v06.ti locally available.
lsk naif0012.tls locally available.
pck pck00010.tpc locally available.
sclk cas00172.tsc locally available.
spk 110504R_SCPSE_11041_11093.bsp locally available.
spk 140809BP_IRRE_00256_25017.bsp locally available.
spk 180927AP_RE_90165_18018.bsp locally available.
subset.download_kernels(non_blocking=True)
ck 11001_12001pa_gapfill_v14.bc locally available.
ck 11017_11066py_as_flown.bc locally available.
ck 11044_11049ra.bc locally available.
ck cas_cda_20120517.bc locally available.
ck cas_lemms_05109_20001_v2.bc locally available.
fk cas_dyn_v03.tf locally available.
fk cas_mimi_v202.tf locally available.
fk cas_rocks_v18.tf locally available.
fk cas_v41.tf locally available.
ik cas_caps_v03.ti locally available.
ik cas_cda_v01.ti locally available.
ik cas_cirs_v09.ti locally available.
ik cas_inms_v02.ti locally available.
ik cas_iss_v10.ti locally available.
ik cas_mag_v01.ti locally available.
ik cas_mimi_v11.ti locally available.
ik cas_radar_v11.ti locally available.
ik cas_rpws_v01.ti locally available.
ik cas_rss_v03.ti locally available.
ik cas_sru_v02.ti locally available.
ik cas_uvis_v06.ti locally available.
ik cas_vims_v06.ti locally available.
lsk naif0012.tls locally available.
pck pck00010.tpc locally available.
sclk cas00172.tsc locally available.
spk 110504R_SCPSE_11041_11093.bsp locally available.
spk 140809BP_IRRE_00256_25017.bsp locally available.
spk 180927AP_RE_90165_18018.bsp locally available.
[]

source

Subsetter.get_metakernel

 Subsetter.get_metakernel ()

*Get metakernel file from NAIF and adapt path to match local storage.

Use save_location if given, otherwise planetarypy archive.*

mkpath = subset.get_metakernel()
mkpath
Path('/home/ayek72/mnt/slowdata/planetarypy/spice_kernels/cassini/cas_2011_v17_110213_110214.tm')
!cat {mkpath}
KPL/MK

   This meta-kernel lists a subset of kernels from the meta-kernel
   cas_2011_v17.tm provided in the CO-S/J/E/V-SPICE-6-V1.0 SPICE PDS3 archive,
   covering the whole or a part of the customer requested time period
   from 2011-02-13T00:00:00.000 to 2011-02-14T00:00:00.000.

   The documentation describing these kernels can be found in the
   complete CO-S/J/E/V-SPICE-6-V1.0 SPICE PDS3 archive available at this URL

   https://naif.jpl.nasa.gov/pub/naif/pds/data/co-s_j_e_v-spice-6-v1.0/cosp_1000

   To use this meta-kernel users may need to modify the value of the
   PATH_VALUES keyword to point to the actual location of the archive's
   ``data'' directory on their system. Replacing ``/'' with ``\''
   and converting line terminators to the format native to the user's
   system may also be required if this meta-kernel is to be used on a
   non-UNIX workstation.

   This meta-kernel was created by the NAIF node's SPICE PDS archive
   subsetting service version 2.1 on Mon Jun 19 08:13:34 PDT 2023.

 
   \begindata
 
      PATH_VALUES     = (
                         '/home/ayek72/mnt/slowdata/planetarypy/spice_kernels/cassini'
                        )
 
      PATH_SYMBOLS    = (
                         'KERNELS'
                        )
 
      KERNELS_TO_LOAD = (
                         '$KERNELS/lsk/naif0012.tls'
                         '$KERNELS/pck/pck00010.tpc'
                         '$KERNELS/fk/cas_rocks_v18.tf'
                         '$KERNELS/fk/cas_mimi_v202.tf'
                         '$KERNELS/fk/cas_dyn_v03.tf'
                         '$KERNELS/fk/cas_v41.tf'
                         '$KERNELS/ik/cas_caps_v03.ti'
                         '$KERNELS/ik/cas_cda_v01.ti'
                         '$KERNELS/ik/cas_cirs_v09.ti'
                         '$KERNELS/ik/cas_inms_v02.ti'
                         '$KERNELS/ik/cas_iss_v10.ti'
                         '$KERNELS/ik/cas_mag_v01.ti'
                         '$KERNELS/ik/cas_mimi_v11.ti'
                         '$KERNELS/ik/cas_radar_v11.ti'
                         '$KERNELS/ik/cas_rpws_v01.ti'
                         '$KERNELS/ik/cas_rss_v03.ti'
                         '$KERNELS/ik/cas_sru_v02.ti'
                         '$KERNELS/ik/cas_uvis_v06.ti'
                         '$KERNELS/ik/cas_vims_v06.ti'
                         '$KERNELS/sclk/cas00172.tsc'
                         '$KERNELS/spk/180927AP_RE_90165_18018.bsp'
                         '$KERNELS/spk/140809BP_IRRE_00256_25017.bsp'
                         '$KERNELS/spk/110504R_SCPSE_11041_11093.bsp'
                         '$KERNELS/ck/11001_12001pa_gapfill_v14.bc'
                         '$KERNELS/ck/11017_11066py_as_flown.bc'
                         '$KERNELS/ck/11044_11049ra.bc'
                         '$KERNELS/ck/cas_cda_20120517.bc'
                         '$KERNELS/ck/cas_lemms_05109_20001_v2.bc'
                        )
 
   \begintext
 

Loading the metakernel works! :

spice.furnsh(str(mkpath))

Or, with given save_location:

subset.save_location = Path(".")
mkpath = subset.get_metakernel()
mkpath
Path('cas_2011_v17_110213_110214.tm')

The metakernel is correctly adapted, however for these tests, I didn’t download the kernels again

!cat {mkpath}
KPL/MK

   This meta-kernel lists a subset of kernels from the meta-kernel
   cas_2011_v17.tm provided in the CO-S/J/E/V-SPICE-6-V1.0 SPICE PDS3 archive,
   covering the whole or a part of the customer requested time period
   from 2011-02-13T00:00:00.000 to 2011-02-14T00:00:00.000.

   The documentation describing these kernels can be found in the
   complete CO-S/J/E/V-SPICE-6-V1.0 SPICE PDS3 archive available at this URL

   https://naif.jpl.nasa.gov/pub/naif/pds/data/co-s_j_e_v-spice-6-v1.0/cosp_1000

   To use this meta-kernel users may need to modify the value of the
   PATH_VALUES keyword to point to the actual location of the archive's
   ``data'' directory on their system. Replacing ``/'' with ``\''
   and converting line terminators to the format native to the user's
   system may also be required if this meta-kernel is to be used on a
   non-UNIX workstation.

   This meta-kernel was created by the NAIF node's SPICE PDS archive
   subsetting service version 2.1 on Mon Jun 19 08:13:34 PDT 2023.

 
   \begindata
 
      PATH_VALUES     = (
                         '.'
                        )
 
      PATH_SYMBOLS    = (
                         'KERNELS'
                        )
 
      KERNELS_TO_LOAD = (
                         '$KERNELS/lsk/naif0012.tls'
                         '$KERNELS/pck/pck00010.tpc'
                         '$KERNELS/fk/cas_rocks_v18.tf'
                         '$KERNELS/fk/cas_mimi_v202.tf'
                         '$KERNELS/fk/cas_dyn_v03.tf'
                         '$KERNELS/fk/cas_v41.tf'
                         '$KERNELS/ik/cas_caps_v03.ti'
                         '$KERNELS/ik/cas_cda_v01.ti'
                         '$KERNELS/ik/cas_cirs_v09.ti'
                         '$KERNELS/ik/cas_inms_v02.ti'
                         '$KERNELS/ik/cas_iss_v10.ti'
                         '$KERNELS/ik/cas_mag_v01.ti'
                         '$KERNELS/ik/cas_mimi_v11.ti'
                         '$KERNELS/ik/cas_radar_v11.ti'
                         '$KERNELS/ik/cas_rpws_v01.ti'
                         '$KERNELS/ik/cas_rss_v03.ti'
                         '$KERNELS/ik/cas_sru_v02.ti'
                         '$KERNELS/ik/cas_uvis_v06.ti'
                         '$KERNELS/ik/cas_vims_v06.ti'
                         '$KERNELS/sclk/cas00172.tsc'
                         '$KERNELS/spk/180927AP_RE_90165_18018.bsp'
                         '$KERNELS/spk/140809BP_IRRE_00256_25017.bsp'
                         '$KERNELS/spk/110504R_SCPSE_11041_11093.bsp'
                         '$KERNELS/ck/11001_12001pa_gapfill_v14.bc'
                         '$KERNELS/ck/11017_11066py_as_flown.bc'
                         '$KERNELS/ck/11044_11049ra.bc'
                         '$KERNELS/ck/cas_cda_20120517.bc'
                         '$KERNELS/ck/cas_lemms_05109_20001_v2.bc'
                        )
 
   \begintext
 

User functions


source

get_metakernel_and_files

 get_metakernel_and_files (mission:str, start:str, stop:str,
                           save_location:str=None, quiet:bool=False)

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

Type Default Details
mission str mission shorthand from datasets dataframe
start str start time as iso-string, or yyyy-jjj
stop str stop time as iso-string or yyyy-jjj
save_location str None override storage into planetarypy archive
quiet bool False suppress kernel-wise feedback
Returns Path pathlib.Path to metakernel file with corrected data path.
mkpath = get_metakernel_and_files("cassini", "2011-02-13", "2011-02-14")
mkpath
/Users/maye/mambaforge/envs/py39/lib/python3.9/site-packages/distributed/node.py:182: UserWarning: Port 8787 is already in use.
Perhaps you already have a cluster running?
Hosting the HTTP server on port 57624 instead
  warnings.warn(
ck 11001_12001pa_gapfill_v14.bc locally available.
ck 11017_11066py_as_flown.bc locally available.
ck 11044_11049ra.bc locally available.
ck cas_cda_20120517.bc locally available.
ck cas_lemms_05109_20001_v2.bc locally available.
fk cas_dyn_v03.tf locally available.
fk cas_mimi_v202.tf locally available.
fk cas_rocks_v18.tf locally available.
fk cas_v41.tf locally available.
ik cas_caps_v03.ti locally available.
ik cas_cda_v01.ti locally available.
ik cas_cirs_v09.ti locally available.
ik cas_inms_v02.ti locally available.
ik cas_iss_v10.ti locally available.
ik cas_mag_v01.ti locally available.
ik cas_mimi_v11.ti locally available.
ik cas_radar_v11.ti locally available.
ik cas_rpws_v01.ti locally available.
ik cas_rss_v03.ti locally available.
ik cas_sru_v02.ti locally available.
ik cas_uvis_v06.ti locally available.
ik cas_vims_v06.ti locally available.
lsk naif0012.tls locally available.
pck pck00010.tpc locally available.
sclk cas00172.tsc locally available.
spk 110504R_SCPSE_11041_11093.bsp locally available.
spk 140809BP_IRRE_00256_25017.bsp locally available.
spk 180927AP_RE_90165_18018.bsp locally available.
Path('/Users/maye/planetarypy_data/spice_kernels/cassini/cas_2011_v17_110213_110214.tm')

source

list_kernels_for_day

 list_kernels_for_day (mission:str, start:str, stop:str='')
Type Default Details
mission str mission shorthand from datasets dataframe
start str start time as iso-string, or yyyy-jjj
stop str stop time as iso-string or yyyy-jjj
Returns list list of kernel names
list_kernels_for_day("mro", "2015-02-13")
['ck/mro_crm_psp_150201_150228.bc',
 'ck/mro_hga_psp_150210_150216_v2.bc',
 'ck/mro_mcs_psp_150201_150228.bc',
 'ck/mro_sa_psp_150210_150216_v2.bc',
 'ck/mro_sc_psp_150210_150216_v2.bc',
 'fk/mro_v16.tf',
 'ik/mro_crism_v10.ti',
 'ik/mro_ctx_v11.ti',
 'ik/mro_hirise_v12.ti',
 'ik/mro_marci_v10.ti',
 'ik/mro_mcs_v10.ti',
 'ik/mro_onc_v10.ti',
 'lsk/naif0012.tls',
 'pck/pck00008.tpc',
 'sclk/mro_sclkscet_00095_65536.tsc',
 'spk/de421.bsp',
 'spk/mar097.bsp',
 'spk/mro_psp34.bsp',
 'spk/mro_psp34_ssd_mro95a.bsp',
 'spk/mro_struct_v10.bsp']
# this always takes much longer than other requests!
list_kernels_for_day("maven", "2017-01-01")
['ck/mvn_app_rel_161226_170101_v01.bc',
 'ck/mvn_app_rel_170102_170108_v01.bc',
 'ck/mvn_iuvs_rem_170101_170331_v03.bc',
 'ck/mvn_sc_rel_161226_170101_v01.bc',
 'ck/mvn_sc_rel_170102_170108_v02.bc',
 'ck/mvn_swea_nom_131118_300101_v02.bc',
 'fk/maven_v09.tf',
 'ik/maven_ant_v10.ti',
 'ik/maven_euv_v10.ti',
 'ik/maven_iuvs_v11.ti',
 'ik/maven_ngims_v10.ti',
 'ik/maven_sep_v12.ti',
 'ik/maven_static_v11.ti',
 'ik/maven_swea_v11.ti',
 'ik/maven_swia_v10.ti',
 'lsk/naif0012.tls',
 'pck/pck00010.tpc',
 'sclk/mvn_sclkscet_00072.tsc',
 'spk/de430s.bsp',
 'spk/mar097s.bsp',
 'spk/maven_orb_rec_170101_170401_v1.bsp',
 'spk/maven_struct_v01.bsp']
# this always takes much longer than other requests!
list_kernels_for_day("orex", "2018-11-30")
['ck/orx_sa_rel_181126_181202_v01.bc',
 'ck/orx_sc_rel_181126_181202_v01.bc',
 'ck/orx_struct_mapcam_v01.bc',
 'ck/orx_struct_polycam_v01.bc',
 'fk/orx_shape_v03.tf',
 'fk/orx_v14.tf',
 'ik/orx_lidar_v00.ti',
 'ik/orx_navcam_v02.ti',
 'ik/orx_ocams_v07.ti',
 'ik/orx_ola_v01.ti',
 'ik/orx_otes_v00.ti',
 'ik/orx_ovirs_v00.ti',
 'ik/orx_rexis_v01.ti',
 'ik/orx_stowcam_v00.ti',
 'ik/orx_struct_v00.ti',
 'lsk/naif0012.tls',
 'pck/bennu_v17.tpc',
 'pck/pck00010.tpc',
 'sclk/orx_sclkscet_00074.tsc',
 'spk/bennu_refdrmc_v1.bsp',
 'spk/de424.bsp',
 'spk/orx_180301_181201_180921_od044_v1.bsp',
 'spk/orx_180801_190302_181218_od077_v1.bsp',
 'spk/orx_181203_190302_190104_od085_v1.bsp',
 'spk/orx_struct_v04.bsp']
def _test_mission_kernels_available(mission):
    print("Doing", mission)
    start = datasets.at[mission, "Start Time"]
    end = datasets.at[mission, "Stop Time"]
    half = Time(start) + (Time(end) - Time(start)) / 2
    print("Half time:", half)
    try:
        found = list_kernels_for_day(mission, half)
    except IndexError:
        print("Problem with", mission)
    else:
        print(f"Found {len(found)} kernels for {mission}")

for mission in datasets.index:
    _test_mission_kernels_available(mission)
Doing bc
Half time: 2020-11-25 00:00:00.000
Found 41 kernels for bc
Doing cassini
Half time: 2007-09-30 12:00:01.000
Found 32 kernels for cassini
Doing clementine
Half time: 1994-03-17 12:00:00.000
Found 19 kernels for clementine
Doing dart
Half time: 2035-12-06 00:00:00.000
Found 14 kernels for dart
Doing dawn
Half time: 2013-04-14 00:00:00.000
Found 21 kernels for dawn
Doing di
Half time: 2005-04-26 12:00:00.000
Found 16 kernels for di
Doing ds1
Half time: 2000-05-21 11:59:59.500
Found 11 kernels for ds1
Doing epoxi
Half time: 2008-05-27 00:00:00.000
Found 12 kernels for epoxi
Doing em16
Half time: 2019-08-07 23:59:59.500
Found 27 kernels for em16
Doing grail
Half time: 2012-04-29 00:00:00.500
Found 20 kernels for grail
Doing hayabusa
Half time: 2005-10-15 12:00:00.000
Found 15 kernels for hayabusa
Doing insight
Half time: 2020-08-24 12:00:00.000
Found 21 kernels for insight
Doing juno
Half time: 2017-02-08 23:59:58.500
Found 25 kernels for juno
Doing ladee
Half time: 2031-11-04 11:59:59.000
Found 12 kernels for ladee
Doing lro
Half time: 2016-04-30 23:59:59.500
Found 24 kernels for lro
Doing maven
Half time: 2018-07-25 11:59:59.000
Found 20 kernels for maven
Doing opportunity
Half time: 2010-12-23 00:00:00.500
Found 23 kernels for opportunity
Doing spirit
Half time: 2006-11-20 12:00:00.000
Found 24 kernels for spirit
Doing messenger
Half time: 2009-12-15 23:59:59.500
Found 18 kernels for messenger
Doing mars2020
Half time: 2021-10-13 12:00:00.000
Found 17 kernels for mars2020
Doing mex
Half time: 2013-03-01 11:59:59.500
Found 39 kernels for mex
Doing mgs
Half time: 2001-11-03 23:59:59.500
Found 20 kernels for mgs
Doing ody
Half time: 2012-01-03 12:00:00.500
Found 14 kernels for ody
Doing mro
Half time: 2014-06-06 11:59:59.500
Found 20 kernels for mro
Doing msl
Half time: 2017-05-16 23:59:58.500
Found 50 kernels for msl
Doing near
Half time: 1998-10-14 12:00:00.000
Found 15 kernels for near
Doing nh
Half time: 2013-01-08 12:00:00.000
Found 28 kernels for nh
Doing orex
Half time: 2018-11-30 23:59:59.500
  warnings.warn('ERFA function "{}" yielded {}'.format(func_name, wmsg),
  warnings.warn('ERFA function "{}" yielded {}'.format(func_name, wmsg),
  warnings.warn('ERFA function "{}" yielded {}'.format(func_name, wmsg),
  warnings.warn('ERFA function "{}" yielded {}'.format(func_name, wmsg),
OSError: SPICE Server request returned status code: {r.status_code}

NOTE: Any ErfaWarnings above are caused by the LADEE mission using a kernel up to 2050, and the astropy.Time module warns about potential precicision issues regarding unknown leapseconds that will be put in in the future.

Generic kernel management

There are a few generic kernels that are required for basic illumination calculations as supported by this package.


source

download_generic_kernels

 download_generic_kernels (overwrite=False)

Download all kernels as required by generic_kernel_list.

download_generic_kernels()

source

load_generic_kernels

 load_generic_kernels ()

*Load all kernels in generic_kernels list.

Loads pure planetary bodies meta-kernel without spacecraft data.

Downloads any missing generic kernels.*

spice.kclear()
load_generic_kernels()

source

show_loaded_kernels

 show_loaded_kernels ()

Print overview of loaded kernels.

show_loaded_kernels()
from nbdev import nbdev_export

nbdev_export()