sczesla / PyAstronomy

A collection of astronomy-related routines in Python
152 stars 35 forks source link

pyasl.ExoplanetEU2() give long error #20

Closed DanielAndreasen closed 7 years ago

DanielAndreasen commented 7 years ago

Hi Stefan,

I get a rather long error message when I try to run pyasl.ExoplanetEU2(). See below.

from PyAstronomy import pyasl
d = pyasl.ExoplanetEU2()

---------------------------------------------------------------------------
E05                                       Traceback (most recent call last)
<ipython-input-43-59de23a2c99b> in <module>()
----> 1 pyasl.ExoplanetEU2()

/home/daniel/Software/anaconda3/lib/python2.7/site-packages/PyAstronomy/pyasl/resBased/exoplanetEU.pyc in __init__(self, skipUpdate, forceUpdate)
    572       # regular update is indicated
    573       self._update(self._download)
--> 574     self._readData()
    575 
    576   def _download(self):

/home/daniel/Software/anaconda3/lib/python2.7/site-packages/PyAstronomy/pyasl/resBased/exoplanetEU.pyc in _readData(self)
    347     with warnings.catch_warnings():
    348       warnings.simplefilter("ignore")
--> 349       self.vot = votable.parse(self._fs.requestFile(self.dataFileName, 'r', gzip.open))
    350     # Use 'name' over ID field to specify column names
    351     self.vot = self.vot.get_first_table().to_table(use_names_over_ids=True)

/home/daniel/Software/anaconda3/lib/python2.7/site-packages/astropy/io/votable/table.pyc in parse(source, columns, invalid, pedantic, chunk_size, table_number, table_id, filename, unit_format, datatype_mapping, 
_debug_python_based_parser)
    138         _debug_python_based_parser=_debug_python_based_parser) as iterator:
    139         return tree.VOTableFile(
--> 140             config=config, pos=(1, 1)).parse(iterator, config)
    141 
    142 

/home/daniel/Software/anaconda3/lib/python2.7/site-packages/astropy/io/votable/tree.pyc in parse(self, iterator, config)
   3391             if start:
   3392                 tag_mapping.get(tag, self._add_unknown_tag)(
-> 3393                     iterator, tag, data, config, pos)
   3394             elif tag == 'DESCRIPTION':
   3395                 if self.description is not None:

/home/daniel/Software/anaconda3/lib/python2.7/site-packages/astropy/io/votable/tree.pyc in _add_resource(self, iterator, tag, data, config, pos)
   3320         resource = Resource(config=config, pos=pos, **data)
   3321         self.resources.append(resource)
-> 3322         resource.parse(self, iterator, config)
   3323 
   3324     def _add_coosys(self, iterator, tag, data, config, pos):

/home/daniel/Software/anaconda3/lib/python2.7/site-packages/astropy/io/votable/tree.pyc in parse(self, votable, iterator, config)
   3145             if start:
   3146                 tag_mapping.get(tag, self._add_unknown_tag)(
-> 3147                     iterator, tag, data, config, pos)
   3148             elif tag == 'DESCRIPTION':
   3149                 if self.description is not None:

/home/daniel/Software/anaconda3/lib/python2.7/site-packages/astropy/io/votable/tree.pyc in _add_table(self, iterator, tag, data, config, pos)
   3102         table = Table(self._votable, config=config, pos=pos, **data)
   3103         self.tables.append(table)
-> 3104         table.parse(iterator, config)
   3105 
   3106     def _add_info(self, iterator, tag, data, config, pos):

/home/daniel/Software/anaconda3/lib/python2.7/site-packages/astropy/io/votable/tree.pyc in parse(self, iterator, config)
   2395                             'TABLEDATA', six.iterkeys(data), config, pos)
   2396                         self.array = self._parse_tabledata(
-> 2397                             iterator, colnumbers, fields, config)
   2398                         break
   2399                     elif tag == 'BINARY':

/home/daniel/Software/anaconda3/lib/python2.7/site-packages/astropy/io/votable/tree.pyc in _parse_tabledata(self, iterator, colnumbers, fields, config)
   2510                                 except Exception as e:
   2511                                     if invalid == 'exception':
-> 2512                                         vo_reraise(e, config, pos)
   2513                                 else:
   2514                                     row[i] = value

/home/daniel/Software/anaconda3/lib/python2.7/site-packages/astropy/io/votable/exceptions.pyc in vo_reraise(exc, config, pos, additional)
    117         message += ' ' + additional
    118     exc.args = (message,)
--> 119     raise exc
    120 
    121 

E05: None:22454:1220: E05: Invalid boolean value 'Yes'

As a sidenote, the link for pyasl.ExoplanetEU doesn't work anymore: http://exoplanet.eu/catalog/csv

I add @sousasag to the conversation as he was the one who found the bug.

sczesla commented 7 years ago

Hi Daniel,

great to hear from you and thanks for reporting.

Honestly, I have been aware of this bug. As far as I can say, the reason for this is that the VO table currently provided by exoplanet.eu is not entirely standard compatible because, as you see in the error message, "Yes" is not a valid boolean value, and astropy does not handle this smoothly (well, it does the right thing actually). I contacted exoplanet.eu about this issue, but I have not heard something so far. So maybe it is not a general issue or I am simply not right in my evaluation.

At any rate, I had hoped that the issue would not require a tailored solution from my side. Yet, I start to see the necessity now. I will look into this and see that I can provide a solution soon!

Stefan

sczesla commented 7 years ago

Hi again,

this was quicker than I expected. I just pushed a commit, which should resolve the issue. Invalid columns are now masked, which prevents an error. However, quite a few values (in particular, nonexisting) will also be masked. I think this is a change in behavior compared to the previous situation.

I hope that helps! Stefan

DanielAndreasen commented 7 years ago

Hi again,

I just tested this, and it works. I had to rename some stuff (names of columns are slightly different), but at least I can get the data again. Thanks for the quick fix.

Daniel

sczesla commented 7 years ago

Hi,

great.

I also looked at the "old" class (ExoplanetEU), which stopped working. Obviously, the mechanism for downloading the data ceased to work for the CSV data, due to a change on the server side, and I could not (quickly) come up with a working alternative (still works for the votable format, and I hope that will continue). So unfortunately, this is seems to be beyond repair for the moment.

Stefan

DanielAndreasen commented 7 years ago

Yes, I understand it is out of our hands. I think you can close this issue though. The VOtable is working again.

Daniel