SPICE aberration corrections#
In order to simplify the use of the SPICE aberration corrections, we introduced a SpiceAbCorr
object:
from planetary_coverage.spice import SpiceAbCorr
It will check that the provided values are valid:
SpiceAbCorr()
'NONE'
SpiceAbCorr('LT')
'LT'
SpiceAbCorr('XCN+S')
'XCN+S'
SpiceAbCorr('FOO')
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
Cell In[5], line 1
----> 1 SpiceAbCorr('FOO')
File ~/checkouts/readthedocs.org/user_builds/planetary-coverage/checkouts/stable/src/planetary_coverage/spice/abcorr.py:59, in SpiceAbCorr.__new__(cls, abcorr, restrict)
56 restrict = cls.DEFAULTS
58 if abcorr not in restrict:
---> 59 raise KeyError(
60 f'Invalid abcorr: `{abcorr}`. Available: ' +
61 '|'.join(restrict)
62 )
64 return str.__new__(cls, abcorr)
KeyError: 'Invalid abcorr: `FOO`. Available: NONE|LT|LT+S|CN|CN+S|XLT|XLT+S|XCN|XCN+S'
You can restrict the list of the valid keys if you need to:
SpiceAbCorr('LT', restrict=('LT', 'LT+S'))
'LT'
SpiceAbCorr('CN', restrict=('LT', 'LT+S'))
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
Cell In[7], line 1
----> 1 SpiceAbCorr('CN', restrict=('LT', 'LT+S'))
File ~/checkouts/readthedocs.org/user_builds/planetary-coverage/checkouts/stable/src/planetary_coverage/spice/abcorr.py:59, in SpiceAbCorr.__new__(cls, abcorr, restrict)
56 restrict = cls.DEFAULTS
58 if abcorr not in restrict:
---> 59 raise KeyError(
60 f'Invalid abcorr: `{abcorr}`. Available: ' +
61 '|'.join(restrict)
62 )
64 return str.__new__(cls, abcorr)
KeyError: 'Invalid abcorr: `CN`. Available: LT|LT+S'
To be fully compatible with spiceypy
, it extends directly from the python base class str
:
abcorr = SpiceAbCorr('LT+S')
isinstance(abcorr, str)
True
abcorr == 'LT+S'
True
with a few additional properties:
abcorr.reception
True
abcorr.transmission
False
abcorr.stellar
True
abcorr.oneway
True
abcorr.converged
False
Finally, you can apply the light time correction based on the provided key:
et, lt = 10, 2
abcorr = SpiceAbCorr('NONE')
abcorr(et, lt) # NONE -> et (no correction)
10.0
abcorr = SpiceAbCorr('LT')
abcorr(et, lt) # LT -> et - lt (reception)
9.999993328718096
abcorr = SpiceAbCorr('XLT')
abcorr(et, lt) # XLT -> et + lt (transmission)
10.000006671281904