Astroquery.jplhorizons output differs from Horizons webpage

I’m trying to get the RA/Dec of an asteroid from the position of a satellite. I have the satellite’s lat/lon/altitude, and I get the asteroid position from astroquery’s jpl horizons package. The standalone test script is below:

#!/usr/bin/env python
from astropy      import units
from astropy.time import Time
from astropy.coordinates import SkyCoord, EarthLocation, AltAz
from astropy.coordinates.builtin_frames import CustomBarycentricEcliptic
from astroquery.jplhorizons import Horizons

# asteroid info
asteroid = '2020 CD3'

# satellite info
lat = 0.23705460  # deg
lon = -178.68626404 # deg
alt = 539149.436813 # meters
tim = Time.strptime( '2015.05.28 00:26:56', '%Y.%m.%d %H:%M:%S' )
ear = EarthLocation(lat=lat, lon=lon, height=alt )
aa  = AltAz( location=ear, obstime=tim )

# JPL's Horizons().vectors() xyz plane
# see https://github.com/astropy/astroquery/issues/2127
JPLF = CustomBarycentricEcliptic( obliquity=84381.448 * units.arcsec )

# get the xyz coordinates of the asteroid from 
# JPL's Horizons service, then use astropy to 
# tranform it to FK4
#
# Warning, this downloads data from a server, so
# please avoid hammering the server with requests
#
jpl = Horizons( id=asteroid, id_type='smallbody', location='@0', epochs=[tim.jd] )
vec = jpl.vectors()
j   = SkyCoord( x=vec['x'], y=vec['y'], z=vec['z'], unit='au', frame=JPLF, representation_type='cartesian' )
j   = j.transform_to( aa ).transform_to('fk5')
print()
print('     FK5 (deg)            RA         Dec')
print('vectors()               : %.6f %.6f' % ( j.ra.degree[0], j.dec.degree[0] ) )

tab = jpl.vectors(refplane='earth')
c = SkyCoord( tab['x'].quantity, tab['y'].quantity, tab['z'].quantity, representation_type='cartesian', frame='icrs', obstime=tim )
c = c.transform_to(aa).transform_to('fk5')
print('vectors(refplane=earth) : %.6f %.6f' % ( c.ra.degree, c.dec.degree ) )


eph = jpl.ephemerides()
print('ephemerides()           : %.6f %.6f' % ( eph['RA'][0],eph['DEC'][0] ) )

When I run the test script, astroquery.jplhorizons.Horizons() says the asteroid should be at RA/Dec ~(244,-21):

      FK5 (deg)            RA         Dec
vectors()               : 244.665601 -21.016988
vectors(refplane=earth) : 244.665601 -21.016988
ephemerides()           : 244.660500 -21.016170

but on the Horizons webpage, when you set:

Target Body: (2020 CD3)
Observer Location: -178.68626404°E, 0.23705460°N, 539149.436813 m
Time Specification: Start=2015-05-28 00:27 UT , Stop=2015-05-28 04:27, Step=1 (hours)

it says the asteroid RA/Dec is at:

269.91184  33.68373

The full web output is:

*******************************************************************************
JPL/HORIZONS                     (2020 CD3)                2021-Sep-27 15:53:02
Rec #:50504613 (+COV) Soln.date: 2021-Jun-25_15:07:42    # obs: 128 (2018-2020)
 
IAU76/J2000 helio. ecliptic osc. elements (au, days, deg., period=Julian yrs):
 
  EPOCH=  2458914.5 ! 2020-Mar-06.00 (TDB)         Residual RMS= .078773
   EC= .03494529757096312  QR= .9863971818171792   TP= 2458866.3996462021
   OM= 134.7432090092998   W=  342.2597100247675   IN= .7388576324362984
   A= 1.022115305313184    MA= 45.87779192987005   ADIST= 1.057833428809189
   PER= 1.03338            N= .9537932059999999    ANGMOM= .017380651
   DAN= .98798             DDN= 1.05602            L= 117.0043116
   B= -.2251263            MOID= .00224417         TP= 2020-Jan-17.8996462021
 
