[AstroPy] Creating Rice compressed fits files

jtaylor2 at stsci.edu jtaylor2 at stsci.edu
Thu Jun 11 11:39:29 EDT 2009


Tommy,

    To create a compressed image HDU from scratch, simply construct a CompImageHDU object from an uncompressed image data array and its associated image header.  From there, the HDU can be treated just like any image HDU.

For example if you have an uncompressed HDU with the name uncompHDU you could do the following:

>>> compHDU = pyfits.CompImageHDU(uncompHDU.data, uncompHDU.Header)

Then you can write it out to a file with:

>>> compHDU.writeto('outfile.fits')

The help on CompImageHDU will give you lots of gory details about the CompImageHDU initializer including some options that effect the compression.  Note that RICE is the default compression method used.

>>> help(pyfits.CompImageHDU.__init__)


   I hope this helps,

       Jim T.



More information about the AstroPy mailing list