Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error reproducing the Vizier Getting Started example #51

Closed
banados opened this issue Feb 2, 2013 · 12 comments
Closed

Error reproducing the Vizier Getting Started example #51

banados opened this issue Feb 2, 2013 · 12 comments

Comments

@banados
Copy link

banados commented Feb 2, 2013

Hi, I get the following error

ERROR: AttributeError: 'module' object has no attribute 'get_data_fileobj'  [astropy.io.vo.ucd]

when trying to reproduce the example here
http://astroquery.readthedocs.org/en/latest/astroquery/vizier.html#functions

Is this a problem just on my machine, my installation? How can I make it work?
Thanks!

astroquery.__version__
Out[111]: '0.0.dev189'
astropy.__version__
Out[112]: '0.2.dev2710'

Here is the example that produces the error and the complete error:

from astroquery import vizier
query = {}
query["-source"] = "VII/258/vv10"
query["-out"] = ["Name", "Sp", "Vmag"]
query["Vmag"] = "5.0..11.0"
table1 = vizier.vizquery(query)
WARNING: W27: None:29:2: W27: COOSYS deprecated in VOTable 1.2 [astropy.io.vo.exceptions]
ERROR: AttributeError: 'module' object has no attribute 'get_data_fileobj' [astropy.io.vo.ucd]
Traceback (most recent call last):
  File "astroquerytest.py", line 6, in <module>
    table1 = vizier.vizquery(query)
  File "/usr/local/lib/python2.7/dist-packages/astroquery/vizier/vizier.py", line 77, in vizquery
    voTable = parse(cStringIO.StringIO(resp.read()), pedantic=False)
  File "/usr/local/lib/python2.7/dist-packages/astropy/io/vo/table.py", line 108, in parse
    config=config, pos=(1, 1)).parse(iterator, config)
  File "/usr/local/lib/python2.7/dist-packages/astropy/io/vo/tree.py", line 2881, in parse
    iterator, tag, data, config, pos)
  File "/usr/local/lib/python2.7/dist-packages/astropy/io/vo/tree.py", line 2812, in _add_resource
    resource.parse(self, iterator, config)
  File "/usr/local/lib/python2.7/dist-packages/astropy/io/vo/tree.py", line 2666, in parse
    iterator, tag, data, config, pos)
  File "/usr/local/lib/python2.7/dist-packages/astropy/io/vo/tree.py", line 2623, in _add_table
    table.parse(iterator, config)
  File "/usr/local/lib/python2.7/dist-packages/astropy/io/vo/tree.py", line 2010, in parse
    iterator, tag, data, config, pos)
  File "/usr/local/lib/python2.7/dist-packages/astropy/io/vo/tree.py", line 1939, in _add_field
    field = Field(self._votable, config=config, pos=pos, **data)
  File "/usr/local/lib/python2.7/dist-packages/astropy/io/vo/tree.py", line 1001, in __init__
    self.ucd        = ucd
  File "/usr/local/lib/python2.7/dist-packages/astropy/io/vo/tree.py", line 321, in ucd
    check_ucd(ucd, self._config, self._pos)
  File "/usr/local/lib/python2.7/dist-packages/astropy/io/vo/tree.py", line 211, in check_ucd
    has_colon=config.get('version_1_2_or_later', False))
  File "/usr/local/lib/python2.7/dist-packages/astropy/io/vo/ucd.py", line 103, in parse_ucd
    _ucd_singleton = UCDWords()
  File "/usr/local/lib/python2.7/dist-packages/astropy/io/vo/ucd.py", line 29, in __init__
    with config.get_data_fileobj("data/ucd1p-words.txt") as fd:
AttributeError: 'module' object has no attribute 'get_data_fileobj'
@astrofrog
Copy link
Member

Sorry about this - it is due to recent changes in the astropy master. Things have been in a state of flux with the upcoming 0.2 release, but once 0.2 is released, the core package will be a lot more stable. I'll see if there is a quick fix for this.

@astrofrog
Copy link
Member

Actually, I just noticed that this is an issue in Astropy itself.

@banados - can you update to the latest Astropy master to see if this fixes this error? You can either install the latest and greatest, or if you prefer installing from tar files, you can install the 0.2b2 beta from:

http://stsdas.stsci.edu/download/packages/index/astropy/index.html

Let us know if this fixes things!

@banados
Copy link
Author

banados commented Feb 3, 2013

Hi Tom, so I updated to

In [16]: astropy.__version__
Out[16]: '0.3.dev3115'

(is that the version you meant?)

