[AstroPy] PyFITS: Appending tables with variable length array...?
Taro Sato
ubutsu at gmail.com
Fri May 6 13:11:50 EDT 2011
Hi there. I'm trying to do something simple with PyFITS, appending
tables but running into a problem.
The manual provides a general procedure for tables with no varlen
arrays, which I mostly follow in the code snippet below.
import pyfits as pf
...
t1 = pf.open(fits1)
t2 = pf.open(fits2)
nr1 = t1[1].data.shape[0]
nr2 = t2[1].data.shape[0]
nr = nr1 + nr2
hdu = pf.new_table(t1[1].columns, nrows=nr)
for i in range(len(t1[1].columns)):
if i == 4:
# this is a variable length array column; need to
# work on row by row
for j, x in enumerate(t2[1].data.field(i)):
print((nr, nr1+j))
hdu.data.field(i)[nr1+j] = x
continue
# for non variable length column, this is fine
hdu.data.field(i)[nr1:] = t2[1].data.field(i)
The conditional was added to take care of a variable length array
column (#5). But this doesn't work...
So my question is, how do we do this? Is it at all possible to update
values in a varlen array column? Is my only option to create a new
table from scratch?
Thank you for your time,
Taro
More information about the AstroPy
mailing list