Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Orbit type lost after Orbit.oo_transform #341

Open
mkelley opened this issue Jun 3, 2022 · 1 comment
Open

Orbit type lost after Orbit.oo_transform #341

mkelley opened this issue Jun 3, 2022 · 1 comment
Assignees

Comments

@mkelley
Copy link
Member

mkelley commented Jun 3, 2022

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 mkelley added potential bug automated label to indicate issue reports bug data and removed potential bug automated label to indicate issue reports labels Jun 3, 2022
@mkelley mkelley self-assigned this Jun 4, 2022
@jrob93
Copy link

jrob93 commented Jun 16, 2022

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"]])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants