curryer.spicierpy.obj

SPICE (NAIF) ID/Name objects.

Examples

After loading the mission kernels: >>> sc = Spacecraft(‘tcte’, infer_all=True) >>> print(sc.to_string(verbose=True)) Spacecraft(‘TCTE’ or -1234)

Frame(‘TCTE_SC_COORD’ or -1234000) Clock(‘TCTE’ or -1234) Ephemeris(‘TCTE’ or -1234) Attitude(‘-1234000’ or -1234000) Instrument(‘TCTE_TIM’ or -1234001)

Frame(‘TCTE_TIM’ or -1234001)

Instrument(‘TCTE_TIM_GLINT’ or -1234011)

Frame(‘TCTE_TIM’ or -1234001)

>>> print(sc.frame, sc.get_instrument('tcte_tim').frame)
Frame(TCTE_SC_COORD) Frame(TCTE_TIM)

Notes

  • Supports:
    • General NAIF object ID system.

    • Frame ID system.

  • Does not support:
    • Surface ID system.

@author: Brandon Stone

Attributes

Classes

AbstractObj

Light-weight abstract class for storing SPICE name <--> id mappings.

Body

General class for SPICE object mapping.

Frame

Frame mapping for default and FK-based mappings.

AnyBodyOrFrame

Obj representing a body or frame.

Spacecraft

Special case where the object has a clock, ephemeris, attitude, frame

_SpacecraftItem

Abstract mapping class that can store a reference to a spacecraft

Instrument

Instrument mapping.

Clock

Spacecraft clock mapping.

Ephemeris

Spacecraft ephemeris (SPK) mapping.

Attitude

Spacecraft attitude (CK) mapping.

Module Contents

curryer.spicierpy.obj.logger
curryer.spicierpy.obj._INDENT = '    '
class curryer.spicierpy.obj.AbstractObj(id_or_name)

Light-weight abstract class for storing SPICE name <–> id mappings.

__slots__ = ['_name', '_id']
classmethod define(name, id_code, **kwargs)
Abstractmethod:

Register a new name <–> ID mapping and return its object.

Parameters:
  • name (str)

  • id_code (int)

  • **kwargs – Extra keywords are passed to init.

Return type:

AbstractObj

Notes

  • This mapping has a medium priority; above built-in mappings, but

below text kernel mappings. - Multiple names can be mapped to the same ID; last-in, first-out. - Frame mappings must be defined in a frame kernel (FK).

__repr__()

<class-name>(<obj-name> or <obj-id>)

__eq__(other)

Equate objects if one is a child of the other and their IDs match.

property name

Object name (uppercase).

Return type:

str

property id

Object ID.

Return type:

int

abstractmethod _name2code(value)

Return the SPICE ID for to the given SPICE name.

abstractmethod _code2name(value)

Return the SPICE name for to the given SPICE ID.

to_string(depth=0, verbose=False)

String representation with an optional indent level.

_check_if_missing(value, attr_name)

Raise an error if missing a value.

class curryer.spicierpy.obj.Body(id_or_name, frame=None)

Bases: AbstractObj

General class for SPICE object mapping.

Examples

>>> earth = Body('earth')
>>> print(earth.name, earth.id)
EARTH 399
>>> print(earth, earth.frame)
Body('EARTH' or 399) Frame('ITRF93' or 13000)
__slots__ = ['_frame']
_frame = None
property frame

SPICE frame related to this body (e.g., SUN –> IAU_SUN).

Return type:

Frame

classmethod define(name, id_code, **kwargs)

Register a new name <–> ID mapping and return its object.

Parameters:
  • name (str)

  • id_code (int)

  • **kwargs – Extra keywords are passed to init.

Return type:

AbstractObj

Notes

  • This mapping has a medium priority; above built-in mappings, but

below text kernel mappings. - Multiple names can be mapped to the same ID; last-in, first-out. - Frame mappings must be defined in a frame kernel (FK).

_name2code

Return the SPICE ID for to the given SPICE name.

_code2name

Return the SPICE name for to the given SPICE ID.

class curryer.spicierpy.obj.Frame(id_or_name, body=None)

Bases: AbstractObj

Frame mapping for default and FK-based mappings.

Examples

>>> iau_sun = Frame('iau_sun')
>>> print(iau_sun.name, iau_sun.id)
IAU_SUN 10010
>>> print(iau_sun, iau_sun.body)
Frame('IAU_SUN' or 10010) Body('SUN' or 10)

Notes

  • The frame ID system is separate from the general SPICE object system, and

the same ID value is interpreted differently depending on the system.
  • Generally instrument or spacecraft subsystem ID vs. frame ID.

__slots__ = ['_body']
_body = None
property body

SPICE body related to this frame (e.g., IAU_SUN –> SUN).

Return type:

Body

classmethod define(name, id_code, **kwargs)

Register a new name <–> ID mapping and return its object.

Parameters:
  • name (str)

  • id_code (int)

  • **kwargs – Extra keywords are passed to init.

Return type:

AbstractObj

Notes

  • This mapping has a medium priority; above built-in mappings, but

below text kernel mappings. - Multiple names can be mapped to the same ID; last-in, first-out. - Frame mappings must be defined in a frame kernel (FK).

_name2code(value)

Return the SPICE ID for to the given SPICE name.

_code2name(value)

Return the SPICE name for to the given SPICE ID.

