-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update WCSLIB to 7.4 with fix for wcshdo
export of complete TPD coefficients
#11260
Conversation
Even if we are going to handle this internally in |
Yes, this is only meant as a kind of template how to fix it in WCSLIB. Ideally upstream could apply something equivalent not too long from now, then the new version might even be added to our In addition, if Setting up an email to mcalabre to discuss the first part. |
@dhomeier Thank you! |
I am tentatively marking this for 4.3. Thanks! |
wcshdo
to export complete TPD coefficients to FITS headerwcshdo
export of complete TPD coefficients
Big thanks to Mark Calabretta for quickly merging the patch and getting it into WCSLIB 7.4, released yesterday! |
Anyone familiar with the compiler on CI / 32-bit? |
Was adding In addition to the library update, I made one change to And the original issue in #11216 is still open, since an old-style WCS distortion header is still read in assuming |
Not familiar, but I suggest we declare |
@nden What do you think?
First, I did not know that we removed comments obtained from Second, about In any case, I would prefer to have this addition be done in a different PR separate from WCSLIB update. |
As I read the discussion back in #3905 the primary incentive was to remove the empty lines, and beyond that, that COMMENT keywords are not part of the WCS standard, which I don't entirely follow... But it sounds indeed as if the comment may still cause problems in Anyway keeping the version info as a COMMENT instead requires two more wcs tests to be adapted, easily enough dealt with, plus |
I do not think comments should cause technical problems. However, imagine you will get a file with multiple (let's say 4) WCSes in the header and when you inspect that file you will find:
How would you know which WCS was created with what WCSLIB. I think it just creates confusion and does not really help unless you always have only one WCS. By the way, in the example above, assume 4th WCS was created "by hand" by an user directly editing the header (or by some function in a third-party package like I think making Maybe we should add another parameter to However, I do not like my own suggestion (I do not think it add much practical value). Also, for HST images, we convert |
Maybe comment could be made more informative, like this:
The more I think about it, the less I like the idea of adding a new header keyword that, IMO, will contribute to more confusion. |
I think several different WCSs created with all different versions or libraries in one file or even HDU are bound to create confusion in the first place. The comments are appended to the end of each header section created by a WCS, so ideally they would stay in that place to be somewhat associated with the corresponding WCS. But I admit that we probably cannot guarantee that order to be preserved though all the potential header updates. Still, I think having the different WCS version with no direct trace of their origin, but say, one implementing the pre-6.3 behaviour of the TPD coefficients, and another the current one, would be even more confusing. For the For the alternative of defining a new keyword, this could make the information less ambiguous, but then storing them for each WCS would probably require another class of structured keywords; in short I do not like the effort in defining this in a FITS- and WCS-standard-conforming way either. In conclusion I probably like your last suggestion to add WCSNAME and info on other creators to the comment best. |
@dhomeier Thank you! Could you please rebase and reorder/squash/drop some of the commits in such a way that you have maybe three commits left: adding WCSLIB 7.4, fixing C code, and updating tests? |
WCSLIB version 7.4 was released on 2021/01/31 by Mark Calabretta. It contains a number of important bug fixes, particularly for wcshdo(), and enhancements, as per the change log appended below. ------------------------------- * C library - In wcshdo(), fixed a bug introduced in release 5.9 that potentially caused loss of numerical precision in the sprintf() formatting of floating point keyvalues. This was triggered when a large range of CRPIXja, PCi_ja, or CDELTia values (as three separate groups) were formatted using an 'f' format descriptor, the range not being so large that it would have forced wcshdo() to revert to 'E' format. Reported by Mohammad Akhlaghi. Also in wcshdo(), fixed a bug introduced in release 7.1 that caused the coefficients of the TPD distortion function not to be written to the header. TPD and Polynomial distortion function headers will now always include the DPja.DOCORR keyword. Reported by Derek Homeier with patch. - In wcsset(), fixed a segv generated in attempting to report a non- standard units string with wcserr message reporting disabled. Reported by Mohammad Akhlaghi. In wcsutrne(), allow 'Angstroms' and 'angstroms' as additional synonyms for 'Angstrom'. - In datfix(), ensure that 0 is returned if an informational message is set in wcsprm::err. Consequent on feedback independently from Mihai Cara and Bruce Merry. Clarified that informational messages may be set in wcsprm::err for returns of 0 from datfix(), obsfix(), unitfix(), and spcfix(). * User manual - Added cautions about translating CDi_ja to PCi_ja plus CDELTia for those historical distortion functions (TPV, TNX, ZPX) that expect to operate on intermediate world coordinates, rather than intermediate pixel coordinates. Consequent on feedback from Mohammad Akhlaghi. - Documentation generation moved to doxygen 1.9.1 (was 1.8.19).
Updated versions and warnings in wcs/tests, ignore wcs.FITSFixedWarning; add test_distortion_header for TPD coefficients in to_header and Cutout2D. Fixed wcshdo_format syntax to build with < C99 compilers. Co-authored-by: Mihai Cara <mcara@users.noreply.github.com>
Added a warning now - tested locally with external WCSLIB 7.3.1; I think all CI jobs are set up to build against the bundled version, so they will miss this. |
Was there a patch to wcslib in this PR? If so, I'd like to see it as a separate commit and also document it so next time there is a wcslib release we can follow up. (It should really be fixed in wcslib.) |
Patch to
You mean just record it in an issue? I was thinking of something equivalent to In the end it perhaps boils down to where to place a recipe like if 'DQ1.DOCORR' not in header:
header.insert('CQDIS1', ('DQ1', 'DOCORR: 0'), after=True) for fixing deprecated headers. |
wcslib 7.4 was patched before merging. |
@nden could you hold this for another day? Mark has sent me a mail about the C99 issues, and I'd like to look into fixing the build of |
Oops, too late. Can you do it on a separate PR or do you want me to revert it? |
Indeed, as WCSLIB's |
So may be create a PR for this and remove the patch there? |
Oh, well. Whatever is easier. It's just another one-line change, but the |
With this, I now see a new warning |
I found on possible change to return value of + if (status == FIXERR_NO_CHANGE) status = FIXERR_SUCCESS; Maybe you can bug @mcara about it, who seems to have been mentioned in this context 😄
– it looks like in your example there were no changes actually made? This would previously have returned -1, but now it has apparently become indistinguishable from 0 (successful changes); not sure if this was fully intended. |
Where do you even report these things upstream to wcslib? Does it have a GitHub? And thanks for the very useful info, @dhomeier ! |
Ha, I suspect it has been developed and archived safely in a set of tarfiles on Mark Calabretta's disk for a quarter-century! |
I am sorry, I probably missed most of the discussion on So what is going on @pllim with the |
@mcara these are the changes in question, which are part of the entire 7.4 update astropy/cextern/wcslib/C/wcsfix.c Line 363 in d971b1c
astropy/cextern/wcslib/C/wcsfix.c Line 586 in d971b1c
I am wondering of the motivation was to output the diagnostic message here astropy/cextern/wcslib/C/wcsfix.c Lines 181 to 191 in d971b1c
but then, was only the old return value of -1 treated as success, and 0 as warning level? |
Description
#11216 (comment) described an inconsistency in WCSLIB's
iparm
parameter lists indis.c
andwcshdr.c
, introduced somewhere between 6.4 (c754932) and 7.1 (56fbc3d), wheniparm[I_DOCORR]
was removed fromdis.c
, but not inwcshdr.c
. As a result, that parameter is not correctly checked to switch on writing of theAUX.*
andTPD.FWD.*
coefficients bywcs.to_header()
, which consequently creates an incomplete distortion model (applying no distortion at all) in the header.The differences to the correct WCS with distortion are found when directly creating a new
WCS
from that header or from aCutout2D
produced from the original, either directly or when written to file and read back (see addedtest_distortion_header
for examples).Fixes part of #11216 (old files written with missing
'DOCORR: 0'
keyword will still not be read in correctly with current WCSLIB, which has'DOCORR: 1'
as default since 6.3).Since we want to create correct headers when linking a system WCSLIB, this requires an upstream fix, but as I don't know the best way to send patches to https://www.atnf.csiro.au/people/mcalabre/WCS/, I have added a proposed fix in the bundled
wcslib
here as a suggestion.I'd also like to propose keeping the info comment à la
Translated from DSS to TPD by WCSLIB 7.3.0
inwcs.to_header()
, as the issues in #11216 show that this information can be rather useful. This would require updating a number of tests checking for (no)COMMENT
cards in the header though, so maybe it could be alternatively be written to its own card likeWCSVER = 7.3.0 / Translated from DSS to TPD by WCSLIB 7.3.0