Skip to content

Commit 11f3647

Browse files
committed
Remove redundant SCAMP distorition parameters when SIP is also present
Fixes astropy#299.
1 parent 96b7a1d commit 11f3647

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

‎astropy/wcs/wcs.py‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,12 +438,28 @@ def sub(self, axes=None):
438438
if _wcs is not None:
439439
sub.__doc__ = _wcs.Wcsprm.sub.__doc__
440440

441+
def _fix_scamp(self):
442+
"""
443+
Remove SCAMP's PVi_m distortion parameters if SIP distortion parameters
444+
are also present. Some projects (e.g., Palomar Transient Factory)
445+
convert SCAMP's distortion parameters (which abuse the PVi_m cards) to
446+
SIP. However, wcslib gets confused by the presence of both SCAMP and
447+
SIP distortion parameters.
448+
449+
See https://github.com/astropy/astropy/issues/299.
450+
"""
451+
if self.wcs is not None and self.wcs.get_pv() and all(ctype.endswith('-SIP') for ctype in self.wcs.ctype):
452+
self.wcs.set_pv([])
453+
warnings.warn("Removed redundant SCAMP distortion parameters " +
454+
"because SIP parameters are also present", FITSFixedWarning)
455+
441456
def fix(self):
442457
"""
443458
Perform the fix operations from wcslib, and warn about any
444459
changes it has made.
445460
"""
446461
if self.wcs is not None:
462+
self._fix_scamp()
447463
fixes = self.wcs.fix()
448464
for key, val in fixes.iteritems():
449465
if val != "No change":

0 commit comments

Comments
 (0)