NASA-Planetary-Science/sbpy

Observations not found for numerous objects which are in the MPC database

monocongo opened this issue · 2 comments

High-level problem description
There are many objects for which there are observations in the MPC dataset but when I use the Obs class to query for these I get errors indicating that I've used an invalid designation.

For example:

RuntimeError: No data queried. Are the target identifiers correct?

However the designations can be used successfully to retrieve orbit and observations from the MPC database search tool (see this), so it seems that either Obs.from_mpc or the wrapped astroquery.mpc.MPCClass.get_observations is where the designation is somehow being mangled before passing it off to the MPC search tool, if that's in fact what's going on here.

What did you do?
I've used the Obs.from_mpc function to successfully retrieve observations for around 300 objects, but I get errors for another ~2000 objects. For example, the following unpacked designations have been used which give the below error:

suspect_designations = [
'2008 JG', '2008 TY9', '2018 SG3', '2020 QD4', '2016 ND1', '2020 VN1', '2011 HN5',
]

The code below will cause the error when run in a Jupyter notebook cell:

from sbpy.data import Obs
desig = '2008 JG'
Obs.from_mpc(targetid=desig, id_type='asteroid designation', get_mpcformat=True)

What did you expect?
I expected to get the MPC observations for the object, as shown in the example below which is the result when using the designation '2010 JR34'

<QTable length=37>
                                      obs                                       
                                     str80                                      
--------------------------------------------------------------------------------
     K10J34R* C2010 05 07.22213 13 34 22.72 -15 22 09.6          19.7 Vr~0HJeG96
     K10J34R  C2010 05 07.22810 13 34 15.85 -15 21 57.5          20.2 Vr~0HJeG96
     K10J34R  C2010 05 07.23405 13 34 08.94 -15 21 45.5          20.2 Vr~0HJeG96
     K10J34R  C2010 05 07.23995 13 34 02.02 -15 21 33.1          20.4 Vr~0HJeG96
     K10J34R  C2010 05 07.25704 13 33 42.08 -15 20 56.7          20.4 Vr~0HJeG96
     K10J34R  C2010 05 07.25773 13 33 41.32 -15 20 55.7          20.8 Vr~0HJeG96
     K10J34R  C2010 05 07.25988 13 33 38.77 -15 20 51.2          20.7 Vr~0HJeG96
     K10J34R  C2010 05 07.26061 13 33 37.98 -15 20 49.2          20.2 Vr~0HJeG96
     K10J34R  C2010 05 07.26277 13 33 35.49 -15 20 44.8          21.3 Vr~0HJeG96
     K10J34R  C2010 05 07.26350 13 33 34.52 -15 20 43.1          20.4 Vr~0HJeG96
                                                                             ...
     K10J34R  C2010 05 08.41892 13 12 13.72 -14 23 12.6          20.2 Ro~0HJe474
     K10J34R  C2010 05 09.40890 12 50 43.43 -13 25 58.9          19.7 Ro~0HJe474
     K10J34R  C2010 05 09.41049 12 50 40.98 -13 25 52.5          19.9 Ro~0HJe474
     K10J34R  C2010 05 09.41207 12 50 38.52 -13 25 46.6          19.6 Ro~0HJe474
     K10J34R  C2010 05 10.21931 12 30 40.66 -12 36 26.8          20.2 Rc~0HJe926
     K10J34R  C2010 05 10.22271 12 30 34.63 -12 36 09.5          20.0 Rc~0HJe926
     K10J34R  C2010 05 10.22611 12 30 28.77 -12 35 52.5          20.6 Rc~0HJe926
     K10J34R  C2010 05 11.42052 11 57 12.19 -10 32 49.4          18.7 Ro~0HJe474
     K10J34R  C2010 05 11.42261 11 57 08.17 -10 32 35.7          20.0 Ro~0HJe474
     K10J34R  C2010 05 11.42468 11 57 04.11 -10 32 22.2          19.8 Ro~0HJe474

