NASA-Planetary-Science / sbpy

A Python package for small bodies research
https://sbpy.org/
Other
67 stars 34 forks source link

Impossible to understand Horizons errors in Ephem.from_horizons #78

Closed mkelley closed 5 years ago

mkelley commented 5 years ago
>>> from sbpy.data import Ephem
>>> h = Ephem.from_horizons('2P', closest_apparition=True)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-20-3ed486ce555c> in <module>()
----> 1 h = Ephem.from_horizons('2P', closest_apparition=True)

/home/msk/local/lib/python3.6/site-packages/sbpy-0.0.dev296-py3.6.egg/sbpy/data/ephem.py in from_horizons(cls, targetids, id_type, epochs, location, **kwargs)
    108             obj = Horizons(id=targetid, id_type=id_type,
    109                            location=location, epochs=epochs)
--> 110             eph = obj.ephemerides(**kwargs)
    111 
    112             # workaround for current version of astroquery to make

/home/msk/local/lib/python3.6/site-packages/astroquery-0.3.9.dev4961-py3.6.egg/astroquery/utils/class_or_instance.py in f(*args, **kwds)
     23         def f(*args, **kwds):
     24             if obj is not None:
---> 25                 return self.fn(obj, *args, **kwds)
     26             else:
     27                 return self.fn(cls, *args, **kwds)

/home/msk/local/lib/python3.6/site-packages/astroquery-0.3.9.dev4961-py3.6.egg/astroquery/utils/process_asyncs.py in newmethod(self, *args, **kwargs)
     27             if kwargs.get('get_query_payload') or kwargs.get('field_help'):
     28                 return response
---> 29             result = self._parse_result(response, verbose=verbose)
     30             self.table = result
     31             return result

/home/msk/local/lib/python3.6/site-packages/astroquery-0.3.9.dev4961-py3.6.egg/astroquery/jplhorizons/core.py in _parse_result(self, response, verbose)
   1221             return None
   1222         else:
-> 1223             data = self._parse_horizons(response.text)
   1224 
   1225         return data

/home/msk/local/lib/python3.6/site-packages/astroquery-0.3.9.dev4961-py3.6.egg/astroquery/jplhorizons/core.py in _parse_horizons(self, src)
   1117                                  err_msg)
   1118             else:
-> 1119                 raise ValueError(('Query failed without error message; '
   1120                                   'check URI for more information'))
   1121         # strip whitespaces from column labels

ValueError: Query failed without error message; check URI for more information

No object is returned, so a user cannot follow up on the error message without running a debugger.

mkelley commented 5 years ago

@mommermi I see a few approaches to fix it: request and print the data from the URI, catch the exception and add the URI to the message, or edit astroquery and add the URI to the exception.

mommermi commented 5 years ago

@mkelley Good point! How about this as an error message:

RuntimeError: Error raised by astroquery.jplhorizons: Query failed without error message; check URI for more information The following query was attempted: https://ssd.jpl.nasa.gov/horizons_batch.cgi?batch=1&TABLE_TYPE=OBSERVER&QUANTITIES=%271%2C2%2C3%2C4%2C5%2C6%2C7%2C8%2C9%2C10%2C11%2C12%2C13%2C14%2C15%2C16%2C17%2C18%2C19%2C20%2C21%2C22%2C23%2C24%2C25%2C26%2C27%2C28%2C29%2C30%2C31%2C32%2C33%2C34%2C35%2C36%2C37%2C38%2C39%2C40%2C41%2C42%2C43%27&COMMAND=%222P%3B+CAP%3B%22&SOLAR_ELONG=%220%2C180%22&LHA_CUTOFF=0&CSV_FORMAT=YES&CAL_FORMAT=BOTH&ANG_FORMAT=DEG&APPARENT=AIRLESS&REF_SYSTEM=J2000&CENTER=%27568%27&START_TIME=%222018-10-22%22&STOP_TIME=%222018-10-26%22&STEP_SIZE=%221d%22&SKIP_DAYLT=NO

mkelley commented 5 years ago

Looks good.