Is there a way to compress non-integer data without loss using the CFITSIO library?

4 views (last 30 days)
Using the "Low-Level" functionality of the CFITSIO MATLAB Library I have been able to compress a FITS file containing a non-integer (double) valued imaged into another FITS file. However, when I go to open the compressed file, the pixel values in the image are slightly different than in the original uncompressed file. I understand that this "loss" is not surprising per https://heasarc.gsfc.nasa.gov/docs/software/fitsio/compression.html
In an effort to skirt this limitation, I multiplied the entire image by 10^n, where n was equal to the maximum number of decimal places displayed by a given value in the array (i.e. 123.4567 would be multiplied by 10^4 to become an integer value of 1234567). This resulted in my having to change the datatype of the image array to int64 in order to accommodate the increased magnitude of the values. However, this datatype change lead to an error when the image was compressed. The specific error code was "113: Unable to allocate memory"
Thanks in advance for your help.

Answers (1)

Bjorn Gustavsson
Bjorn Gustavsson on 16 Dec 2021
If you have data in double (32 or 64 bit-format), and want to keep it that way, dont' cook up your own casting-trickery - set the BITPIX keyword to either -32 or -64 and save the data in double-format.
(If the matlab-version of CFITSIO cannot handle that make a bug-report on that.)
HTH

Products


Release

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!