[AstroPy] modifying FITS data
Jean-Luc Menut
jeanluc.menut at free.fr
Tue May 31 10:53:55 EDT 2011
Hello All,
I'm currently struggling with Pyfits, I hope somebody could help me.
My problem is the following :
I have a FITS file mostly structured as an OIFITS (but not completly),
of which I would like to modify several of the tables' data. The file is
structured as the following:
In [47]: orig.info()
Filename: 2006-03-01-05-03.fits
No. Name Type Cards Dimensions Format
0 PRIMARY PrimaryHDU 9 () int16
1 OI_WAVELENGTH BinTableHDU 17 95R x 2C [E, E]
2 OI_VIS BinTableHDU 48 1R x 14C ['I', 'D', 'D', 'D',
'113C', '113C', '113D', '113D', '113D', '113D', '1D', '1D', '2I', '113L']
3 OI_VIS2 BinTableHDU 38 1R x 10C [I, D, D, D, 95D,
95D, 1D, 1D, 2I, 95L]
4 OI_ARRAY BinTableHDU 31 3R x 5C [3A, 2A, 1I, 1E, 3D]
5 OI_TARGET BinTableHDU 49 1R x 17C [1I, 7A, 1D, 1D, 1E,
1D, 1D, 1D, 7A, 7A, 1D, 1D, 1D, 1D, 1E, 1E, 7A]
The table OI_VIS has several fields. One of them is 'VISAMP' :
In [51]: print orig['OI_VIS'].data['VISAMP']
array([[ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0.]])
What I would like to do is to replace these value by some others
(actually interpolated from other FITS data).
I probably missed something obvious but I did not manage to find how to
do that.
By example, if I try to do
In [80]: orig['OI_VIS'].data['VISAMP']=tuple(ones(14))
I obtain:
ValueError: field named VISAMP not found.
So any information is welcome.
Thanks by advance,
Jean-Luc
More information about the AstroPy
mailing list