Commit 06a0f931 authored by Kristin's avatar Kristin Committed by GitHub
Browse files

Update spkezr call to put target and observer in correction positions and...

Update spkezr call to put target and observer in correction positions and negate resulting vector so it still points the correct direction (#232)
parent fbf328b8
Loading
Loading
Loading
Loading
+13 −8
Original line number Diff line number Diff line
@@ -299,17 +299,22 @@ class NaifSpice():
            ephem = self.ephemeris_time
            pos = []
            vel = []
         
            for time in ephem:
                state, _ = spice.spkezr(self.spacecraft_name,
                # spkezr returns a vector from the observer's location to the aberration-corrected
                # location of the target. For more information, see: 
                # https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/FORTRAN/spicelib/spkezr.html
                state, _ = spice.spkezr(self.target_name,
                                       time,
                                       self.reference_frame,
                                       self.light_time_correction,
                                        self.target_name,)
                                       self.spacecraft_name,)
                pos.append(state[:3])
                vel.append(state[3:])
            # By default, spice works in km
            self._position = [p * 1000 for p in pos]
            self._velocity = [v * 1000 for v in vel]
            # By default, spice works in km, and the vector returned by spkezr points the opposite
            # direction to what ALE needs, so it must be multiplied by (-1) 
            self._position = [p * -1000 for p in pos]
            self._velocity = [v * -1000 for v in vel] 
        return self._position, self._velocity, self.ephemeris_time

    @property