Skip to content

Upgrade wcslib to 5.7 - #3905

Merged
mdboom merged 14 commits into
astropy:masterfrom
mdboom:wcs/upgrade-5.7
Jul 7, 2015
Merged

mdboom merged 14 commits into
astropy:masterfrom
mdboom:wcs/upgrade-5.7

Conversation

@mdboom

@mdboom mdboom commented Jun 30, 2015

Copy link
Copy Markdown
Contributor

This contains the "official" fix for the iteration bug in #3891, as well as a fix for the copying of distortion parameters in wcsprm objects in #3904.

In addition to vanilla 5.7, this includes a small fix for outputting FITS headers containing TPV distortions that in all likelihood will make it into wcslib 5.8. I've therefore designated the version 5.8.pre. (As well as a test for the issue by round-tripping a TPV WCS).

As per a discussion with @eteq and @astrofrog, this also adds a check that will raise an ImportError if the version of wcslib is one of the known broken ones in the 5.x series (currently anything prior to to-be-released 5.8). Unfortunately, there's no easy way to do this at build time -- it happens on the first import of a built astropy (which obviously includes running the tests). There was no version specifier in versions prior to 5.x, so we just act as if all 4.x versions are fine (which isn't quite true).

This also adds a test for the issue in #3904.

@mdboom mdboom added wcs Affects-dev PRs and issues that do not impact an existing Astropy release Bug labels Jun 30, 2015
@mdboom mdboom added this to the v1.1.0 milestone Jun 30, 2015
@eteq

eteq commented Jul 1, 2015

Copy link
Copy Markdown
Member

Just tested it now, and this fixes #3904, so now DECAM TPV images load correctly! 👏 (So this closes #3904).

I think your solution to the versioning problem is as good as we're going to do given the limitations available to us with WCSLIB, so it seems good to me.

Comment thread astropy/wcs/wcs.py Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe have this instead be something like "only 5.8 and later (or the verion packaged with astropy)"? I.e., make it clear that a possible "solution" is to use the builtin one if for whatever reason it's difficult to upgrade wcslib

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@eteq

eteq commented Jul 1, 2015

Copy link
Copy Markdown
Member

One other thought: maybe you should actually add a test using only the headers from an image HDU copied from a DECAM image (a la what I was checking in #3904)? That seems like a decent way to do a regression test without the full image.

@mdboom

mdboom commented Jul 1, 2015

Copy link
Copy Markdown
Contributor Author

One other thought: maybe you should actually add a test using only the headers from an image HDU copied from a DECAM image (a la what I was checking in #3904)?

I already have a test using a TPV header. It's not a DECAM image, but I think the only thing necessary to reproduce the error is that it contains TPV coefficients. Or am I missing something?

@eteq

eteq commented Jul 7, 2015

Copy link
Copy Markdown
Member

@mdboom - oops, missed that. So yes, that's perfect then.

@embray

embray commented Jul 7, 2015

Copy link
Copy Markdown
Member

Seems good to go then.

mdboom added a commit that referenced this pull request Jul 7, 2015
@mdboom
mdboom merged commit 51e0824 into astropy:master Jul 7, 2015
Comment thread astropy/wcs/wcs.py

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mdboom Is there a reason this line was removed? If empty lines in the header don't get removed, calling to_header creates fits cards like keyword=" " , value = None. This came up just now because wcslib 5.8 adds an empty line and a comment line. Here's what I mean:

w.to_header()
Out[13]: 
WCSAXES =                    2 / Number of coordinate axes                      
CRPIX1  =               2048.0 / Pixel coordinate of reference point            
CRPIX2  =               1024.0 / Pixel coordinate of reference point            
PC1_1   =    1.29055156974E-05 / Coordinate transformation matrix element       
PC1_2   =    5.95250078647E-06 / Coordinate transformation matrix element       
PC2_1   =    5.02263819607E-06 / Coordinate transformation matrix element       
PC2_2   =   -1.26448441522E-05 / Coordinate transformation matrix element       
CDELT1  =                  1.0 / [deg] Coordinate increment at reference point  
CDELT2  =                  1.0 / [deg] Coordinate increment at reference point  
CUNIT1  = 'deg'                / Units of coordinate increment and value        
CUNIT2  = 'deg'                / Units of coordinate increment and value        
CTYPE1  = 'RA---TAN-SIP'       / TAN (gnomonic) projection + SIP distortions    
CTYPE2  = 'DEC--TAN-SIP'       / TAN (gnomonic) projection + SIP distortions    
CRVAL1  =        5.63056810618 / [deg] Coordinate value at reference point      
CRVAL2  =       -72.0545718428 / [deg] Coordinate value at reference point      
LONPOLE =                180.0 / [deg] Native longitude of celestial pole       
LATPOLE =       -72.0545718428 / [deg] Native latitude of celestial pole        
WCSNAME = 'IDC_postsm4'        / Coordinate system title                        
RADESYS = 'FK5'                / Equatorial coordinate system                   
EQUINOX =               2000.0 / [yr] Equinox of equatorial coordinates         

COMMENT  WCS header keyrecords produced by WCSLIB 5.8         

I have code that loops over WCS keywords and changes them. I'll change my code to look for empty lines and comments but just wondering if the previous behaviour is not preferable,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that line may just have been removed in error -- there was lots of juggling how the header is parsed here so we can edit it and pass the edited version (with SIP removed for example) to wcslib.

But I'm not sure how the strip would help here -- it wouldn't remove any blank FITS lines unless they were at the end.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are right. However the absence of this line, and the addition of a new line and a comment have the same effect, in the sense that they create keywords which are not in the WCS standard and I expect WCS.to_header to return WCS keywords only. Yeah, I agree it returns a valid header but I wish this kind of behaviour change was handled through the relax keyword or not introduced at all. It just adds noise.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could modify to_header to remove these lines...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Do you want me to make a PR or do you prefer to make it? It's either removing these lines or I have to make numerous changes in stwcs.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 This change is unexpectedly hard to handle.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I almost have a PR -- stay tuned...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Affects-dev PRs and issues that do not impact an existing Astropy release Bug wcs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants