GNU Astronomy Utilities - Bugs: bug #59459, Unclear WCS when both PC and CD...
You are not allowed to post comments on this tracker with your current authentication level.
bug #59459: Unclear WCS when both PC and CD exist in input, but conflict
Submitter: | Alberto <drastyy> | ||
Submitted: | Fri 13 Nov 2020 10:00:28 AM UTC | ||
Category: | Fits | Severity: | 3 - Normal |
Item Group: | Output not reasonable | Status: | Fixed |
Privacy: | Public | Assigned to: | sks_15 |
Open/Closed: | Closed |
Fri 04 Dec 2020 11:06:25 PM UTC, comment #4: |
Mohammad Akhlaghi <makhlaghi> |
Thu 03 Dec 2020 07:58:31 PM UTC, comment #3: Yes, of course!!
|
Alberto <drastyy> |
Thu 03 Dec 2020 04:57:10 PM UTC, comment #2: Hi Alberto,
|
Sachin Kumar Singh <sks_15> |
Fri 13 Nov 2020 12:12:42 PM UTC, comment #1: The SIP <--> TPV conversion feature was written by Sachin, so I am assigning this task to him.
|
Mohammad Akhlaghi <makhlaghi> |
Fri 13 Nov 2020 10:00:28 AM UTC, original submission:
While I'm doing a transformation of the SIP to TPV coefficients with GNUastro, something strange happened when I did a coadd. After that, I tried to make the transformation with a python code and everything went well.
|
Alberto <drastyy> |
Depends on the following items: None found
Items that depend on this one: None found
There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.
Follow 7 latest changes.
Date | Changed by | Updated Field | Previous Value | => | Replaced by |
---|---|---|---|---|---|
2020-12-04 | makhlaghi | Status | None | Fixed | |
Open/Closed | Open | Closed | |||
Summary | Problem with SIP to TPV trasnformation | Unclear WCS when both PC and CD exist in input, but conflict | |||
Carbon-Copy | - | Added -email is unavailable- | |||
2020-11-13 | makhlaghi | Assigned to | None | sks_15 | |
2020-11-13 | drastyy | Attached File | - | Added header_Python_SIPtoTPV_transform.txt, #50267 | |
2020-11-13 | drastyy | Attached File | - | Added header_GNUastro_SIPtoTPV_transform.txt, #50266 |
Powered by Savane 3.13-d3ae.
Corresponding source code
With the help of Sachin, we think the problem has been fixed in Commit 7e74cba65d. But please read below (it may be important for your project)...
In short, Sachin found out that this FITS file contains both the PC and CD matrices of the WCS standard (which are different ways to map the pixels to the celestial coordinates). And more importantly, Sachin recognized that they produce different mappings! Usually a FITS file only has one of them, so this was strange! When they exist together, they are usually just different representations of the same mapping.
So I had a look at it (a small portion of it is shown below), and from the position of the headers, I saw the cause of the problem: astrometry.net had kept the original keywords but changed some of their names (except for the 'PCX_X' matric keywords!!!). Immediately after it, astrometry.net has just added its finally derived WCS after it. Here is a part of the header:
Because it had renamed the original CDELT keywords (which define the pixel scale for the PC matrix), but had kept the PC matrix keywords, the two PC and CD representations didn't match any more!!!
So I manually deleted the PC matrix elements with the command below, then converted the distortion to TPV and the problem was fixed: I checked by opening the TPV file with the SIP file without the PC matrix elements, in ds9. Then I matched both of them by WCS and the images matched perfectly. See below for the Python output that you originally posted.
Keeping old metadata (that is no longer relevant) is very bad practice, that causes terrible situations like this. Unfortunately many astronomical software follow this bad practice, causing headaches like this in later phases. But anyway, let's get back to the problem.
So the problem wasn't actually caused the SIP --> TPV conversion! It was caused by two different pixel <--> sky conversions in one file!!!
To avoid frustrations like this for future Gnuastro users, in Commit 7e74cba65d, I added a check for such cases: if the two mappings exist in the file, and they are different, Gnuastro will print a detailed warning and even suggest solutions. Then it will use the CD matrix (as described in the commit message).
THIS IS IMPORTANT FOR YOUR PROJECT: having the two conflicting PC and CD matrices had also caused ds9 to use the wrong WCS on the file. Open both the 'in.fits' and 'in-copy.fits' from the commands above in ds9 and look at the WCS pointing directions of the file you attached and you'll see what I mean.
Finally, after you remove the PC matrix and do the conversion, you'll notice that the PV coefficients will be different from what you initially posted from the Python script! This is the Gnuastro TPV keywords:
And here are the ones you posted in the Python output:
Since ds9 can correctly match the original image without the PC matrix and the Gnuastro-TPV image, we can say that Gnuastro's conversion is correct. So probably the Python script has also been confused by the conflicting PC and CD matrices.
You can get the most recent tarball that has this solution here.
https://akhlaghi.org/gnuastro.pdf
https://akhlaghi.org/gnuastro-latest.tar.lz
About this new tarball, let me just say that NoiseChisel's thresholding and sky subtraction step have been greatly improved in Commit 4a08b3fc205f. So if you modified NoiseChisel's default parameters, make sure they are also useful with this new version (it is much more robust, so I propose updating your NoiseChisel scripts as soon as possible ;-)). I'll post a few examples in the announcement for Gnuastro's 0.14 release.