and now I get a different error:

table1 = vizier.vizquery(query)
ERROR: ValueError: masked should be one of True, False, None [astropy.table.table]
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-22-fddc0f7526fd> in <module>()
----> 1 table1 = vizier.vizquery(query)

/usr/local/lib/python2.7/dist-packages/astroquery/vizier/vizier.pyc in vizquery(query, server)
     88             data = voTreeTable.array
     89             # Add Table to the list
---> 90             tableList += [Table(data, names)]
     91 
     92     # Merge the Table list

/home/eduardo/astropy/astropy/table/table.py in __init__(self, data, masked, names, dtypes, meta, copy)
    760         # Set up a placeholder empty table
    761         self._data = None
--> 762         self._set_masked(masked)
    763         self.columns = TableColumns()
    764         self.meta = OrderedDict() if meta is None else deepcopy(meta)

/home/eduardo/astropy/astropy/table/table.py in _set_masked(self, masked)
   1232                 self._masked = masked
   1233             else:
-> 1234                 raise ValueError("masked should be one of True, False, None")
   1235         if self._masked:
   1236             self._column_class = MaskedColumn

ValueError: masked should be one of True, False, None

@astrofrog
Copy link
Member

@banados - thanks for trying this! I'll look into it.

@astrofrog
Copy link
Member

@keflavich - the issue is this: Table(data, names) - you should use the keyword names, i.e. Table(data=data, names=names) because the second argument is now mask. I'm going to be mostly offline in the next couple of days, so feel free to fix it (and make sure this doesn't need to be changd elsewhere).

@keflavich
Copy link
Contributor

Thanks @astrofrog, I'll try to get this fixed.

@keflavich
Copy link
Contributor

@astrofrog, @banados - this issue has been fixed in master since 1/10/2013 (commit 387d9ea, pr #43). @banados, can you check that you have the latest git version?

@banados
Copy link
Author

banados commented Feb 4, 2013

So now I am sure I have the latest git version:

astropy.__version__
'0.3.dev3119'

When I do git log, the last change was on Date: Sun Feb 3 23:36:40 2013 -0800

Now, I get the same error I was getting at the beginning:

WARNING: W27: None:29:2: W27: COOSYS deprecated in VOTable 1.2 [astropy.io.vo.exceptions]
ERROR: AttributeError: 'module' object has no attribute 'get_data_fileobj' [astropy.io.vo.ucd]
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-6-fddc0f7526fd> in <module>()
----> 1 table1 = vizier.vizquery(query)

/usr/local/lib/python2.7/dist-packages/astroquery/vizier/vizier.pyc in vizquery(query, server)
     75     http.request("POST", "/viz-bin/votable", body=body)
     76     resp = http.getresponse()
---> 77     voTable = parse(cStringIO.StringIO(resp.read()), pedantic=False)
     78 
     79     # Convert VOTABLE into a list of astropy Table.

/usr/local/lib/python2.7/dist-packages/astropy/io/vo/table.pyc in parse(source, columns, invalid, pedantic, chunk_size, table_number, filename, _debug_python_based_parser)
    106         _debug_python_based_parser=_debug_python_based_parser) as iterator:
    107         return tree.VOTableFile(
--> 108             config=config, pos=(1, 1)).parse(iterator, config)
    109 
    110 

/usr/local/lib/python2.7/dist-packages/astropy/io/vo/tree.pyc in parse(self, iterator, config)
   2879             if start:
   2880                 tag_mapping.get(tag, self._add_unknown_tag)(
-> 2881                     iterator, tag, data, config, pos)
   2882             elif tag == 'DESCRIPTION':
   2883                 if self.description is not None:

/usr/local/lib/python2.7/dist-packages/astropy/io/vo/tree.pyc in _add_resource(self, iterator, tag, data, config, pos)
   2810         resource = Resource(config=config, pos=pos, **data)
   2811         self.resources.append(resource)
-> 2812         resource.parse(self, iterator, config)
   2813 
   2814     def _add_coosys(self, iterator, tag, data, config, pos):

/usr/local/lib/python2.7/dist-packages/astropy/io/vo/tree.pyc in parse(self, votable, iterator, config)
   2664             if start:
   2665                 tag_mapping.get(tag, self._add_unknown_tag)(
-> 2666                     iterator, tag, data, config, pos)
   2667             elif tag == 'DESCRIPTION':
   2668                 if self.description is not None:

/usr/local/lib/python2.7/dist-packages/astropy/io/vo/tree.pyc in _add_table(self, iterator, tag, data, config, pos)
   2621         table = Table(self._votable, config=config, pos=pos, **data)
   2622         self.tables.append(table)
