Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ sbpy.dynamics

- Added missing `sbpy.dynamics.state.State.to_ephem`. [#434]

- Fixed conversion between spherical and cartesian representations in
`sbpy.dynamics.state.State.from_ephem`. [#452]

sbpy.spectroscopy
^^^^^^^^^^^^^^^^^

Expand Down
2 changes: 1 addition & 1 deletion sbpy/dynamics/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ def from_ephem(
c: cr.SphericalRepresentation = cr.SphericalRepresentation(
eph["ra"], eph["dec"], eph["Delta"]
)
d: cr.SphericalDifferential = cr.SphericalDifferential(
d = cr.SphericalCosLatDifferential(
eph["RA*cos(Dec)_rate"],
eph["Dec_rate"],
eph["deltadot"],
Expand Down
24 changes: 13 additions & 11 deletions sbpy/dynamics/tests/test_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@ def test_from_states(self):
def test_from_ephem(self):
"""Test Ephem to State.

import numpy as np
from astropy.time import Time
from astroquery.jplhorizons import Horizons
import spiceypy
Expand All @@ -495,18 +496,19 @@ def test_from_ephem(self):
# au, rad, and rad/day
sph = spiceypy.xfmsta(rec, "rectangular", "latitudinal", " ")

# xfmsta returns dra, but we will need dra*cos(dec)
delta, ra, dec, deldot, dra, ddec = sph

print(rec[:3])
print(rec[3:])
print(np.degrees((ra, dec)), "deg,", delta, "au")
print(np.degrees((dra, ddec)), "deg/day,", deldot, "au/day")
print(np.degrees((dra * np.cos(dec), ddec)), "deg/day,", deldot, "au/day")

"""

r = [0.5849871061746752, -1.112950265888228, 1.957197574037426] * u.au
r = [0.5849901313190226, -1.112942283220293, 1.957189523210894] * u.au
v = (
[-0.0008339472072142703, 0.01387010312203588, -0.006617657384488537]
[-0.0008339191946335428, 0.01387013925942148, -0.006617666089656045]
* u.au
/ u.day
)
Expand All @@ -527,7 +529,7 @@ def test_from_ephem(self):
state = State.from_ephem(eph)

# and with the frame
state = State.from_ephem(eph, frame="icrs")
state = State.from_ephem(eph, frame="icrs")[0]
assert u.allclose(state.r, r)
assert u.allclose(state.v, v)
assert np.isclose((state.t - t).jd, 0)
Expand All @@ -542,16 +544,16 @@ def test_from_ephem(self):
# barycenter
eph = Ephem.from_dict(
{
"ra": -62.27275959 * u.deg,
"dec": 57.28285294 * u.deg,
"delta": 2.3262610671524557 * u.au,
"RA*cos(Dec)_rate": 0.26043265 * u.deg / u.day,
"Dec_rate": 0.17436216 * u.deg / u.day,
"delta_rate": -0.012413330003023705 * u.au / u.day,
"ra": -62.27246831248106 * u.deg,
"dec": 57.28286302297011 * u.deg,
"delta": 2.3262512352036984 * u.au,
"RA*cos(Dec)_rate": 0.14076500428418215 * u.deg / u.day,
"Dec_rate": 0.17436263017100262 * u.deg / u.day,
"delta_rate": -0.012413330622647187 * u.au / u.day,
"date": t,
},
)
state = State.from_ephem(eph, "icrs")
state = State.from_ephem(eph, "icrs")[0]
assert u.allclose(state.r, r)
assert u.allclose(state.v, v)
assert np.isclose((state.t - t).jd, 0)
Expand Down
Loading