astroquery icon indicating copy to clipboard operation
astroquery copied to clipboard

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

Open monocongo opened this issue 1 year ago • 5 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

monocongo avatar Jul 12 '22 13:07 monocongo

I've been using the above approach for getting observations for a number of objects and I've only managed to get observations for about 10% of these, with the remainder getting the above error.

As an initial test case I'm using two objects which are both in the MPC dataset: '2010 JR34' and '2008 JG'. The first one is handled well by astroquery and it responds with the expected observations data. The second designation however triggers the error described above.

When debugging I make a breakpoint to compare the request URL and I see this difference:

GOOD designation ('2010 JR34'): https://minorplanetcenter.net/search_db/observations?designation=2010+JR34&object_type=M&table=observations

BAD designation('2008 JG'): http://minorplanetcenter.net/search_db?table=observations&object_type=M&designation=2008+JG

Notice the differences -- I'm not sure yet why, and if I use the URL format that works for 2010 JR34 but swap the year and label, i.e. https://minorplanetcenter.net/search_db/observations?designation=2008+JG&object_type=M&table=observations

it doesn't work either, so I'm not sure yet what the correct URL (and request object, payload etc.) should be to get the data for 2008 JG, but that data does exist, for example: https://minorplanetcenter.net/db_search/show_object?object_id=613986

monocongo avatar Jul 12 '22 13:07 monocongo

Ah, I see, the MPC's ephemeris service fails for '2008 JG' but does work for 613986, despite these being the same object. You can test out various objects using their web front-end: https://minorplanetcenter.net/iau/MPEph/MPEph.html I tried it out and got the same result (i.e., 2008 JG errored). Please report the issue to them at https://mpc-service.atlassian.net/servicedesk/customer/portals and they should keep you informed on the resolution.

For astroquery, I'm updating the error message from MPC.get_ephemeris. I want to include whatever message the MPC returns, but I'll also add the ephemeris service front-end URL to aid with debugging.

mkelley avatar Jul 13 '22 13:07 mkelley

For the MPC observation database, when I search for 2008 JG via https://minorplanetcenter.net/db_search , the returned URL is https://minorplanetcenter.net/db_search/show_object?object_id=613986 , i.e., they are resolving 2008 JG to the permanent designation and returning the results. But that is not working for your URLs.

mkelley avatar Jul 13 '22 13:07 mkelley

@mkelley @monocongo - for the benefits of the issue to be easily reproducible, could you please rephrase the code example above to be a minimal example using astroquery only rather than sbpy? Thanks!

bsipocz avatar Jul 13 '22 14:07 bsipocz

Oh, I've been confused as to which service you were using 🤦🏻‍♀️ Sorry about bringing up the ephemeris service, which may be related, but not directly relevant. Here is the MWE:

>>> from astroquery.mpc import MPC
>>> MPC.get_observations('2008 JG')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/msk/Projects/astroquery/astroquery/utils/class_or_instance.py", line 25, in f
    return self.fn(obj, *args, **kwds)
  File "/home/msk/Projects/astroquery/astroquery/utils/process_asyncs.py", line 29, in newmethod
    result = self._parse_result(response, verbose=verbose)
  File "/home/msk/Projects/astroquery/astroquery/mpc/core.py", line 1186, in _parse_result
    raise RuntimeError(('No data queried. Are the target '
RuntimeError: No data queried. Are the target identifiers correct?

How about "No data queried. Are the target identifiers correct? Is the MPC database search working for your object? The service is hosted at https://www.minorplanetcenter.net/search_db ."

mkelley avatar Jul 13 '22 14:07 mkelley

Addressed by #2466

mkelley avatar Jun 05 '23 13:06 mkelley