What did really happen?

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
File ~/git/sbpy/sbpy/data/obs.py:86, in Obs.from_mpc(cls, targetid, id_type, **kwargs)
     85 try:
---> 86     results = MPC.get_observations(targetid, id_type=id_type,
     87                                    **kwargs)
     88 except (RuntimeError, ValueError) as e:

File ~/miniconda3/envs/sbpydev/lib/python3.10/site-packages/astroquery/utils/class_or_instance.py:25, in class_or_instance.__get__.<locals>.f(*args, **kwds)
     24 if obj is not None:
---> 25     return self.fn(obj, *args, **kwds)
     26 else:

File ~/miniconda3/envs/sbpydev/lib/python3.10/site-packages/astroquery/utils/process_asyncs.py:29, in async_to_sync.<locals>.create_method.<locals>.newmethod(self, *args, **kwargs)
     28     return response
---> 29 result = self._parse_result(response, verbose=verbose)
     30 self.table = result

File ~/miniconda3/envs/sbpydev/lib/python3.10/site-packages/astroquery/mpc/core.py:1186, in MPCClass._parse_result(self, result, **kwargs)
   1185 if len(src) == 0:
-> 1186     raise RuntimeError(('No data queried. Are the target '
   1187                         'identifiers correct?'))
   1189 # return raw response if requested

RuntimeError: No data queried. Are the target identifiers correct?

During handling of the above exception, another exception occurred:

QueryError                                Traceback (most recent call last)
Input In [3], in <cell line: 4>()
      2 desig = '2008 JG'
      3 #desig = '2010 JR34'
----> 4 Obs.from_mpc(targetid=desig, id_type='asteroid designation', get_mpcformat=True)

File ~/git/sbpy/sbpy/bib/core.py:171, in cite.<locals>.decorator.<locals>.wrapper(*args, **kwargs)
    168 @wraps(f)
    169 def wrapper(*args, **kwargs):
    170     # only cite after successful call
--> 171     result = f(*args, **kwargs)
    172     register(f, citations)
    173     return result

File ~/git/sbpy/sbpy/bib/core.py:171, in cite.<locals>.decorator.<locals>.wrapper(*args, **kwargs)
    168 @wraps(f)
    169 def wrapper(*args, **kwargs):
    170     # only cite after successful call
--> 171     result = f(*args, **kwargs)
    172     register(f, citations)
    173     return result

File ~/git/sbpy/sbpy/data/obs.py:89, in Obs.from_mpc(cls, targetid, id_type, **kwargs)
     86     results = MPC.get_observations(targetid, id_type=id_type,
     87                                    **kwargs)
     88 except (RuntimeError, ValueError) as e:
---> 89     raise QueryError(
     90         ('Error raised by '
     91          'astroquery.mpc.MPCClass.get_observations: '
     92          '{}').format(e))
     94 if 'epoch' in results.columns:
     95     results['epoch'] = Time(results['epoch'].to('d').value,
     96                             scale='utc', format='jd')

QueryError: Error raised by astroquery.mpc.MPCClass.get_observations: No data queried. Are the target identifiers correct?

Provide information on your environment:
operating system and version: Linux Kubuntu 21.10
sbpy version: latest from GitHub
astropy version: 5.1
numpy version: 1.23.0

This is a problem with the MPC tool upon which the sbpy-astroquery chain is based. I tried 2008 JG at https://minorplanetcenter.net/iau/MPEph/MPEph.html and got back:

No current elements found for 2008 JG. There may be published elements for this object; if there are, it is probably meaningless to make a current prediction of the basis of them. However, when this object is identified/recovered/rediscovered, elements will be available here. If the designation refers to a recently designated object, ephemerides will generally be available on the day following assignment of the designation.

However, the MPC orbit database has an orbit for this year, so I don't understand why it reports "no current elements": http://www.minorplanetcenter.net/db_search/show_object?object_id=613986

Regardless, it seems the astroquery error message could be improved to help diagnose issues like this.

I have re-posted this issue on the astroquery project. Thanks for the attention to this issue and guidance.