Пример #1
0
 def single_state(self, time, observer='SUN', frame='ECLIPJ2000',
     abcorr=None):
     if isinstance(observer, Body):
         observer = observer.name
     if isinstance(frame, Body):
         frame = frame._frame or frame.name
     return numpy.array(spice.spkezr(self.name, Time.fromposix(time).et(),
         frame, abcorr or Body._ABCORR, observer))
Пример #2
0
    def state(self, times, observer='SUN', frame='ECLIPJ2000',
        abcorr=None):
        '''Get the position and speed of this object relative to the observer
        in a specific reference frame.

        :type times: ``Iterable`` | has ``__float__()``
        :arg times: The point(s) in time for which to calculate the
          position/speed.

        :type observer: :py:class:`~spiceminer.bodies.Body` | ``str``
        :arg observer: Object to use as (0,0,0).

        :type abcorr: ``str``
        :arg abcorr: Aberration correction to be applied. May be one of LT,
          LT+S, CN, CN+S, XLT, XLT+S, XCN, XCN+S. For explanation of these see
          `here <http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/spkez_c.html#Detailed_Input>`_.

        :return: (``ndarray``) -- The nx7 array containing time and
          (x, y, z)-position/speed.
        :raises:
          (``TypeError``) -- If an argument doesn't conform to the type
          requirements.

          (:py:class:`~spiceminer._spicewrapper.SpiceError`) -- If there is
          necessary information missing.
        '''
        if isinstance(observer, Body):
            observer = observer.name
        if isinstance(frame, Body):
            frame = frame._frame or frame.name
        if isinstance(times, numbers.Real):
            times = [float(times)]
        if isinstance(times, collections.Iterable):
            result = []
            for time in times:
                with ignored(spice.SpiceError):
                    data = spice.spkezr(self.name, Time.fromposix(time).et(),
                        frame, abcorr or Body._ABCORR, observer)
                    result.append([time] + data[0] + [data[1]])
            return numpy.array(result).transpose()
        msg = 'state() Real or Iterable argument expected, got {}.'
        raise TypeError(msg.format(type(times)))