Closed gandalfsaxe closed 6 years ago
cc @mommermi
399
is correct, but then you also have to use id_type='id'
when initializing your Horizons
object. If you only use id=399
, it will return asteroid 399, as id_type
is by default set to smallbody
, querying the asteroid and comet database.
If it's not yet in the docs, would it be possible to include?
I think it's written up in the final paragraph here. @GandalfSaxe if you think it should be explained in a different way or more thoroughly, please let me know.
Ah ok I see. I was probably just tired when looking at the documentation. Perhaps a single example with a planet would be beneficial, but as you said, it was already there 🙂
I am having some trouble with my query though:
from astroquery.jplhorizons import Horizons
obj = Horizons(id='399',
location='@sun',
epochs={'start':'2010-01-01',
'stop':'2010-03-01',
'step':'1d'},
id_type='majorbody')
results in KeyError: 'Obsrv-lon'
error when I try to extract ephemerides:
I'm having a similar KeyError: 'Obsrv-lon'
error when trying to query JPL Horizons for the Moon when observed from an earth location.
e.g.
from astroquery.jplhorizons import Horizons
obj = Horizons(id='301', id_type='id', location={'lon': 0.0000, 'lat': 51.0000, 'elevation':0., 'body':'399'}, epochs=2451545.0)
obj.ephemerides()
gives me the following output:
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
<ipython-input-174-765a66533942> in <module>()
----> 1 obj.ephemerides()
C:\Anaconda3\lib\site-packages\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)
C:\Anaconda3\lib\site-packages\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
C:\Anaconda3\lib\site-packages\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
C:\Anaconda3\lib\site-packages\astroquery\jplhorizons\core.py in _parse_horizons(self, src)
1184 rename = []
1185 for col in data.columns:
-> 1186 data[col].unit = column_defs[col][1]
1187 if data[col].name != column_defs[col][0]:
1188 rename.append(data[col].name)
KeyError: 'Obsrv-lon'
Copying and pasting the obj.uri
string into a browser works well though.
I have tried using other id_type
s:
obj = Horizons(id='Moon', id_type='majorbody', location={'lon': 0.0000, 'lat': 51.0000, 'elevation':0., 'body':'399'}, epochs=2451545.0)
obj.ephemerides()
which gives me an ambiguous target name error but shows that the ID for the Moon is correct above:
ValueError: Ambiguous target name; provide unique id:
ID# Name Designation IAU/aliases/other
------- ---------------------------------- ----------- -------------------
3 Earth-Moon Barycenter EMB
301 Moon Luna
Also, using the same query style for other bodies like the Sun (10), Mars (499), Jupiter (599), etc. does not produce any errors. e.g.
obj = Horizons(id='499', id_type='id', location={'lon': 0.0000, 'lat': 51.0000, 'elevation':0., 'body':'399'}, epochs=2451545.0)
obj.ephemerides()
<Table masked=True length=1>
targetname datetime_str datetime_jd ... alpha_true PABLon PABLat
--- --- d ... deg deg deg
str10 str24 float64 ... float64 float64 float64
---------- ------------------------ ----------- ... ---------- -------- -------
Mars (499) 2000-Jan-01 12:00:00.000 2451545.0 ... 31.459 343.7026 -1.2928
I'm using the Anaconda distribution on Windows 10. My version of astroquery
is 0.3.9.dev582
from pypi.org.
Thank you.
This looks like a bug. I will look into this! Thanks!
This has been addressed in #1268
Nice!
@GandalfSaxe - you should be able to update now with pip install --pre --upgrade astroquery
to have this fixed locally.
I'm trying to get some coordinates for Earth with Sun as location on Horizons, as here:
However id=399 is not Earth, but
Persephone (1895 BP)
. I also tried:[399]
earth
Earth
Earth (Geocenter)
Earth (Geocenter) 399
earth
Is looked closely at the documentation page JPL Horizons Queries, but no luck.
What is the id of Earth?