Author Topic: xisf image does not properly save as int16 fits  (Read 3307 times)

Offline fgasdia

  • Newcomer
  • Posts: 7
xisf image does not properly save as int16 fits
« on: 2016 February 08 18:21:39 »
I went to save an xisf image as a signed 16 bit fits file, yet the fits that is produced has its BZERO value set to 32768 with the comment "offset data range to that of unsigned short". It appears to be saved in an int16 format, yet the data values of the image itself are effectively unsigned int16.

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: xisf image does not properly save as int16 fits
« Reply #1 on: 2016 February 09 00:18:25 »
XISF does not support signed integers to store pixel sample data, so when you select an integer format to save an XISF file, pixel data will always be stored as unsigned 8, 16 or 32-bit integers.

FITS keywords are always ignored by XISF. They are stored and retrieved as a compatibility layer to support applications and tools that still depend on FITS keywords, but they have no meaning from an XISF decoder's point of view, which acts just as a transmission channel for them.

Structural and reserved FITS keywords, such as BITPIX, NAXIS, BZERO and BSCALE for example, are stored in XISF headers just for informative purposes, but they do not reflect any actual property of the image. These keywords correspond to the image that was initially read in FITS format, but not to the image that has been stored in XISF format.  These keywords are always ignored and replaced automatically with valid values in case you decide---heaven forbid---to export the image in FITS format.

So there's no bug here, just the expected behavior.
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline fgasdia

  • Newcomer
  • Posts: 7
Re: xisf image does not properly save as int16 fits
« Reply #2 on: 2016 February 09 08:26:51 »
The problem is that if I go to the menu to save an image as (signed) int16 FITS, PixInsight has added the BZERO keyword 32768 and effectively saves the image data as unsigned int16.

I am a big supporter of moving away from FITS and embracing the XISF format. The backstory is that I had reduced some science images using the Image Calibration tool, but needed to analyze them using more basic astronomy software that was expecting signed int16 format. For my regular astrophotography, I use XISF throughout.

Perhaps the option to save as signed int16 should be removed if internally pixel data is stored as an unsigned integer?

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: xisf image does not properly save as int16 fits
« Reply #3 on: 2016 February 10 06:53:19 »
Bug confirmed. The FITS support module is ignoring signed/unsigned options selected by the user on the FITS Options dialog. Thank you for discovering this problem, and sorry for the inconvenience.

The good news is that this bug is now fixed. I'll release an update later today.
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: xisf image does not properly save as int16 fits
« Reply #4 on: 2016 February 10 06:56:43 »
Quote
I am a big supporter of moving away from FITS and embracing the XISF format.

Thank you so much for this. I really appreciate your support, as XISF is a crucial project where I am investing a lot of effort and resources. Hopefully we'll have a first official specification released before the end of February. I am currently working on the final XISF 1.0 specification document.
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: xisf image does not properly save as int16 fits
« Reply #5 on: 2016 February 10 08:23:51 »
The update is now available for all platforms. When saving signed integer images, note that BZERO=0 and BSCALE=1 are written by default to increase compatibility with other applications. If necessary, you can disable this feature on the FITS Format Preferences dialog, by unchecking the write scaling keywords to signed integer images option.

Let me know if the update fixes this bug completely. Of course I have verified that it does fix it, but having a double check is always nice ;)
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline fgasdia

  • Newcomer
  • Posts: 7
Re: xisf image does not properly save as int16 fits
« Reply #6 on: 2016 February 10 10:38:07 »
Thanks for getting the update out so quickly Juan! I can confirm that it fixed the issue.