Question

I have a fits files of event data, and I need to modify one of the tables by adding a new column of data derived by the data stored in a preexisting column of the same table. The problem I have is in closing the modified file. This is the code:

data = fits.open(events, extname='events')
t1 = data[1].data.field('time')
table = Table.read(events, format='fits')
t2 = Column(name='T2', data=t1)
table.add_column(t2)

How can I close the file writing on the same file as in input? If I try with table.write(events, format='fits') I receive an error due to the writing on an existing file, while if I try to close data the modifications are not written in the file.

Was it helpful?

Solution

They just recently added an overwrite option (similar to the usual clobber):

table.write(events, format='fits', overwrite='True')
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top