I am trying to update a FITS table extension by appending some new columns to it. I am following the method given at http://pyfits.readthedocs.org/en/latest/users_guide/users_table.html#merging-tables. However, the header of the merged table contains only the bare minimum information required to identify the column. There was information in the original header file that I need. How can I carry all the extra keywords from the old table across to the new one?
I have already tried
merged_table.header = old_table.header
and adding in the necessary entries for the new columns manually, but this always corrupts the header and makes the entire FITS file unreadable.
Thanks
The best answer to this partly depends on how the new table is being created, but as of the latest version of PyFITS (v3.3.0) or Astropy (v0.4.2) the
BinTableHDU.from_columns
method, which creates a new BINARY table HDU from a set of column definitions accepts an optionalheader
argument which can receive, for example, the header from the original table HDU.This will ignore any keywords related to the table structure as understood by the FITS format, and only keep other metadata. I believe there was a bug for a bit where the
header
argument was ignored but that should be fixed now.