Skip to content

Commit 2325a09

Browse files
committed
Remove redundant SCAMP distorition parameters when SIP is also present
Fixes astropy#299.
1 parent bbd9ec4 commit 2325a09

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
@@ -437,12 +437,28 @@ def sub(self, axes=None):
437437
if _wcs is not None:
438438
sub.__doc__ = _wcs.Wcsprm.sub.__doc__
439439

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

0 commit comments

Comments
 (0)