Open martinBanda opened 4 years ago
Could you please include a complete example of code that would reproduce the issue? Also, please report your astropy and astroquery versions. Is the main MPC webpage works as you expect for these two cases?
astropy: 4.0 astroquery: 0.4.1.dev0
Below an example:
from astroquery.mpc import MPC
number, name = 137295, '1999 RB216'
obs = MPC.get_observations(number, get_mpcformat=True)
obs2 = MPC.get_observations(name, get_mpcformat=True)
print(len(obs)) #output: 333
print(len(obs2)) #output: 38
There are 333 observations, according the main MPC webpage: https://minorplanetcenter.net/db_search/show_object?object_id=137295
but, in the download version (click in download link) there are 341 observations.
The "obs" variable (in example) actually has 341 observations stored in 333 lines, which means that 2 observations are being stored by line for 8 of the 333 lines (lines 121 to 128).
I used the next code to write, in a ascii file, the content of the "obs" variable:
import numpy as np
obs_data = obs['obs'].data
np.savetxt('test.txt', obs_data, fmt='%s')
The version of my numpy is: 1.18.1
cc @mkelley - this still seems to be an issue
I think this is an issue with the service and not with astroquery. The raw responses have the same problem:
>>> from astroquery.mpc import MPC
>>>
>>> number, name = 137295, '1999 RB216'
>>>
>>> obs = MPC.get_observations_async(number, get_mpcformat=True)
>>> obs2 = MPC.get_observations_async(name, get_mpcformat=True)
>>>
>>> print(len(obs2.json()))
38
>>> print(len(obs.json()))
363
There is a new API for getting observational data and it does not have this issue:
>>> import requests
>>> from xml.etree import ElementTree as ET
>>>
>>> response = requests.get("https://data.minorplanetcenter.net/api/get-obs", json={"desigs": ["137295"]})
>>> obs = ET.fromstring(response.json()[0]["XML"])
>>> response = requests.get("https://data.minorplanetcenter.net/api/get-obs", json={"desigs": ["1999 RB216"]})
>>> obs2 = ET.fromstring(response.json()[0]["XML"])
>>>
>>> print(len(obs.findall("optical")))
363
>>> print(len(obs2.findall("optical")))
363
Since the old API is or is going to be deprecated, the solution is to switch to the new API. Otherwise, open a help desk ticket at the MPC with the problem (but their answer might be to use the new API).
Since the old API is or is going to be deprecated
Do we have a roadmap/timeline to switch the astroquery module to use the new API?
At the moment I can only say that I will not have time before November.
Hello, I am trying to use MPC library from astroquery.mpc to get all reported observations (in Minor Planet Center) for the asteroid 137295 (1999 RB216). The result is different when the asteroid's name (result=38 lines) is used instead of the number (result=333 lines). Could anyone please check if this problem is really happening? if yes, what would be the solution?