sbpy icon indicating copy to clipboard operation
sbpy copied to clipboard

Orbit type lost after Orbit.oo_transform

Open mkelley opened this issue 3 years ago • 1 comments

from astropy.time import Time
from sbpy.data import Orbit

orbit = Orbit.from_mpc('2P')
orbit['targetname'] = '2P'
orbit['orbtype'] = 'COM'   # cometary style orbit with q, Tp (otherwise use KEP with a, M)
orbit['H'] = 15 * u.mag
orbit['G'] = 0.15
print(orbit['orbtype'])

# propagate the orbit forward to 2026 with openorb
future_orbit = orbit.oo_propagate(Time('2026-06-06'))
print(future_orbit['orbtype'])

Output

orbtype
-------
    COM
orbtype
-------
    2.0

Instead of 2.0, it should have been COM.

mkelley avatar Jun 03 '22 22:06 mkelley

I noticed this recently too because I was trying to propagate an orbit to multiple Time objects and it would just hang mysteriously:

from astropy.time import Time
from sbpy.data import Orbit

orbit = Orbit.from_horizons('Ceres')
orbit["orbtype"] = "KEP"
print(orbit['orbtype'])

# propagate the orbit forward to 2026 with openorb
times = Time(['2024-06-06','2025-06-06','2026-06-06'])
future_orbit = orbit.oo_propagate(times)
print(future_orbit['orbtype'])

Silly hack is to do one timestep at a time and drop (or overwrite) the orbtype:

# propagate the orbit forward to 2026 with openorb
times = Time(['2024-06-06','2025-06-06','2026-06-06'])
for i in range(len(times)):
    print(i)
    future_orbit = orbit.oo_propagate(times[i]) # propagate the orbit one time step
    del future_orbit.table["orbtype"] # orbtype is added as int, sbpy freaks out so delete the orbtype and then _to_oo works it out
    statevec = future_orbit.oo_transform('CART') # transform from orbital elements to cartesian
    print(statevec.table[["epoch","x","y","z"]])

jrob93 avatar Jun 16 '22 13:06 jrob93