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 398 forks source link

"Cannot parse table column names" when trying to use Horizons #1192

Closed astrojuanlu closed 6 years ago

astrojuanlu commented 6 years ago

I'm trying to reproduce the Horizons examples from the documentation, but I get a OSError: Cannot parse table column names. no matter what I try:

$ ipython
Python 3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 18:10:19) 
Type 'copyright', 'credits' or 'license' for more information
IPython 6.4.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: >>> from astroquery.jplhorizons import Horizons
   ...: >>> obj = Horizons(id='Ceres', location='568',
   ...: ...                epochs={'start':'2010-01-01', 'stop':'2010-03-01',
   ...: ...                        'step':'10d'})
   ...: >>> eph = obj.ephemerides()
   ...: >>> print(eph)
   ...:                        
---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
<ipython-input-1-ed8be634f3c0> in <module>()
      3                epochs={'start':'2010-01-01', 'stop':'2010-03-01',
      4                        'step':'10d'})
----> 5 eph = obj.ephemerides()
      6 print(eph)
      7 

~/.miniconda36/envs/poliastro36/lib/python3.6/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)

~/.miniconda36/envs/poliastro36/lib/python3.6/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

~/.miniconda36/envs/poliastro36/lib/python3.6/site-packages/astroquery/jplhorizons/core.py in _parse_result(self, response, verbose)
    944             return None
    945         else:
--> 946             data = self._parse_horizons(response.text)
    947 
    948         return data

~/.miniconda36/envs/poliastro36/lib/python3.6/site-packages/astroquery/jplhorizons/core.py in _parse_horizons(self, src)
    850 
    851         if headerline == []:
--> 852             raise IOError('Cannot parse table column names.')
    853 
    854         # remove all 'Cut-off' messages

OSError: Cannot parse table column names.

In [2]: import astroquery; astroquery.__version__
Out[2]: '0.3.8'
astrojuanlu commented 6 years ago

In fact, if I try to run those tests locally, all of the remote tests fail:

$ python setup.py test --package='jplhorizons' --remote-data='any'
[...]
============================= test session starts =============================
platform linux -- Python 3.6.4, pytest-3.5.1, py-1.5.3, pluggy-0.6.0

Running tests with astroquery version 0.3.8.
Running tests in astroquery/jplhorizons docs/jplhorizons.

Date: 2018-07-12T11:52:23

Platform: Linux-4.15.0-24-generic-x86_64-with-debian-stretch-sid

Executable: /home/juanlu/.miniconda36/envs/poliastro36/bin/python

Full Python Version: 
3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 18:10:19) 
[GCC 7.2.0]

encodings: sys: utf-8, locale: UTF-8, filesystem: utf-8
byteorder: little
float info: dig: 15, mant_dig: 15

Numpy: 1.14.3
Matplotlib: 2.2.2
Pandas: 0.22.0
Astropy: 3.0.2
APLpy: not available
pyregion: not available
Using Astropy options: remote_data: any.

rootdir: /tmp/astroquery-test-xh4rw1wf/lib/python3.6/site-packages, inifile: setup.cfg
plugins: remotedata-0.3.0, openfiles-0.3.0, doctestplus-0.1.3, cov-2.5.1, arraydiff-0.2
collected 22 items                                                            

astroquery/jplhorizons/core.py .....                                    [ 22%]
astroquery/jplhorizons/tests/test_jplhorizons.py ...                    [ 36%]
astroquery/jplhorizons/tests/test_jplhorizons_remote.py FFFF.FF.FF.FF   [ 95%]
docs/jplhorizons/jplhorizons.rst .                                      [100%]

================================== FAILURES ===================================
[...]
bsipocz commented 6 years ago

cc @mommermi @mkelley

astrojuanlu commented 6 years ago

While I wait for the release, I saw that I can do

from astroquery.jplhorizons import conf
conf.horizons_server = 'https://ssd.jpl.nasa.gov/horizons_batch.cgi'

Horizons(...)

and everything works. This was not very well documented though, so perhaps it's not the way it should be used.

bsipocz commented 6 years ago

No, that's totally a valid way to change the configuration. It doesn't make much sense do change those defaults for most of the modules, but I guess some generic docs wouldn't hurt anyway. I'm just not sure about the location, I guess not many users are looking into e.g. https://astroquery.readthedocs.io/en/latest/api.html?

astrojuanlu commented 6 years ago

I reached that document, and seemed like dev documentation to me. My two cents :)

ColinOrionChandler commented 6 years ago

Ran into this issue again, thanks @Juanlu001 for the conf solution, worked like a charm!

bsipocz commented 6 years ago

@ColinOrionChandler - Which version do you use? If it's 0.3.8, you could try to switch to the latest release with pip install --update --pre astroquery