Example in astroquery docs for making Horizons ephemerides generates errors

I was trying to get some data on the Sun and Moon from the day of the eclipse. I was relying on some of the examples here:

and my script kept generating an error.

So I tried copying the original script from the page, with one additional line, and kept getting an error.

from astroquery.jplhorizons import Horizons
import astropy.units as u
statue_of_liberty = {'lon': -74.0466891 * u.deg,
                     'lat': 40.6892534 * u.deg,
                     'elevation': 0.093 * u.km}
obj = Horizons(id='Ceres',
eph = obj.ephemerides()

The error is

Cannot read coordinate triplet, ? or ?! for help

What am I doing wrong?

astropy 5.1
astroquery 0.4.6

You’re getting tripped up because you are running the stable release of astroquery (0.4.6) but looking at the documentation for the development branch, which is what is shown by default online. Since 0.4.6, there’s been a change to make location unit-aware (see Allow astropy Quantity in query locations by mkelley · Pull Request #2746 · astropy/astroquery · GitHub).

If you look at the documentation for 0.4.6 (as of this writing, JPL Horizons Queries (astroquery.jplhorizons/astroquery.solarsystem.jpl.horizons) — astroquery v0.4.6), you can see that all you need to do to fix your script is to remove the units (i.e., u.deg and u.km).

1 Like


Thanks Ayshih!