I am trying to get the vector data for Earth using Astroquery's Horizons Class. I have the following code:
from astroquery.jplhorizons import Horizons
import numpy as np
earth = Horizons(id=399, epochs = {'start':'2005-06-20', 'stop':'2005-06-21','step':'1d'})
earthVectors = earth.vectors()
earthX = earthVectors['x'].data # X is in AU
au2km = 149_597_870.7
earthXkm = earthX * au2km # X is in km
which returns earthXkm = [-3429775.6506088143 -899299.0538429054]
in kilometers.
Getting this information directly from JPL Hoizons gives [-2793030.0, -2627770.0]
kilometers.
There is a large discrepancy here and this is the same for all the values in the astropy table. I would also not expect the data to vary as much in one day as that from the astroquery result.
Is there an error in my code, or does the horizons vectors() method not work as intended?
After further analysis I have found the cause of the discrepancy. Astroquery's Horizon Class uses a default coordinate system centered at the center of the sun for vectors. The Horizon's app; however, using the Solar System barycenter as the default coordinate origin. Using the location attribute set to the solar system barycenter fixes the issue.
location='@ssb'
orlocation='500@0'