[AstroPy] How to change fits table header to another name

Yannick Roehlly yannick.roehlly at gmail.com
Thu Jun 25 14:07:51 EDT 2015


Hi Vinu,

The easiest way is to use Table:

from astropy.table import Table
t = Table.read("foo.fits")
t['RA'].name = 'RA_1'
t.write("bar.fits")

But if your FITS file has other extensions you may loose them when saving
back the table. In that case, you must use io.fits but you must know the
position of the column you want to rename:

from astropy.io import fits
hdu_list = fits.open("foo.fits")
hdu_list[1].columns[1].name = "RA_1"  # The column index starts at 0
hdu_list.writeto("bar.fits")

Regards,

Yannick

2015-06-25 19:06 GMT+02:00 Vinu Vikram <vvinuv at gmail.com>:

> Hi All
> I would like to change a fits binary table column name to another
> name. E.g. if the fits table has the header column RA and I need to
> change that to RA_1.
> Thanks
> Vinu
> _______________________________________________
> AstroPy mailing list
> AstroPy at scipy.org
> http://mail.scipy.org/mailman/listinfo/astropy
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/astropy/attachments/20150625/203615de/attachment.html>


More information about the AstroPy mailing list