Skip to content

Commit 9c8479f

Browse files
authored
Remove heuristic code to handle PTF files which is causing a bug
Fix for astropy#14255 . Currently the `_fix_scamp` function remove any PV keywords when SIP distortions are present and no radial terms are present which should not be the case. This function was put in place for solving astropy#299 but it causes the bug astropy#14255. We can either keep adding heuristic code to fix the edge cases as they come up with or remove the edge-cases and let the user deal with non-standard file. I'm opening a pull request for the latter following the discusison in astropy#14255.
1 parent f557c0f commit 9c8479f

1 file changed

Lines changed: 0 additions & 47 deletions

File tree

‎astropy/wcs/wcs.py‎

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -705,52 +705,6 @@ def sub(self, axes=None):
705705
if _wcs is not None:
706706
sub.__doc__ = _wcs.Wcsprm.sub.__doc__
707707

708-
def _fix_scamp(self):
709-
"""
710-
Remove SCAMP's PVi_m distortion parameters if SIP distortion parameters
711-
are also present. Some projects (e.g., Palomar Transient Factory)
712-
convert SCAMP's distortion parameters (which abuse the PVi_m cards) to
713-
SIP. However, wcslib gets confused by the presence of both SCAMP and
714-
SIP distortion parameters.
715-
716-
See https://github.com/astropy/astropy/issues/299.
717-
"""
718-
# Nothing to be done if no WCS attached
719-
if self.wcs is None:
720-
return
721-
722-
# Nothing to be done if no PV parameters attached
723-
pv = self.wcs.get_pv()
724-
if not pv:
725-
return
726-
727-
# Nothing to be done if axes don't use SIP distortion parameters
728-
if self.sip is None:
729-
return
730-
731-
# Nothing to be done if any radial terms are present...
732-
# Loop over list to find any radial terms.
733-
# Certain values of the `j' index are used for storing
734-
# radial terms; refer to Equation (1) in
735-
# <http://web.ipac.caltech.edu/staff/shupe/reprints/SIP_to_PV_SPIE2012.pdf>.
736-
pv = np.asarray(pv)
737-
# Loop over distinct values of `i' index
738-
for i in set(pv[:, 0]):
739-
# Get all values of `j' index for this value of `i' index
740-
js = set(pv[:, 1][pv[:, 0] == i])
741-
# Find max value of `j' index
742-
max_j = max(js)
743-
for j in (3, 11, 23, 39):
744-
if j < max_j and j in js:
745-
return
746-
747-
self.wcs.set_pv([])
748-
warnings.warn(
749-
"Removed redundant SCAMP distortion parameters "
750-
+ "because SIP parameters are also present",
751-
FITSFixedWarning,
752-
)
753-
754708
def fix(self, translate_units="", naxis=None):
755709
"""
756710
Perform the fix operations from wcslib, and warn about any
@@ -790,7 +744,6 @@ def fix(self, translate_units="", naxis=None):
790744
invoked.
791745
"""
792746
if self.wcs is not None:
793-
self._fix_scamp()
794747
fixes = self.wcs.fix(translate_units, naxis)
795748
for key, val in fixes.items():
796749
if val != "No change":

0 commit comments

Comments
 (0)