appspice.spice_bspdump
¶
SPICE BC file dumping tool
USAGE: spice_bcdump -f frame -c center object t0 t1 dt_sec kernel0 [kernel1 …]
-f frame: Reference frame. If not specified, J2000 is used. -c center: Reference frame. If not specified, Sun is used. -r correction: Correction of light time or abberation.
""" SPICE BC file dumping tool
USAGE: spice_bcdump -f frame -c center object t0 t1 dt_sec kernel0 [kernel1 ...]
-f frame: Reference frame. If not specified, J2000 is used.
-c center: Reference frame. If not specified, Sun is used.
-r correction: Correction of light time or abberation.
"""
import sys
import datetime
import dateutil.parser
from optparse import OptionParser
from irfpy.util import utc
from irfpy.spice import spice
def main(obj, t0, t1, dt, klist, frame, center, correction):
for k in klist:
spice.furnsh(klist)
try:
obj_int = int(obj)
except ValueError:
obj_int = spice.bodn2c(obj)
print('# {} -> {}'.format(obj, obj_int))
try:
center_int = int(center)
except ValueError:
center_int = spice.bodn2c(center)
print("# {} -> {}".format(center, center_int))
for t in utc.trange(t0, t1, dt):
et = spice.str2et(t.strftime('%FT%T.%f'))
# st, lt = spice.spkezr(obj, et, frame, correction, center)
st, lt = spice.spkez(obj_int, et, frame, correction, center_int)
print(t.strftime('%FT%T.%f'), et, st[0], st[1], st[2], st[3], st[4], st[5])
def argmain():
usage = "usage: %prog [options] object t0 t1 dt_sec kernel0 [kernel1 ...]"
parser = OptionParser(usage)
parser.add_option("-f", "--frame", dest="frame",
help="Reference frame. J2000 is default", default='J2000')
parser.add_option("-c", "--center",
help="Center of the object. Sun is default",
action="store", dest="center", default='Sun')
parser.add_option("-r", "--correction",
action="store", dest="correction",
help="Correction. None is default.", default='None')
(options, args) = parser.parse_args()
if len(args) < 5:
parser.error("incorrect number of arguments")
obj = args[0]
t0 = dateutil.parser.parse(args[1])
t1 = dateutil.parser.parse(args[2])
dt = datetime.timedelta(seconds=float(args[3]))
klist = args[4:]
print('# ' + str(options))
print('# ' + str(args))
main(obj, t0, t1, dt, klist, options.frame, options.center, options.correction)
if __name__ == '__main__':
argmain()