vrruiz / xisfits

Convert images from XISF to FITS
MIT License
8 stars 0 forks source link

Conversion fails on anything not test data (missing vital keywords) #17

Closed IvoJager closed 3 years ago

IvoJager commented 4 years ago

Hi,

I was looking at this project for a StarTools user who was looking for a solution to convert XISF-locked data into universal FITS data. Unfortunately, right now, conversion fails (latest master) for any XISF file I throw at it, except the test data.

The files are converted, however inspection with a hexviewer reveals vital keywords (SIMPLE, BITPIX, NAXIS, etc. are all missing). It appears the data blobs are correctly extracted and appended to the header however. Visible keywords are mostly HISTORY and COMMENT keywords, with little else. The END keyword is also correctly generated. As a result, any application with FITS import capability fails to interpret the generated files correctly.

Any ideas what the problem might be here?

cargo 1.42.0 (86334295e 2020-01-31) on Linux

IvoJager commented 4 years ago

I was able to get it to output the needed keywords by forcing it to always execute fitswriter::fits_write_data(cli.output(), &fits_hd)?; and never fitswriter::fits_write_data_keywords(cli.output(), &fits_hd, &xisf_fits_keywords)?;

Obviously we're now missing out on any non-header keywords, but at least we got a usable/liberated image now!

vrruiz commented 4 years ago

Hi! Would you be able to share one of those files with me so I can debug the problem? The fits_write_data_keywords is used when there is an embedded FITS header in the XISF file, so the program tries to preserve those. fits_write_data creates the FITS header from scratch. The problem may lie there.

IvoJager commented 4 years ago

Many thanks for looking into this! I don't own any of the files myself, but one example can currently be found in this post; https://www.cloudynights.com/topic/700134-m106-processing-practicing-questions-non-uniform-color-background/?p=10081601 (I usually like to keep things on-topic on github, but quickly wanted to wish you safety and good health!)

karolbe commented 4 years ago

Also, I noticed that any file converted and loaded into Siril is truncated. I have never had any issues with Siril (https://gitlab.com/free-astro/siril) and fits images so I can only guess that this is due to incorrect conversion.

vrruiz commented 4 years ago

Weird. I’ll take a look.

vrruiz commented 4 years ago

Ok. Seems that some of the refactoring done during August introduced a regression (which also means that the current tests are missing additional checks). Do git checkout cc3cbedd5a1bc43a46001fa24a71baf92880e55a before compiling to get a working version.

karolbe commented 4 years ago

Thanks for quick reply. I tested that version and I am now getting these errors:

09:33:16: FITS error: This does not look like a FITS file.
09:33:16: FITS error: Extension doesn't start with SIMPLE or XTENSION keyword. (ffrhdu)
09:33:16: FITS error: OBSERVER = 'Blaki Stella'      / Observer who acquired the data
09:33:16: FITS error: ffopen could not interpret primary array header of file: 
09:33:16: FITS error: /run/media/kbryd/My Book/Astro/Ekspertymenty/IC1318/drive-download-20200901T1309
09:33:16: FITS error: 48Z-001/integration S2 odszumione po masked stretch.fit
09:33:16: FITS error: This does not look like a FITS file.
09:33:16: FITS error: Extension doesn't start with SIMPLE or XTENSION keyword. (ffrhdu)
09:33:16: FITS error: OBSERVER = 'Blaki Stella'      / Observer who acquired the data
09:33:16: FITS error: ffopen could not interpret primary array header of file: 
09:33:16: FITS error: /run/media/kbryd/My Book/Astro/Ekspertymenty/IC1318/drive-download-20200901T1309
09:33:16: FITS error: 48Z-001/integration S2 odszumione po masked stretch.fit
09:33:16: FITS error: This does not look like a FITS file.
09:33:16: FITS error: Extension doesn't start with SIMPLE or XTENSION keyword. (ffrhdu)
09:33:16: FITS error: OBSERVER = 'Blaki Stella'      / Observer who acquired the data
09:33:16: FITS error: ffopen could not interpret primary array header of file: 
09:33:16: FITS error: /run/media/kbryd/My Book/Astro/Ekspertymenty/IC1318/drive-download-20200901T1309
09:33:16: FITS error: 48Z-001/integration S2 odszumione po masked stretch.fit
09:33:16: FITS error: This does not look like a FITS file.
09:33:16: FITS error: Extension doesn't start with SIMPLE or XTENSION keyword. (ffrhdu)
09:33:16: FITS error: OBSERVER = 'Blaki Stella'      / Observer who acquired the data
09:33:16: FITS error: ffopen could not interpret primary array header of file: 
09:33:16: FITS error: /run/media/kbryd/My Book/Astro/Ekspertymenty/IC1318/drive-download-20200901T1309
09:33:16: FITS error: 48Z-001/integration S2 odszumione po masked stretch.fit
09:33:16: FITS error: This does not look like a FITS file.
09:33:16: Opening /run/media/kbryd/My Book/Astro/Ekspertymenty/IC1318/drive-download-20200901T130948Z-001/integration S2 odszumione po masked stretch.fit failed.
vrruiz commented 4 years ago

Hmm... This is unexpected: «Extension doesn't start with SIMPLE or XTENSION keyword». All FITS files start with the SIMPLE keyword. With the pre-August code, I converted a test file and PixInsight loaded the resulting FITS file correctly (uses the same FITS library as Siril).

Can you share the XISF file with me?

karolbe commented 4 years ago

I am not an owner of the file and I took it from a forum (registration required) so I am not sure if I can post it publicly here. Is there some other private way I can send it to you?

vrruiz commented 4 years ago

I've fixed the truncated image problem. Can you check with the latest version?