-> 2623         table.parse(iterator, config)
   2624 
   2625     def _add_info(self, iterator, tag, data, config, pos):

/usr/local/lib/python2.7/dist-packages/astropy/io/vo/tree.pyc in parse(self, iterator, config)
   2008 
   2009                     tag_mapping.get(tag, self._add_unknown_tag)(
-> 2010                         iterator, tag, data, config, pos)
   2011                 else:
   2012                     if tag == 'DESCRIPTION':

/usr/local/lib/python2.7/dist-packages/astropy/io/vo/tree.pyc in _add_field(self, iterator, tag, data, config, pos)
   1937 
   1938     def _add_field(self, iterator, tag, data, config, pos):
-> 1939         field = Field(self._votable, config=config, pos=pos, **data)
   1940         self.fields.append(field)
   1941         field.parse(iterator, config)

/usr/local/lib/python2.7/dist-packages/astropy/io/vo/tree.pyc in __init__(self, votable, ID, name, datatype, arraysize, ucd, unit, width, precision, utype, ref, type, id, xtype, config, pos, **extra)
    999         self.datatype   = datatype
   1000         self.arraysize  = arraysize
-> 1001         self.ucd        = ucd
   1002         self.unit       = unit
   1003         self.width      = width

/usr/local/lib/python2.7/dist-packages/astropy/io/vo/tree.pyc in ucd(self, ucd)
    319                     W28, W28, ('ucd', self._element_name, '1.2'),
    320                     self._config, self._pos)
--> 321             check_ucd(ucd, self._config, self._pos)
    322         self._ucd = ucd
    323 

/usr/local/lib/python2.7/dist-packages/astropy/io/vo/tree.pyc in check_ucd(ucd, config, pos)
    209                 check_controlled_vocabulary=config.get(
    210                     'version_1_2_or_later', False),
--> 211                 has_colon=config.get('version_1_2_or_later', False))
    212         except ValueError as e:
    213             # This weird construction is for Python 3 compatibility

/usr/local/lib/python2.7/dist-packages/astropy/io/vo/ucd.pyc in parse_ucd(ucd, check_controlled_vocabulary, has_colon)
    101     global _ucd_singleton
    102     if _ucd_singleton is None:
--> 103         _ucd_singleton = UCDWords()
    104 
    105     if has_colon:

/usr/local/lib/python2.7/dist-packages/astropy/io/vo/ucd.pyc in __init__(self)
     27         self._capitalization = {}
     28 
---> 29         with config.get_data_fileobj("data/ucd1p-words.txt") as fd:
     30             for line in fd.readlines():
     31                 type, name, descr = [

AttributeError: 'module' object has no attribute 'get_data_fileobj'

@astrofrog
Copy link
Member

@banados - there's something strange with your installation - /usr/local/lib/python2.7/dist-packages/astropy/io/vo does not exist in the latest Astropy. Could you try removing /usr/local/lib/python2.7/dist-packages/astropy, then installing Astropy and trying again?

@banados
Copy link
Author

banados commented Feb 4, 2013

ok... so it seems that the problem was that I checked that I had the latest git astropy version, but I didn't check the astroquery version.

Even after deleting the directory that @astrofrog suggested and installing astropy again I was getting the same error...

So I uninstalled astroquery, updated it to the last version and the error went away

Then, the astroquery version that crashes is:

astroquery.__version__
 '0.0.dev189'

And the version that works without problems is

astroquery.__version__
'0.0.dev219

Thanks all for your help and sorry for not noticing this before!

@banados banados closed this as completed Feb 4, 2013
@astrofrog
Copy link
Member

@banados - just to follow up on this - when you removed and reinstalled astropy, did you still get errors containing /usr/local/lib/python2.7/dist-packages/astropy/io/vo? If so, there's still something weird because it should be /usr/local/lib/python2.7/dist-packages/astropy/io/votable. Maybe you should try from a clean clone (there may be residual files in build).

@banados
Copy link
Author

banados commented Feb 4, 2013

When I removed and reinstalled astropy after deleting /usr/local/lib/python2.7/dist-packages/astropy/io/vo, I was getting the other error associated with the table:

ERROR: ValueError: masked should be one of True, False, None [astropy.table.table]

Actually I started from a clean one, I removed everything related with astropy and astroquery and installed them from scratch. And I confirm now that I have the correct directory instead:

/usr/local/lib/python2.7/dist-packages/astropy/io/votable/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants