Reputation: 11
I have a table in FITS format that I have to edit. This is a sample of the data in Python:
data =
FITS_rec([( 0, -1, -1., -540., -1.93287335e-18, -0.14582774, -1., -26.5, 12.12002624, 4),
( 1, -1, -1., -539., -2.19318337e-18, -0.16850733, -1., -26.5, 12.12002624, 4),
( 2, -1, -1., -538., -2.18309714e-18, -0.16215905, -1., -26.5, 12.12002624, 4),
...,
(1077, -2, -1., 537., 4.93990773e-18, 0.34313738, -1., -10. , 12.92693756, 5),
(1078, -2, -1., 538., 3.57624176e-18, 0.25193304, -1., -10. , 12.92693756, 5),
(1079, -2, -1., 539., 1.57228526e-18, 0.11302811, -1., -10. , 12.92693756, 5)],
dtype=(numpy.record, [('ID', '>i4'), ('BIN_ID', '>i4'), ('X', '>f8'), ('Y', '>f8'), ('FLUX', '>f8'), ('SNR', '>f8'), ('XBIN', '>f8'), ('YBIN', '>f8'), ('SNRBIN', '>f8'), ('NSPAX', '>i4')]))
I want to edit the last column of each array, so that it correlates to NSPAX
.
In order to delete the last column, I tried this code:
names = list(data.dtype.names)
new_names = names[:8]
b = a[new_names]
But I get this error when running it: IndexError: only integers, slices (':'), ellipsis ('...'), numpy.newaxis ('None') and integer or boolean arrays are valid indices
Can someone help me? Also, once I've deleted that column, how can I add another one?
Upvotes: 1
Views: 75