[AstroPy] Producing tile compressed FITS files

John K. Parejko parejkoj at uw.edu
Thu Jun 16 23:48:29 EDT 2016

cc:ing William Pence, as this may be an odd interaction between astropy.io.fits and cfitsio.

In an effort to reduce the size of some LSST test data, I converted the three image HDUs in a file to compressed image HDUs like so:

from astropy.io import fits
data = fits.open('somefile.fits')
for i in [1,2,3]:
    data[i] = fits.CompImageHDU(data=data[i].data,header=data[i].header)
data.writeto(f, clobber=True)

If I open the new file with pyfits, all of the HDUs seem fine, but now cfitsio doesn't appear to like the files. Erin Sheldon's fitsio only sees the first 2 HDUs. So does the online FITS tester webpage:


DS9 seems to read it ok: I can specify "-mecube" and see all three image planes.

Is what I did above not allowed for some reason, or did I do something wrong?

I've put up the original file, the file with 3 HDUs tile-compressed, and (the original goal of this) a file with the 3 image HDUs zeroed out and then compressed (I wanted a file with the structure of the original, but taking minimal space):


Ideas and suggestions welcome!

Thanks in advance,

John Parejko
parejkoj at uw.edu
Department of Physics and Astronomy
University of Washington
Seattle, WA

More information about the AstroPy mailing list