Skip to content

Commit

Permalink
Always parse times with astropy Time
Browse files Browse the repository at this point in the history
  • Loading branch information
dstansby committed Nov 18, 2019
1 parent 1677364 commit 5a6ed2c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions heliopy/spice/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,17 @@ def generate_positions(self, times, observing_body, frame):
https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/req/frames.html
for a list of frames.
"""
times = time.Time(times)
# Spice needs a funny set of times
fmt = '%Y %b %d, %H:%M:%S'
spice_times = [spiceypy.str2et(time.strftime(fmt)) for time in times]
# 'None' specifies no light-travel time correction
light_travel_correction = 'None'

# Do the calculation
pos_vel, lightTimes = spiceypy.spkezr(
self.target, spice_times, frame, 'None', observing_body)
self.target, spice_times, frame, light_travel_correction,
observing_body)

positions = np.array(pos_vel)[:, :3] * u.km
velocities = np.array(pos_vel)[:, 3:] * u.km / u.s

Expand Down

0 comments on commit 5a6ed2c

Please sign in to comment.