[AstroPy] Access to compressed data in FITS file.

Éric Depagne eric at depagne.org
Mon May 23 09:46:45 EDT 2011


Hi all.

I have some fits files that contain compressed data. 
If I open them using pyfits.open, I get the following:
In [17]: f
Out[17]: 
[<pyfits.NP_pyfits.PrimaryHDU object at 0x95979ec>,
 <pyfits.NP_pyfits.BinTableHDU object at 0x959ad4c>,
 <pyfits.NP_pyfits.BinTableHDU object at 0x959ea8c>,
 <pyfits.NP_pyfits.BinTableHDU object at 0x95cd86c>,
 <pyfits.NP_pyfits.BinTableHDU object at 0x95d164c>]

and then :
In [18]: f[1].data
Out[18]: 
FITS_rec([ (array([ 0,  0,  0, ..., 11,  6,  0], dtype=uint8), 
7.8563242345474249, 81.508781433105469),
       (array([  0,   0,   0, ..., 217, 137, 160], dtype=uint8), 
6.1135416774841307, -748.53662109375),
       (array([  0,   0,   0, ...,  90, 112, 128], dtype=uint8), 
6.308497703138733, -115.72266387939453),
       ...,
       (array([  0,   0,   0, ..., 109, 195,   0], dtype=uint8), 
6.7486103076454169, -17.52739143371582),
       (array([  0,   0,   0, ...,  92, 198,   0], dtype=uint8), 
6.7442002691665648, -20.605709075927734),
       (array([  0,   0,   0, ..., 210, 137, 232], dtype=uint8), 
6.9185699581314086, -33.143478393554688)], 
      dtype=[('COMPRESSED_DATA', '>i4', 2), ('ZSCALE', '>f8'), ('ZZERO', 
'>f8')])

I have a script that reads both compressed and uncompressed fits file, and of 
course, it fails with the compressed ones.

Does anybody knows, either how to access the data in the compressed case, or 
know a pointer wher I could find the info.

Thanks a lot.

Éric.
Un clavier azerty en vaut deux
----------------------------------------------------------
Éric Depagne                            eric at depagne.org



More information about the AstroPy mailing list