Adding a new column to a FITS file via python

若如初见. 提交于 2019-12-04 05:29:06

问题


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 pyfits.

I tried pyfits.append(filename, distance) which showed no errors but did not add my column to the FITS file.

Any suggestions??


回答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()


来源:https://stackoverflow.com/questions/21046500/adding-a-new-column-to-a-fits-file-via-python

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!