class curryer.spicierpy.obj.AnyBodyOrFrame(id_or_name, body=True, frame=True)

Bases: AbstractObj

Obj representing a body or frame.

__slots__ = ['_is_frame', '_obj']
property is_frame
property body
property frame
classmethod define(name, id_code, **kwargs)
Abstractmethod:

Register a new name <–> ID mapping and return its object.

Parameters:
  • name (str)

  • id_code (int)

  • **kwargs – Extra keywords are passed to init.

Return type:

AbstractObj

Notes

  • This mapping has a medium priority; above built-in mappings, but

below text kernel mappings. - Multiple names can be mapped to the same ID; last-in, first-out. - Frame mappings must be defined in a frame kernel (FK).

_name2code(value)

Return the SPICE ID for to the given SPICE name.

_code2name(value)

Return the SPICE name for to the given SPICE ID.

class curryer.spicierpy.obj.Spacecraft(id_or_name, frame=None, clock=None, ephemeris=None, attitude=None, instruments=None, infer_all=False)

Bases: Body

Special case where the object has a clock, ephemeris, attitude, frame and zero or more instruments; typically a spacecraft.

Examples

>>> sc = Spacecraft('tcte')
>>> print(sc.name, sc.id)
TCTE -1234
>>> print(sc.id, sc.attitude.id, sc.frame.id)
-1234 -1234000 -1234000
>>> print(sc.get_instrument('tcte_tim'))
Instrument('TCTE_TIM' or -1234001)
    Frame('TCTE_TIM' or -1234001)
__slots__ = ['_clock', '_ephemeris', '_attitude', '_instruments']
_clock = None
_ephemeris = None
_attitude = None
_instruments = None
property clock

Spacecraft mapping object for this spacecraft.

Returns:

Assumes the clock uses the same ID as the spacecraft (typical).

Return type:

Clock

property ephemeris

Ephemeris mapping for this spacecraft.

Returns:

Assumes the SPK uses the same ID as the spacecraft (typical).

Return type:

Ephemeris

property attitude

Attitude mapping for this spacecraft.

Returns:

Attitude mapped to the spacecrafts reference frame; must use a CK-based reference frame spacecraft.

Return type:

Attitude

property instruments

All SPICE objects with an ID in the standard instrument ID range.

Returns:

Instrument IDs and Instrument mappings related to this spacecraft.

Return type:

collections.OrderedDict

Notes

  • Standard instrument ID range:

    [<spacecraft-id> * 1000, <spacecraft-id> * 1000 - 999]

  • Based on the kernel pool variable: “NAIF_BODY_CODE”

get_instrument(id_or_name)

Retrieve an instrument mapping and associate it with this spacecraft mapping.

Parameters:

id_or_name (int or str) – Instrument ID or name.

Return type:

Instrument

to_string(depth=0, verbose=False)

String representation with an optional indent level.

class curryer.spicierpy.obj._SpacecraftItem(id_or_name, frame=None, spacecraft=None)

Bases: Body

Abstract mapping class that can store a reference to a spacecraft mapping object.

__slots__ = ['_spacecraft']
_spacecraft = None
property spacecraft

Spacecraft mapping related to this item.

Returns:

Either the spacecraft supplied during init (e.g., item accessed through a Spacecraft instance), or a new instance based ID assumptions (see subclass method _infer_spacecraft_id).

Return type:

Spacecraft

abstractmethod _infer_spacecraft(id_code)

Infer the spacecraft from the object’s ID.

class curryer.spicierpy.obj.Instrument(id_or_name, frame=None, spacecraft=None)

Bases: _SpacecraftItem

Instrument mapping.

Examples

>>> tim = Instrument('tcte_tim')
>>> print(tim.name, tim.id)
TCTE_TIM -1234001
>>> print(tim.spacecraft.name, tim.frame)
TCTE Frame('TCTE_TIM' or -1234001)
__slots__ = []
_infer_spacecraft(id_code)

Infer the spacecraft from the object’s ID.

to_string(depth=0, verbose=False)

String representation with an optional indent level.

class curryer.spicierpy.obj.Clock(id_or_name, frame=None, spacecraft=None)

Bases: _SpacecraftItem

Spacecraft clock mapping.

Examples

>>> sclk = Clock('tcte')
>>> print(sclk.name, sclk.id)
TCTE -1234
__slots__ = []
_infer_spacecraft(id_code)

Infer the spacecraft from the object’s ID.

class curryer.spicierpy.obj.Ephemeris(id_or_name, frame=None, spacecraft=None)

Bases: _SpacecraftItem

Spacecraft ephemeris (SPK) mapping.

Examples

>>> spk = Ephemeris('tcte')
>>> print(spk.name, spk.id)
TCTE -1234
__slots__ = []
_infer_spacecraft(id_code)

Infer the spacecraft from the object’s ID.

class curryer.spicierpy.obj.Attitude(id_or_name, frame=None, spacecraft=None)

Bases: _SpacecraftItem

Spacecraft attitude (CK) mapping.

Examples

>>> ck = Attitude(-1234000)
>>> print(repr(ck.name), ck.id)
'-1234000' -1234000
>>> print(ck.spacecraft.name, ck.spacecraft.id)
TCTE -1234
__slots__ = []
_infer_spacecraft(id_code)

Infer the spacecraft from the object’s ID.