[AstroPy] Producing tile compressed FITS files

John Parejko parejkoj at uw.edu
Fri Jun 17 12:44:13 EDT 2016

Bill Pence gave this reply, but he's not on the astropy list.

By the looks of it, this is an astropy bug when it writes the CompImageHDUs.

On Jun 17, 2016 8:21 AM, "William Pence" <William.Pence at nasa.gov> wrote:

The error message produced by fits_verify when testing the compressed file
indicates that the header keywords in the 3rd HDU are not present in the
required order.  The 8th keyword of the binary table extension (the
compressed image) must be TFIELDS, but in this file the 8th keyword is
BSCALE.  CFITSIO strictly enforces this requirement, so won't read that HDU
(or any following HDUs). Here is the error message:

*** Error:   Bad HDU? (from CFITSIO error stack:)
             ffgtkn found unexpected keyword or value for keyword no. 8.
              Expected positive integer keyword TFIELDS, but instead
              found keyword BSCALE with value 1
             Failed to move to HDU number 3 (ffmahd).


On 6/16/2016 11:48 PM, John K. Parejko wrote:

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:
> http://fits.gsfc.nasa.gov/fits_verify.html
> 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):
> http://staff.washington.edu/parejkoj/lsst/
> Ideas and suggestions welcome!
> Thanks in advance,
> John
> --
> *************************
> John Parejko
> parejkoj at uw.edu
> http://staff.washington.edu/parejkoj/
> Department of Physics and Astronomy
> University of Washington
> Seattle, WA
> **************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/astropy/attachments/20160617/7609c9a0/attachment.html>

More information about the AstroPy mailing list