[SciPy-User] [Astropy] Can't write a table in a format other than plain ascii
braga
Vittorio.Braga at roma2.infn.it
Wed Oct 16 05:19:20 EDT 2013
Dear all
I am not only new to Astropy but I'm totally new to python itself
I need to read a csv table and rewrite it as an ipac table. I do this
with astropy 0.24 ...
zaamus at zaamuspc:~/Documenti/Dottorato/RRLyr/temp$ python -V
Python 2.7.2
zaamus at zaamuspc:~/Documenti/Dottorato/RRLyr/temp$ sudo python
[sudo] password for zaamus:
Python 2.7.2+ (default, Oct 4 2011, 20:03:08)
[GCC 4.6.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from astropy.io import ascii
>>> rdr=ascii.get_reader(Reader=ascii.Basic)
>>> rdr.header.splitter.delimiter=','
>>> rdr.data.splitter.delimiter=','
>>> t1=ascii.read('match_2MASS+nomi')
>>> t2=ascii.read('RRLyr_PLZK.dat')
all is nice until here and I also manage to write to file in a plain
ascii format
>>> ascii.write(t2,'RRLyr_PLZK.dat_2')
Fine. But if I do...
>>> ascii.write(t2,'RRLyr_PLZK.dat_2',format='ipac')
ERROR: TypeError: __init__() got an unexpected keyword argument
'format' [astropy.io.ascii.core]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/astropy/io/ascii/ui.py",
line 277, in write
writer = get_writer(Writer=Writer, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/astropy/io/ascii/ui.py",
line 244, in get_writer
writer = core._get_writer(Writer, **kwargs)
File
"/usr/local/lib/python2.7/dist-packages/astropy/io/ascii/core.py", line
1015, in _get_writer
writer = Writer(**writer_kwargs)
TypeError: __init__() got an unexpected keyword argument 'format'
Same thing with format='latex'
Also trying to write to sys.stdout (after importing sys) works only
with no format specification
I've also tried to
>>> from astropy.io.ascii import ipac
>>> ipac.write(t2,'RRLyr_PLZK.dat_2')
ERROR: AttributeError: 'module' object has no attribute 'write'
[unknown]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'write'
>>> from astropy.table import Table
>>> t3=Table.read('match_2MASS+nomi',format='ascii')
>>> Table.write(t3,'match_2MASS+nomi_2',format='ascii')
fine, again it works...
then I try
>>> Table.write(t3,'match_2MASS+nomi_2',format='ascii.ipac')
ERROR: Exception: No writer defined for format 'ascii.ipac' and class
'Table' [astropy.io.registry]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/astropy/io/registry.py",
line 200, in write
writer = get_writer(format, data.__class__)
File "/usr/local/lib/python2.7/dist-packages/astropy/io/registry.py",
line 138, in get_writer
'{1!r}'.format(data_format, data_class.__name__))
Exception: No writer defined for format 'ascii.ipac' and class 'Table'
>>> Table.write(t3,'match_2MASS+nomi_2',format='ipac')
ERROR: Exception: No writer defined for format 'ipac' and class 'Table'
[astropy.io.registry]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/astropy/io/registry.py",
line 200, in write
writer = get_writer(format, data.__class__)
File "/usr/local/lib/python2.7/dist-packages/astropy/io/registry.py",
line 138, in get_writer
'{1!r}'.format(data_format, data_class.__name__))
Exception: No writer defined for format 'ipac' and class 'Table'
Am I missing something? Am I not importing something?
Thank you, Vittorio
--
Vittorio Francesco Braga
PhD student in Tor Vergata University of Rome
Mobile: +393203753307, Office (PhD room): +390672594868
More information about the SciPy-User
mailing list