curryer.spicierpy.obj ===================== .. py:module:: curryer.spicierpy.obj .. autoapi-nested-parse:: SPICE (NAIF) ID/Name objects. .. rubric:: 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) .. rubric:: Notes - Supports: - General NAIF object ID system. - Frame ID system. - Does not support: - Surface ID system. @author: Brandon Stone Attributes ---------- .. autoapisummary:: curryer.spicierpy.obj.logger curryer.spicierpy.obj._INDENT Classes ------- .. autoapisummary:: curryer.spicierpy.obj.AbstractObj curryer.spicierpy.obj.Body curryer.spicierpy.obj.Frame curryer.spicierpy.obj.AnyBodyOrFrame curryer.spicierpy.obj.Spacecraft curryer.spicierpy.obj._SpacecraftItem curryer.spicierpy.obj.Instrument curryer.spicierpy.obj.Clock curryer.spicierpy.obj.Ephemeris curryer.spicierpy.obj.Attitude Module Contents --------------- .. py:data:: logger .. py:data:: _INDENT :value: ' ' .. py:class:: AbstractObj(id_or_name) Light-weight abstract class for storing SPICE name <--> id mappings. .. py:attribute:: __slots__ :value: ['_name', '_id'] .. py:method:: define(name, id_code, **kwargs) :classmethod: :abstractmethod: Register a new name <--> ID mapping and return its object. :param name: :type name: str :param id_code: :type id_code: int :param \*\*kwargs: Extra keywords are passed to init. :rtype: AbstractObj .. rubric:: 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). .. py:method:: __repr__() ( or ) .. py:method:: __eq__(other) Equate objects if one is a child of the other and their IDs match. .. py:property:: name Object name (uppercase). :rtype: str .. py:property:: id Object ID. :rtype: int .. py:method:: _name2code(value) :abstractmethod: Return the SPICE ID for to the given SPICE name. .. py:method:: _code2name(value) :abstractmethod: Return the SPICE name for to the given SPICE ID. .. py:method:: to_string(depth=0, verbose=False) String representation with an optional indent level. .. py:method:: _check_if_missing(value, attr_name) Raise an error if missing a value. .. py:class:: Body(id_or_name, frame=None) Bases: :py:obj:`AbstractObj` General class for SPICE object mapping. .. rubric:: Examples >>> earth = Body('earth') >>> print(earth.name, earth.id) EARTH 399 >>> print(earth, earth.frame) Body('EARTH' or 399) Frame('ITRF93' or 13000) .. py:attribute:: __slots__ :value: ['_frame'] .. py:attribute:: _frame :value: None .. py:property:: frame SPICE frame related to this body (e.g., SUN --> IAU_SUN). :rtype: Frame .. py:method:: define(name, id_code, **kwargs) :classmethod: Register a new name <--> ID mapping and return its object. :param name: :type name: str :param id_code: :type id_code: int :param \*\*kwargs: Extra keywords are passed to init. :rtype: AbstractObj .. rubric:: 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). .. py:attribute:: _name2code Return the SPICE ID for to the given SPICE name. .. py:attribute:: _code2name Return the SPICE name for to the given SPICE ID. .. py:class:: Frame(id_or_name, body=None) Bases: :py:obj:`AbstractObj` Frame mapping for default and FK-based mappings. .. rubric:: 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) .. rubric:: 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. .. py:attribute:: __slots__ :value: ['_body'] .. py:attribute:: _body :value: None .. py:property:: body SPICE body related to this frame (e.g., IAU_SUN --> SUN). :rtype: Body .. py:method:: define(name, id_code, **kwargs) :classmethod: Register a new name <--> ID mapping and return its object. :param name: :type name: str :param id_code: :type id_code: int :param \*\*kwargs: Extra keywords are passed to init. :rtype: AbstractObj .. rubric:: 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). .. py:method:: _name2code(value) Return the SPICE ID for to the given SPICE name. .. py:method:: _code2name(value) Return the SPICE name for to the given SPICE ID. .. py:class:: AnyBodyOrFrame(id_or_name, body=True, frame=True) Bases: :py:obj:`AbstractObj` Obj representing a body or frame. .. py:attribute:: __slots__ :value: ['_is_frame', '_obj'] .. py:property:: is_frame .. py:property:: body .. py:property:: frame .. py:method:: define(name, id_code, **kwargs) :classmethod: :abstractmethod: Register a new name <--> ID mapping and return its object. :param name: :type name: str :param id_code: :type id_code: int :param \*\*kwargs: Extra keywords are passed to init. :rtype: AbstractObj .. rubric:: 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). .. py:method:: _name2code(value) Return the SPICE ID for to the given SPICE name. .. py:method:: _code2name(value) Return the SPICE name for to the given SPICE ID. .. py:class:: Spacecraft(id_or_name, frame=None, clock=None, ephemeris=None, attitude=None, instruments=None, infer_all=False) Bases: :py:obj:`Body` Special case where the object has a clock, ephemeris, attitude, frame and zero or more instruments; typically a spacecraft. .. rubric:: 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) .. py:attribute:: __slots__ :value: ['_clock', '_ephemeris', '_attitude', '_instruments'] .. py:attribute:: _clock :value: None .. py:attribute:: _ephemeris :value: None .. py:attribute:: _attitude :value: None .. py:attribute:: _instruments :value: None .. py:property:: clock Spacecraft mapping object for this spacecraft. :returns: Assumes the clock uses the same ID as the spacecraft (typical). :rtype: Clock .. py:property:: ephemeris Ephemeris mapping for this spacecraft. :returns: Assumes the SPK uses the same ID as the spacecraft (typical). :rtype: Ephemeris .. py:property:: attitude Attitude mapping for this spacecraft. :returns: Attitude mapped to the spacecrafts reference frame; must use a CK-based reference frame spacecraft. :rtype: Attitude .. py:property:: instruments All SPICE objects with an ID in the standard instrument ID range. :returns: Instrument IDs and Instrument mappings related to this spacecraft. :rtype: collections.OrderedDict .. rubric:: Notes - Standard instrument ID range: [ * 1000, * 1000 - 999] - Based on the kernel pool variable: "NAIF_BODY_CODE" .. py:method:: get_instrument(id_or_name) Retrieve an instrument mapping and associate it with this spacecraft mapping. :param id_or_name: Instrument ID or name. :type id_or_name: int or str :rtype: Instrument .. py:method:: to_string(depth=0, verbose=False) String representation with an optional indent level. .. py:class:: _SpacecraftItem(id_or_name, frame=None, spacecraft=None) Bases: :py:obj:`Body` Abstract mapping class that can store a reference to a spacecraft mapping object. .. py:attribute:: __slots__ :value: ['_spacecraft'] .. py:attribute:: _spacecraft :value: None .. py: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`). :rtype: Spacecraft .. py:method:: _infer_spacecraft(id_code) :abstractmethod: Infer the spacecraft from the object's ID. .. py:class:: Instrument(id_or_name, frame=None, spacecraft=None) Bases: :py:obj:`_SpacecraftItem` Instrument mapping. .. rubric:: 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) .. py:attribute:: __slots__ :value: [] .. py:method:: _infer_spacecraft(id_code) Infer the spacecraft from the object's ID. .. py:method:: to_string(depth=0, verbose=False) String representation with an optional indent level. .. py:class:: Clock(id_or_name, frame=None, spacecraft=None) Bases: :py:obj:`_SpacecraftItem` Spacecraft clock mapping. .. rubric:: Examples >>> sclk = Clock('tcte') >>> print(sclk.name, sclk.id) TCTE -1234 .. py:attribute:: __slots__ :value: [] .. py:method:: _infer_spacecraft(id_code) Infer the spacecraft from the object's ID. .. py:class:: Ephemeris(id_or_name, frame=None, spacecraft=None) Bases: :py:obj:`_SpacecraftItem` Spacecraft ephemeris (SPK) mapping. .. rubric:: Examples >>> spk = Ephemeris('tcte') >>> print(spk.name, spk.id) TCTE -1234 .. py:attribute:: __slots__ :value: [] .. py:method:: _infer_spacecraft(id_code) Infer the spacecraft from the object's ID. .. py:class:: Attitude(id_or_name, frame=None, spacecraft=None) Bases: :py:obj:`_SpacecraftItem` Spacecraft attitude (CK) mapping. .. rubric:: Examples >>> ck = Attitude(-1234000) >>> print(repr(ck.name), ck.id) '-1234000' -1234000 >>> print(ck.spacecraft.name, ck.spacecraft.id) TCTE -1234 .. py:attribute:: __slots__ :value: [] .. py:method:: _infer_spacecraft(id_code) Infer the spacecraft from the object's ID.