Commit 05a5d3ff authored by Alessandro Frigeri's avatar Alessandro Frigeri
Browse files

introduced a check for _MOV frame, outputting error for missing CK

parent efde6503
Loading
Loading
Loading
Loading
+71 −34
Original line number Diff line number Diff line
%% Cell type:markdown id: tags:

## Ma_MISS example

This is an example of localization of Ma_MISS frame and instrument reading (derived from the original test script)

%% Cell type:code id: tags:

``` python
import spiceypy
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
import os
```

%% Cell type:code id: tags:

``` python
# Set the base_path to the directory of the repo
base_path = '/tmp/a/mamissspice/'
base_path = 'LOCAL_CODE_DIRECTORY'
os.chdir( base_path+'/kernels/')
```

%% Cell type:code id: tags:

``` python
# Load the metakernel
spiceypy.furnsh('mk/emrsp_test_rec_0003_v004.tm')

# How many kernel did we load?
spiceypy.ktotal('ALL')
```

%% Output

    ---------------------------------------------------------------------------
    SpiceNOSUCHFILE                           Traceback (most recent call last)
    <ipython-input-49-8f6fa52d0862> in <module>
          1 # Load the metakernel
    ----> 2 spiceypy.furnsh('mk/emrsp_test_rec_0003_v004.tm')
          3
          4 # How many kernel did we load?
          5 spiceypy.ktotal('ALL')
    /usr/local/lib/python3.9/site-packages/spiceypy/spiceypy.py in with_errcheck(*args, **kwargs)
        106         try:
        107             res = f(*args, **kwargs)
    --> 108             check_for_spice_error(f)
        109             return res
        110         except BaseException:
    /usr/local/lib/python3.9/site-packages/spiceypy/spiceypy.py in check_for_spice_error(f)
         89         traceback = qcktrc(200)
         90         reset()
    ---> 91         raise stypes.dynamically_instantiate_spiceyerror(
         92             short=short, explain=explain, long=long, traceback=traceback
         93         )
    SpiceNOSUCHFILE:
================================================================================

Toolkit version: CSPICE66

SPICE(NOSUCHFILE) --

The first file '../fk/emrsp_rm_v007.tf' specified by KERNELS_TO_LOAD in the file mk/emrsp_test_rec_0003_v004.tm could not be located.

furnsh_c --> FURNSH --> ZZLDKER

================================================================================
    33

%% Cell type:code id: tags:

``` python
# Compute 500 time-steps between 2 sols
solStart = spiceypy.str2et("2021 APR 01 23:01:09.185 UTC")
solEnd = spiceypy.str2et("2021 APR 04 23:01:09.1850 UTC")
times = np.linspace(solStart, solEnd, num=500, endpoint=True)
```

%% Cell type:code id: tags:

``` python
# retrieve rover position at there 500 time-steps
rosalind_positions, lttimes = spiceypy.spkpos("EXOMARS ROVER", times, "IAU_MARS", "lt+s", "MARS")
```

%% Output

    array([[ 2933.57319826, -1339.99580045,  1047.91587017],
           [ 2933.57680434, -1339.99742935,  1047.91715661],
           [ 2933.58069342, -1339.99903926,  1047.9185248 ],
           ...,
           [ 2933.55887234, -1339.89816799,  1047.99150258],
           [ 2933.55851812, -1339.89800624,  1047.99137604],
           [ 2933.55842628, -1339.89796432,  1047.99134325]])

%% Cell type:code id: tags:

``` python
# retrieve the position of CLUPI and the DRILL TIP
clupi_positions,    lttimes = spiceypy.spkpos("RM_CLUPI",times, "IAU_MARS", "lt+s", "MARS")
drilltip_positions, lttimes = spiceypy.spkpos("RM_DRILL_TIP_FIX",times, "IAU_MARS", "lt+s", "MARS")
drilltip_positions_FIX, lttimes = spiceypy.spkpos("RM_DRILL_TIP_FIX",times, "IAU_MARS", "lt+s", "MARS")
drilltip_positions_FIX
```

%% Output

    array([[ 2933.57345983, -1339.9953418 ,  1047.9163352 ],
           [ 2933.57707367, -1339.99697882,  1047.91762514],
           [ 2933.58096274, -1339.99858822,  1047.91899287],
           ...,
           [ 2933.55868789, -1339.89854543,  1047.99206699],
           [ 2933.55833368, -1339.89838368,  1047.99194045],
           [ 2933.55824184, -1339.89834175,  1047.99190766]])

%% Cell type:code id: tags:

