[AstroPy] Access to compressed data in FITS file.

Taro Sato taro at ap.smu.ca
Mon May 23 10:05:53 EDT 2011


On Mon, May 23, 2011 at 10:46 AM, Éric Depagne <eric at depagne.org> wrote:
> 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
> _______________________________________________
> AstroPy mailing list
> AstroPy at scipy.org
> http://mail.scipy.org/mailman/listinfo/astropy
>

The PyFITS manual discusses how to deal with compressed data:

http://stsdas.stsci.edu/download/wikidocs/The_PyFITS_Handbook.pdf

Is this not enough?


-- 
Taro Sato
Department of Astronomy & Physics
Saint Mary's University             email: taro at ap.smu.ca
Halifax, NS B3H 3C3                 phone: (902)420-5027
Canada                                web: http://ap.smu.ca/~taro



More information about the AstroPy mailing list