Asteroid physical parameters (km, seconds, rotational period in hours):
   GM= n.a.                RAD= n.a.               ROTPER= n.a.
   H= 31.8                 G= .150                 B-V= n.a.
                           ALBEDO= n.a.            STYP= n.a.
 
Asteroid non-gravitational force model (AMRAT= m^2/kg;A1,A2,A3=au/d^2;R0=au):
   AMRAT=  0.
   A1= 1.356929074973E-10  A2= 0.                  A3= 0.
 Non-standard or simulated/proxy model:
   ALN=  1.            NK=  0.       NM=  2.       NN=  0.       R0=  1.
 
ASTEROID comments: 
1: soln ref.= JPL#27, OCC=0
2: source=ORB
*******************************************************************************


*******************************************************************************
Ephemeris / API_USER Mon Sep 27 15:53:02 2021 Pasadena, USA      / Horizons    
*******************************************************************************
Target body name: (2020 CD3)                      {source: JPL#27}
Center body name: Earth (399)                     {source: DE441}
Center-site name: (user defined site below)
*******************************************************************************
Start time      : A.D. 2015-May-28 00:27:00.0000 UT      
Stop  time      : A.D. 2015-May-28 04:27:00.0000 UT      
Step-size       : 60 minutes
*******************************************************************************
Target pole/equ : No model available
Target radii    : (unavailable)                                                
Center geodetic : 181.313736,0.23705460,539.14944 {E-lon(deg),Lat(deg),Alt(km)}
Center cylindric: 181.313736,6917.22760,28.442729 {E-lon(deg),Dxy(km),Dz(km)}
Center pole/equ : High-precision EOP model        {East-longitude positive}
Center radii    : 6378.1 x 6378.1 x 6356.8 km     {Equator, meridian, pole}    
Target primary  : Sun
Vis. interferer : MOON (R_eq= 1737.400) km        {source: DE441}
Rel. light bend : Sun, EARTH                      {source: DE441}
Rel. lght bnd GM: 1.3271E+11, 3.9860E+05 km^3/s^2                              
Small-body perts: Yes                             {source: SB441-N16}
Atmos refraction: NO (AIRLESS)
RA format       : DEG
Time format     : CAL 
EOP file        : eop.210926.p211220                                           
EOP coverage    : DATA-BASED 1962-JAN-20 TO 2021-SEP-26. PREDICTS-> 2021-DEC-19
Units conversion: 1 au= 149597870.700 km, c= 299792.458 km/s, 1 day= 86400.0 s 
Table cut-offs 1: Elevation (-90.0deg=NO ),Airmass (>38.000=NO), Daylight (NO )
Table cut-offs 2: Solar elongation (  0.0,180.0=NO ),Local Hour Angle( 0.0=NO )
Table cut-offs 3: RA/DEC angular rate (     0.0=NO )                           
*******************************************************************************
Initial IAU76/J2000 heliocentric ecliptic osculating elements (au, days, deg.):
  EPOCH=  2458914.5 ! 2020-Mar-06.00 (TDB)         Residual RMS= .078773       
   EC= .03494529757096312  QR= .9863971818171792   TP= 2458866.3996462021      
   OM= 134.7432090092998   W=  342.2597100247675   IN= .7388576324362984       
  Equivalent ICRF heliocentric cartesian coordinates (au, au/d):
   X=-9.675822914533228E-01  Y= 2.212974108216997E-01  Z= 1.031890496759188E-01
  VX=-4.692966798948430E-03 VY=-1.547085528646655E-02 VZ=-6.494577482405959E-03
Asteroid physical parameters (km, seconds, rotational period in hours):        
   GM= n.a.                RAD= n.a.               ROTPER= n.a.                
   H= 31.8                 G= .150                 B-V= n.a.                   
                           ALBEDO= n.a.            STYP= n.a.                  
Asteroid non-gravitational force model (AMRAT= m^2/kg;A1,A2,A3=au/d^2;R0=au):  
   AMRAT=  0.                                                                  
   A1= 1.356929074973E-10  A2= 0.                  A3= 0.                      
 Non-standard or simulated/proxy model:                                        
   ALN=  1.            NK=  0.       NM=  2.       NN=  0.       R0=  1.       
*******************************************************************************
 Date__(UT)__HR:MN     R.A.___(ICRF)___DEC
******************************************
$SOE
 2015-May-28 00:27 *m  269.91184  33.68373
 2015-May-28 01:27 *m  269.95547  33.68764
 2015-May-28 02:27 *m  269.99998  33.70396
 2015-May-28 03:27 *m  270.03839  33.73238
 2015-May-28 04:27 *m  270.06412  33.77181
$EOE
*******************************************************************************
Column meaning:
 
TIME

  Times PRIOR to 1962 are UT1, a mean-solar time closely related to the
prior but now-deprecated GMT. Times AFTER 1962 are in UTC, the current
civil or "wall-clock" time-scale. UTC is kept within 0.9 seconds of UT1
using integer leap-seconds for 1972 and later years.

  Conversion from the internal Barycentric Dynamical Time (TDB) of solar
system dynamics to the non-uniform civil UT time-scale requested for output
has not been determined for UTC times after the next July or January 1st.
Therefore, the last known leap-second is used as a constant over future
intervals.

  Time tags refer to the UT time-scale conversion from TDB on Earth
regardless of observer location within the solar system, although clock
rates may differ due to the local gravity field and no analog to "UT"
may be defined for that location.

  Any 'b' symbol in the 1st-column denotes a B.C. date. First-column blank
(" ") denotes an A.D. date. Calendar dates prior to 1582-Oct-15 are in the
Julian calendar system. Later calendar dates are in the Gregorian system.

  NOTE: "n.a." in output means quantity "not available" at the print-time.
 
SOLAR PRESENCE (OBSERVING SITE)
  Time tag is followed by a blank, then a solar-presence symbol:

        '*'  Daylight (refracted solar upper-limb on or above apparent horizon)
        'C'  Civil twilight/dawn
        'N'  Nautical twilight/dawn
        'A'  Astronomical twilight/dawn
        ' '  Night OR geocentric ephemeris

LUNAR PRESENCE (OBSERVING SITE)
  The solar-presence symbol is immediately followed by a lunar-presence symbol:

        'm'  Refracted upper-limb of Moon on or above apparent horizon
        ' '  Refracted upper-limb of Moon below apparent horizon OR geocentric
             ephemeris
 
 'R.A.___(ICRF)___DEC' =
  Astrometric right ascension and declination of the target center with
respect to the observing site (coordinate origin) in the reference frame of
the planetary ephemeris (ICRF). Compensated for down-leg light-time delay
aberration.

  Units: RA  in decimal degrees,  ddd.fffff{ffff}
         DEC in decimal degrees,  sdd.fffff{ffff}


 Computations by ...
     Solar System Dynamics Group, Horizons On-Line Ephemeris System
     4800 Oak Grove Drive, Jet Propulsion Laboratory
     Pasadena, CA  91109   USA
     Information  : https://ssd.jpl.nasa.gov/
     Documentation: https://ssd.jpl.nasa.gov/?horizons_doc
     Connect      : https://ssd.jpl.nasa.gov/?horizons (browser)
                    telnet ssd.jpl.nasa.gov 6775       (command-line)
                    e-mail command interface available
                    Script and CGI interfaces available
     Author       : Jon.D.Giorgini@jpl.nasa.gov

*******************************************************************************

This question is mirrored from an astropy issue I created as well:
JPL Horizons: differing results between python and web output · Issue #2159 · astropy/astroquery · GitHub

So,
a) why is there such a large mismatch between the python and webpage RADecs? My first instinct is that I entered something incorrectly in the web interface, but I’m not sure.
b) in the test script, why is the ephemerides() RADec different from the vectors() RADec?

1 Like

I think you got all of the above answered in the Astropy issue, but for anyone else:
a) The origin isn’t the same in the two cases because location='@0' in the Python script means the solar-system barycenter (SSB), which is not what is desired.
b) The differences are (1) the ephemerides() and vectors() both accept the JD time format, but the former defaults to UTC time scale and the latter is required to be in TDB time scale, so feeding in the same JD value to both actually results in non-equivalent times, and (2) ephemerides() is corrected for light travel time (i.e., planetary aberration) while vectors() is pure geometric.