How to save the title and units of the table of astrophysics in ascii file

I am trying to create an ascii table with some information about the header, column names and units and some data, it should look like this:

 # ... Header Info ...
          Name | Morphology |         ra_u |        dec_u | ...
               | InNS+B+MOI | HH:MM:SS.SSS | ±DD:MM:SS:SSS| ...
 ==============| ========== | ============ | ============ | ...
 1_Cam_A       | I          | 04:32:01.845 | +53:54:39.03   ...
 10_Lac        | I          | 22:39:15.679 | +39:03:01.01   ... 
...

So far I have tried with numpy.savetxt and astropy.ascii.writhe, numpy will not solve my problems, and with ascii.write I managed to get something similar, but not quite right:

              Name | Morphology |         ra_u |        dec_u | ...    
================== | ========== | ============ | ============ | ...
1_Cam_A            | I          | 04:32:01.845 | +53:54:39.03   ...
...

I am using this code:

formato= {'Name':'%-23s','Morphology':'%-10s','ra_u':'%s','dec_u':'%s',...}
names=['Name','Morphology','ra_u','dec_u','Mag6']
units=['','InNS+B+MOI','HH:MM:SS.SSS','±DD:MM:SS:SSS',...]
ascii.write(data, output='pb.txt',format='fixed_width_two_line',position_char='=',delimiter=' | ',names=names, formats=formato)

So, if I print in my terminal, the table looks the way it should, except for the header information, but when I save it to a file, the units disappear ...

Is there a way to include them in a file ?, or do I need to save the file and edit it later?

P.D.: , IPAC ascii.write, , , : '| null | null |..... ', , ...

Un saludo.

+4
2

, astropy.table astropy.io.ascii. https://github.com/astropy/astropy/issues .

ascii.ipac:

tbl.write('test.txt', format='ascii.ipac')
with open('test.txt', 'r') as fh:
    output = []
    for ii, line in enumerate(fh):
        if ii not in (1,3):
            output.append(line)

with open('test.txt', 'w') as fh:
    fh.writelines(output)

IPAC, 2- 4- .

+4

, ASCII , ECSV.

+1

All Articles