astropy / astroquery

Functions and classes to access online data resources. Maintainers: @keflavich and @bsipocz and @ceb8
http://astroquery.readthedocs.org/en/latest/
BSD 3-Clause "New" or "Revised" License
706 stars 399 forks source link

Horizons query fails for mysterious reason related to significant figures #1978

Closed davetyp closed 2 years ago

davetyp commented 3 years ago

The code below will raise an error. However, if any of the contants (jdut, lat, lon, elevation) to have merely one less place past the decimal point, the result is returned just fine. The URI for the code below returns a valid result when pasted into a web browser. However, the raw_response does not match what is received in a web browser. Seems therefore to be an astroquery parsing issue.
NOTE: this code works perfectly fine for many other jdut value (with 9 places past the decimal) with the observatory constants of the same precision as shown here. Out of ~207,000 calls made to astroquery, only this specific combination of values made it choke. Very odd. Installed version of astropy is 0.4.2.dev0, using Python 3.8.3 on Win7 x64.

from astroquery.jplhorizons import Horizons

observatory = {'lat': 29.836944,
               'lon': -82.621333,
               'elevation': 0.018}

#jdut = 2471724.1487055495  Throws an error
#jdut = 2471724.148705549    Works fine

jdut = 2471724.1487055495

#505 = Jupiter V (Amalthea) body center
ama = Horizons(id='505',
               id_type='majorbody',
               location=observatory,
               epochs=[jdut])

eph_ama = ama.ephemerides(quantities='14')

print(eph_ama['datetime_jd'][0],
      eph_ama['datetime_str'][0],
      eph_ama['PDObsLon'][0])

When run under Python 3.8.3 on Win7 x64, that code using those specific lat, lon alt, and JD values throws the following error:

Traceback (most recent call last):
  File "N:/Documents/get_jpl_horizons_eph_test2.py", line 18, in <module>
    eph_ama = ama.ephemerides(quantities='14')
  File "C:\Program Files\Python38\lib\site-packages\astroquery\utils\class_or_instance.py", line 25, in f
    return self.fn(obj, *args, **kwds)
  File "C:\Program Files\Python38\lib\site-packages\astroquery\utils\process_asyncs.py", line 29, in newmethod
    result = self._parse_result(response, verbose=verbose)
  File "C:\Program Files\Python38\lib\site-packages\astroquery\jplhorizons\core.py", line 1296, in _parse_result
    data = self._parse_horizons(response.text)
  File "C:\Program Files\Python38\lib\site-packages\astroquery\jplhorizons\core.py", line 1188, in _parse_horizons
    raise ValueError(('Query failed without known error message; '
ValueError: Query failed without known error message; received the following response:
WLDINI: missing required file EOPFIL

 ERROR in VLRDC: Var not declared: IP_ADDR

!$$SOF
TABLE_TYPE = OBSERVER
QUANTITIES = '14'
COMMAND = "505"
SOLAR_ELONG = "0,180"
LHA_CUTOFF = 0
CSV_FORMAT = YES
CAL_FORMAT = BOTH
ANG_FORMAT = DEG
APPARENT = AIRLESS
REF_SYSTEM = J2000
EXTRA_PREC = NO
CENTER = coord@399
COORD_TYPE = GEODETIC
SITE_COORD = '-82.621333,29.836944,0.018000'
TLIST = 2471724.1487055495
SKIP_DAYLT = NO
bsipocz commented 2 years ago

Major changes has been made to the horizons module, and now the above example works for for me without issues. Feel free reopen is you still run into it.