[fitsbits] Possible bug in CFITSIO

Gordon, Craig A. (GSFC-660.1)[INNOVIM] craig.a.gordon at nasa.gov
Fri Feb 28 10:55:46 EST 2020


Hi David,

What Thierry wrote about the BITPIX keyword is correct.  It is merely telling you the size needed in storing the pixels in the image file.  However CFITSIO provides a function fits_get_img_equivtype described here:

https://heasarc.gsfc.nasa.gov/docs/software/fitsio/c/c_user/node40.html#ffgidt

which will perform the conversion in your example below.  That is, it takes into account the BITPIX, BZERO, and BSCALE values and then reports the equivalent type of the array for receiving the data.  In your example that would be USHORT_IMG.

-Craig

________________________________
From: THIERRY FORVEILLE <thierry.forveille at univ-grenoble-alpes.fr>
Sent: Friday, February 28, 2020 7:08 AM
To: David C. Partridge <david.partridge at perdrix.co.uk>
Cc: William Pence <wdpence2000 at yahoo.com>; CCFITS Help Desk <ccfits at heasarc.gsfc.nasa.gov>; fitsbits at listmgr.nrao.edu <fitsbits at listmgr.nrao.edu>
Subject: Re: [fitsbits] Possible bug in CFITSIO


> So for clarity:
>
>
>
> Are you saying that if the headers of a 16 bit FITS file say:
>
>
>
>    SIMPLE  =                    T / file does conform to FITS standard
>
>    BITPIX  =                   16 / number of bits per data pixel
>
>    BZERO   =                32768 / offset data range to that of unsigned short
>
>    BSCALE  =                    1 / default scaling factor
>
>
>
> that I should ignore the fact the BITPIX is telling me to use signed short,
>
BITPIX is not telling you what to use in your code, just what's stored in the
file. _That_ is signed shorts, but what you convert it to is totally up to you.
I'd use floats (because I'll promptly do things like averaging multiple images,
and those of course step out of the integer space), but you are welcome to use
unsigned shorts if you like, or signed longs, or even complex doubles for the
matter.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listmgr.nrao.edu/pipermail/fitsbits/attachments/20200228/8c99dc97/attachment.html>


More information about the fitsbits mailing list