Source code for irfpy.pep.galileo_spice

''' Replaces :mod:`galileo_orbit`.

The Galileo orbit information from SPICE in Galileo PDS.

The files are downloaded via web interface of PDS.
The kernel is not in the repository, because they are very large in size
and this may not used for future investigations.
Thus, the kernel files should be prepared differently.
Refer to Futaana for this with statement ``Futaana to refer to folder 111125-juice-orbit.```


.. todo::

    Full re-implementation!!
    Thus, no doctests are done.!!!

.. todo::

    Archive the data, not in the repository but not in the master repository.
    Some other way is better.

'''
import os
import glob

from pkg_resources import resource_filename

import numpy as np

try:
    import spiceypy as spice
except ImportError:
    import spice


[docs]class GalileoSpice: __default_instance = None
[docs] @classmethod def get_default_instance(cls): if cls.__default_instance == None: cls.__default_instance = GalileoSpice() return cls.__default_instance
def __init__(self): ### Use pkg_resource while kernel files are not in the repository. kernsdir = resource_filename(__name__, os.path.join('galileo_orbit', 'kernels')) kerns = glob.glob(os.path.join(kernsdir, '*')) for kern in kerns: if kern.endswith('TXT'): continue if kern.endswith('LBL'): continue if kern.endswith('TSP'): continue print('Loading', kern) spice.furnsh(kern) kernsdir = resource_filename(__name__, os.path.join('spice')) kerns = glob.glob(os.path.join(kernsdir, '*')) for kern in kerns: if kern.endswith('TXT'): continue if kern.endswith('LBL'): continue if kern.endswith('TSP'): continue if kern.endswith('rst'): continue print('Loading', kern) spice.furnsh(kern)
[docs] def get_position(self, t, relative_to="JUPITER", frame="JSE"): et0 = spice.str2et(t.strftime('%FT%T')) posvel, lt = spice.spkezr('GALILEO ORBITER', et0, frame, "LT+S", relative_to) return np.array(posvel[0:3])
[docs] def get_velocity(self, t, relative_to="JUPITER", frame="JSE"): ''' Return the Galileo orbiter's velocity vector. :param t: Time :type t: ``datetime.datetime`` :keyword relative_to: The SPICE name of the body to calculate the relative velocity :type relative_to: String or SPICE ID :keyword frame: Frame of the velocity vector :type frame: String :returns: Return the galileo orbiter's velocity vector in the given frame :rtype: ``np.array`` ''' et0 = spice.str2et(t.strftime('%FT%T')) posvel, lt = spice.spkezr('GALILEO ORBITER', et0, frame, 'LT+S', relative_to) return np.array(posvel[3:])
[docs] def get_positions(self, tlist): return np.array([self.get_position(t) for t in tlist])
[docs] def get_callisto_position(self, t): et0 = spice.str2et(t.strftime('%FT%T')) posvel, lt = spice.spkezr('CALLISTO', et0, 'JSE', "LT+S", 'JUPITER') return np.array(posvel[0:3])
[docs] def get_ganymede_position(self, t): et0 = spice.str2et(t.strftime('%FT%T')) posvel, lt = spice.spkezr('GANYMEDE', et0, 'JSE', "LT+S", 'JUPITER') return np.array(posvel[0:3])