pythontabular

Python table output in IPAC style


I'd like to make an IPAC output table (http://docs.astropy.org/en/v0.2.1/table/io.html)

I have two data columns, ra and dec, and these are two numpy arrays::

type(data['ra'])
numpy.ndarray

However,

data_out = (data['ra'], data['dec'])
data_out.write('data_out.tbl', format='ipac')

but then get:

AttributeError: 'tuple' object has no attribute 'write'


Solution

  • from astropy.table import Table
    data_out = Table.from_pandas(data)
    output_path = '/data_out.tbl'
    
    # Write the table in IPAC format
    data_out.write(output_path, format='ipac')