High-level problem description
Hi, I have been using sbpy to generate synchrones and syndynes and noticed some discrepancy in the creation of State objects that I could not find any explanation for.
What did you do?
Basically, I tried creating a State object for my comet in two different ways:
- I used astroquery to obtain the cartesian heliocentric coordinates of the comet directly from JPL Horizons via Horizons(...).vectors().
- I used the sbpy convenience functions sbpy.data.from_horizons() and created a State object from that using sbpy.dynamics.state.from_ephem()
Example:
from astroquery.jplhorizons import Horizons
from sbpy.data import Ephem
from sbpy.dynamics import State
from astropy.time import Time
import astropy.units as u
epoch=Time(2459946.0,format='jd')
# using astroquery
q = Horizons(id='311P', location='@sun', epochs=epoch, id_type='smallbody')
v = q.vectors(refplane='earth')
r = u.Quantity([v['x'][0], v['y'][0], v['z'][0]], u.au)
rdot = u.Quantity([v['vx'][0], v['vy'][0], v['vz'][0]], u.au / u.day)
comet = State(r,rdot,epoch,frame='heliocentriceclipticiau76')
print(comet)
# using sbpy functions
eph = Ephem.from_horizons("311P",
epochs=epoch,
location='@sun',
id_type="smallbody")
comet = State.from_ephem(eph,frame='heliocentriceclipticiau76')[0]
print(comet)
Output:
<State (<HeliocentricEclipticIAU76 Frame (obstime=2459946.0)>):
r
[ 1.16927516 -1.85001645 -0.72280141] AU
v
[15.28357029 9.8210348 5.85998821] km / s
t
2459946.0>
<State (<HeliocentricEclipticIAU76 Frame (obstime=2459946.0)>):
r
[ 1.16916454 -1.85008735 -0.72284385] AU
v
[14.56214698 10.21163345 3.68954787] km / s
t
2459946.0>
What did you expect?
The same state vector for both methods.
What did really happen?
The resulting state vectors are quite similar but not identical in their positions (difference about 0.01%), but the velocity vectors differ quite drastically. These differences in the state vectors change the resulting Synchrones and Syndynes significantly. In my case, method 1 yielded the physically plausible projected synchrones and syndynes for my observations (unrelated to the example given here).
When checking the source code of from_ephem(), I saw that the cartesian coordinates are calculated from JPL Horizons' ephemerides using astropy functions (SphericalRepresentation, SphericalDifferential,...). It seems as if these astropy transformations return different cartesian vectors than Horizons gives out when using its vector mode. If I am missing something, maybe an additional input to the from_ephem() function or some frame transformation that I didn't know I have to apply, I would be happy about any hint. Otherwise, since sbpy's from_horizons() currently uses astroquery.jplhorizons.HorizonsClass.ephemerides(), it might also make sense to include another convenience function using astroquery.jplhorizons.HorizonsClass.vectors() for direct access to Horizons' state vectors.
Provide information on your environment:
operating system and version: Debian GNU/Linux 12
sbpy version: 0.6.0
astropy version: 7.2.0
numpy version: 1.26.4
Thank you for your work on sbpy!
High-level problem description
Hi, I have been using sbpy to generate synchrones and syndynes and noticed some discrepancy in the creation of State objects that I could not find any explanation for.
What did you do?
Basically, I tried creating a State object for my comet in two different ways:
Example:
Output:
<State (<HeliocentricEclipticIAU76 Frame (obstime=2459946.0)>):
r
[ 1.16927516 -1.85001645 -0.72280141] AU
v
[15.28357029 9.8210348 5.85998821] km / s
t
2459946.0>
<State (<HeliocentricEclipticIAU76 Frame (obstime=2459946.0)>):
r
[ 1.16916454 -1.85008735 -0.72284385] AU
v
[14.56214698 10.21163345 3.68954787] km / s
t
2459946.0>
What did you expect?
The same state vector for both methods.
What did really happen?
The resulting state vectors are quite similar but not identical in their positions (difference about 0.01%), but the velocity vectors differ quite drastically. These differences in the state vectors change the resulting Synchrones and Syndynes significantly. In my case, method 1 yielded the physically plausible projected synchrones and syndynes for my observations (unrelated to the example given here).
When checking the source code of from_ephem(), I saw that the cartesian coordinates are calculated from JPL Horizons' ephemerides using astropy functions (SphericalRepresentation, SphericalDifferential,...). It seems as if these astropy transformations return different cartesian vectors than Horizons gives out when using its vector mode. If I am missing something, maybe an additional input to the from_ephem() function or some frame transformation that I didn't know I have to apply, I would be happy about any hint. Otherwise, since sbpy's from_horizons() currently uses astroquery.jplhorizons.HorizonsClass.ephemerides(), it might also make sense to include another convenience function using astroquery.jplhorizons.HorizonsClass.vectors() for direct access to Horizons' state vectors.
Provide information on your environment:
operating system and version: Debian GNU/Linux 12
sbpy version: 0.6.0
astropy version: 7.2.0
numpy version: 1.26.4
Thank you for your work on sbpy!