''' Dump the 1205 version of spice kernel
Command line options:
-c Center object
-f Frame
-l Limit in km
-s Start time
-e End time
-d Delta time (integer in sec)
'''
import os
import sys
import logging
logging.basicConfig()
import datetime
import getopt
import numpy as np
import pyana.pep.juice_spice1205 as jspice
from pyana.spice.pyspice import spice
def main(center='jupiter', frame='jse', limit=None, t0=datetime.datetime(2022, 6, 1, 7),
t1=datetime.datetime(2033, 7, 4, 18), dt=datetime.timedelta(hours=1)):
print('# JUICE_ORBIT')
print('# CENTER=', center)
print('# FRAME=', frame)
print('# LIMIT=', limit)
js = jspice.JuiceSpice.get_default_instance()
t = t0
logging.getLogger('JuiceSpice').setLevel(logging.WARN)
while t <= t1:
et = spice.utc2et(t.strftime('%FT%T'))
pos = js.get_position(t, relative_to=center, frame=frame)
if np.isnan(pos[0]):
t = t + dt
continue
r = (pos ** 2).sum()
if limit and r > limit * limit:
t = t + dt
continue
print(t, et, '%f %f %f' % (pos[0], pos[1], pos[2]), '%e' % np.sqrt(r))
t = t + dt
if __name__ == "__main__":
optlist, args = getopt.getopt(sys.argv[1:], 'c:f:l:s:e:d:')
# Default values
center = 'jupiter'
frame = 'jse'
limit = None
start = datetime.datetime(2022, 6, 1, 7)
end = datetime.datetime(2033, 7, 4, 18)
delta = datetime.timedelta(hours=1)
for o, a in optlist:
if o == '-c':
center = a
elif o == '-f':
frame = a
elif o == '-l':
limit = float(a)
elif o == '-s':
start = dateutil.parser.parse(a)
elif o == '-e':
end = dateutil.parser.parse(a)
elif o == '-d':
delta = datetime.timedelta(seconds=int(a))
main(center=center, frame=frame, limit=limit, t0=start, t1=end, dt=delta)