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

JPL Horizonts Wildcard search #1485

Open LMNT1 opened 5 years ago

LMNT1 commented 5 years ago

Hello, first i want to gratulate you - this is a very nice piece of software.

My Issue ist easy: The wildcard search (id='*') Returns multiple results. This is a Feature not an error, but you are raising it as Error. Any way to get the table with search as result and not from the error Text? Greetings

mommermi commented 5 years ago

Hi @LMNT1, I checked on your issue and get the following behavior:

from astroquery.jplhorizons import Horizons
obj = Horizons(id='1289*')
obj.ephemerides()

Traceback (most recent call last): File "", line 1, in File "/home/mommermi/lowell/software/astroquery/astroquery/utils/class_or_instance.py", line 25, in f return self.fn(obj, *args, **kwds) File "/home/mommermi/lowell/software/astroquery/astroquery/utils/process_asyncs.py", line 29, in newmethod result = self._parse_result(response, verbose=verbose) File "/home/mommermi/lowell/software/astroquery/astroquery/jplhorizons/core.py", line 1275, in _parse_result data = self._parse_horizons(response.text) File "/home/mommermi/lowell/software/astroquery/astroquery/jplhorizons/core.py", line 1143, in _parse_horizons '\n'.join(src[idx + 2:end_idx]))) ValueError: Ambiguous target name; provide unique id: Record # Epoch-yr >MATCH DESIG< Primary Desig Name


    1289            2001289        1933 QR         Kutaissi
    6952            3001289        1986 JT         Niccolo
   11289            2011289        1991 PA2        Frescobaldi
   12102            3012892        1998 JB4        Piazzolla
   12103            3012896        1998 KL         1998 KL
   12527            3012890        1998 JE3        Anneraugh
   12859            3012899        1998 KK1        Marlamoore
   12890            2012890        1998 QG43       1998 QG43
   12891            2012891        1998 QH51       1998 QH51
   12892            2012892        1998 QE52       1998 QE52
   12893            2012893        1998 QS55       Mommert
   12894            2012894        1998 QN73       1998 QN73
   12895            2012895        1998 QO99       Balbastre
   12896            2012896        1998 QV102      Geoffroy
   12897            2012897        1998 RY5        Bougeret
   12898            2012898        1998 RK6        Mignard

...

It returns both a ValueError and a table of potential objects. I am somewhat indifferent about what should really happen if the targetname is ambiguous (e.g., by using a wildcard symbol). There are the following options: 1) the current solution that raises an error and provides a human-readable description 2) no error, but return an astropy Table of targetnames 3) raise a warning and return a Table

The downside of 2) would be that the user gets a table and might not be aware that something is wrong (e.g., no ephemerides could be obtained).

As I said, I am somewhat indifferent and leave this decision to @keflavich and/or @bsipocz.

Thanks for raising this issue!

LMNT1 commented 5 years ago

Hi @mommermi, since i'm using the to_pandas function 2) would be nice, but maybe in a seperate field to get it from. Thanks