Skip to content Skip to sidebar Skip to footer

Adding A New Column To A Fits File Via Python

I have created an array named distance that contains 1242 values. I want to add this array as the 11th column in an already existing FITS file that contains 10 columns. I am using

Solution 1:

Finally they released an updated library that allows the modification of a table extension in a human way!

Last release of FITSIO. You can easily add a column with a code looking like the following:

import fitsio
from fitsio import FITS,FITSHDR
...
fits = FITS('file.fits','rw')
fits[-1].insert_column(name = 'newcolumn', data = mydata)      # add the extra column
fits.close()

Post a Comment for "Adding A New Column To A Fits File Via Python"