``` python
# Eleonora's test: missing CK to move the RM_DRILL_TIP_MOV
drilltip_positions_MOV, lttimes = spiceypy.spkpos("RM_DRILL_TIP_MOV",times, "IAU_MARS", "lt+s", "MARS")
drilltip_positions_MOV
```

%% Output

    ---------------------------------------------------------------------------
    SpiceSPKINSUFFDATA                        Traceback (most recent call last)
    <ipython-input-17-08d36c56eb65> in <module>
          1 # Eleonora's test
    ----> 2 drilltip_positions_MOV, lttimes = spiceypy.spkpos("RM_DRILL_TIP_MOV",times, "IAU_MARS", "lt+s", "MARS")
          3 drilltip_positions_MOV
    /usr/local/lib/python3.9/site-packages/spiceypy/spiceypy.py in with_errcheck(*args, **kwargs)
        105     def with_errcheck(*args, **kwargs):
        106         try:
    --> 107             res = f(*args, **kwargs)
        108             check_for_spice_error(f)
        109             return res
    /usr/local/lib/python3.9/site-packages/spiceypy/spiceypy.py in spkpos(targ, et, ref, abcorr, obs)
      12127         for t in et:
      12128             libspice.spkpos_c(targ, t, ref, abcorr, obs, ptarg, ctypes.byref(lt))
    > 12129             check_for_spice_error(None)
      12130             ptargs.append(stypes.c_vector_to_python(ptarg))
      12131             lts.append(lt.value)
    /usr/local/lib/python3.9/site-packages/spiceypy/spiceypy.py in check_for_spice_error(f)
         89         traceback = qcktrc(200)
         90         reset()
    ---> 91         raise stypes.dynamically_instantiate_spiceyerror(
         92             short=short, explain=explain, long=long, traceback=traceback
         93         )
    SpiceSPKINSUFFDATA:
================================================================================

Toolkit version: CSPICE66

SPICE(SPKINSUFFDATA) --

Insufficient ephemeris data has been loaded to compute the position of -174043 (RM_DRILL_TIP_MOV) relative to 0 (SOLAR SYSTEM BARYCENTER) at the ephemeris epoch 2021 APR 01 23:02:18.370.

spkpos_c --> SPKPOS --> SPKEZP --> SPKAPO --> SPKGPS

================================================================================

%% Cell type:code id: tags:

``` python
# retrieve MaMISS position
mamiss_positions,    lttimes = spiceypy.spkpos("RM_MAMISS",times, "IAU_MARS", "lt+s", "MARS")
```

%% Output

    ---------------------------------------------------------------------------
    SpiceSPKINSUFFDATA                        Traceback (most recent call last)
    <ipython-input-46-9eef3b3a6b89> in <module>
          1 # retrieve MaMISS position
    ----> 2 mamiss_positions,    lttimes = spiceypy.spkpos("RM_MAMISS",times, "IAU_MARS", "lt+s", "MARS")

    /usr/local/lib/python3.9/site-packages/spiceypy/spiceypy.py in with_errcheck(*args, **kwargs)
        105     def with_errcheck(*args, **kwargs):
        106         try:
    --> 107             res = f(*args, **kwargs)
        108             check_for_spice_error(f)
        109             return res
    /usr/local/lib/python3.9/site-packages/spiceypy/spiceypy.py in spkpos(targ, et, ref, abcorr, obs)
      12127         for t in et:
      12128             libspice.spkpos_c(targ, t, ref, abcorr, obs, ptarg, ctypes.byref(lt))
    > 12129             check_for_spice_error(None)
      12130             ptargs.append(stypes.c_vector_to_python(ptarg))
      12131             lts.append(lt.value)
    /usr/local/lib/python3.9/site-packages/spiceypy/spiceypy.py in check_for_spice_error(f)
         89         traceback = qcktrc(200)
         90         reset()
    ---> 91         raise stypes.dynamically_instantiate_spiceyerror(
         92             short=short, explain=explain, long=long, traceback=traceback
         93         )
    SpiceSPKINSUFFDATA:
================================================================================

Toolkit version: CSPICE66

SPICE(SPKINSUFFDATA) --

Insufficient ephemeris data has been loaded to compute the position of -174500 (RM_MAMISS) relative to 0 (SOLAR SYSTEM BARYCENTER) at the ephemeris epoch 2021 APR 01 23:02:18.370.

spkpos_c --> SPKPOS --> SPKEZP --> SPKAPO --> SPKGPS

================================================================================

%% Cell type:code id: tags:

``` python
```