[AstroPy] question on saving fits files

Grigoris Maravelias gr.maravelias at gmail.com
Wed Feb 10 11:30:11 EST 2016


Hello!

I have a problem with a rather simple process, but I cannot understand
what I am doing wrong. I have an image in a fits file that i want to
open and process its data values, and save it as another file (including
some extra information on the header for what I did). So according to
the astropy docs [1] I did the following:

hdulist = fits.open('small.fits')
hdu = hdulist[0]
hd = hdu.header
dt = hdu.data

hd.append(('HISTORY', 'blabla '), bottom=True)

print dt            # check data before
dt = dt*1000
print dt            # and after

hdulist.writeto('small_mod.fits')

If I print dt before and after their modification (multiplied by 1000) I
can see that they are indeed different (properly multiplied), but when I
save the fits file I just see the original data values (however, the
HISTORY line is added properly in the primary header).

What am I missing here?

Best
Grigoris
 

[1] http://docs.astropy.org/en/stable/io/fits/usage/headers.html





More information about the AstroPy mailing list