Skip to content

Commit

Permalink
Remove computation of extra distortion model
Browse files Browse the repository at this point in the history
Handling of camera geometry distortions is now done when reading the
raw files: we don't want to overwrite that here. Leaving the methods
that can do the work for a deprecation period.

Deprecate the config option.
  • Loading branch information
parejkoj committed Jul 23, 2019
1 parent 697fdba commit c9e059b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 23 deletions.
2 changes: 2 additions & 0 deletions python/lsst/ip/isr/isrFunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,8 @@ def attachTransmissionCurve(exposure, opticsTransmission=None, filterTransmissio
return combined


@deprecated(reason="Camera geometry-based SkyWcs are now set when reading raws. To be removed after v19.",
category=FutureWarning)
def addDistortionModel(exposure, camera):
"""!Update the WCS in exposure with a distortion model based on camera
geometry.
Expand Down
11 changes: 2 additions & 9 deletions python/lsst/ip/isr/isrTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,8 @@ class IsrTaskConfig(pexConfig.Config):
dtype=bool,
doc="Apply a distortion model based on camera geometry to the WCS?",
default=True,
deprecated=("Camera geometry is incorporated when reading the raw files."
" This option no longer is used, and will be removed after v19.")
)

# Initial CCD-level background statistics options.
Expand Down Expand Up @@ -1167,8 +1169,6 @@ def run(self, ccdExposure, camera=None, bias=None, linearizer=None, crosstalkSou
raise RuntimeError("Must supply a flat exposure if config.doFlat=True.")
if self.config.doDefect and defects is None:
raise RuntimeError("Must supply defects if config.doDefect=True.")
if self.config.doAddDistortionModel and camera is None:
raise RuntimeError("Must supply camera if config.doAddDistortionModel=True.")
if (self.config.doFringe and filterName in self.fringe.config.filters and
fringes.fringes is None):
# The `fringes` object needs to be a pipeBase.Struct, as
Expand Down Expand Up @@ -1377,10 +1377,6 @@ def run(self, ccdExposure, camera=None, bias=None, linearizer=None, crosstalkSou
sensorTransmission=sensorTransmission,
atmosphereTransmission=atmosphereTransmission)

if self.config.doAddDistortionModel:
self.log.info("Adding a distortion model to the WCS.")
isrFunctions.addDistortionModel(exposure=ccdExposure, camera=camera)

flattenedThumb = None
if self.config.qa.doThumbnailFlattened:
flattenedThumb = isrQa.makeThumbnail(ccdExposure, isrQaConfig=self.config.qa)
Expand Down Expand Up @@ -1491,9 +1487,6 @@ def runDataRef(self, sensorRef):
ccdExposure = sensorRef.get(self.config.datasetType)

camera = sensorRef.get("camera")
if camera is None and self.config.doAddDistortionModel:
raise RuntimeError("config.doAddDistortionModel is True "
"but could not get a camera from the butler.")
isrData = self.readIsrData(sensorRef, ccdExposure)

result = self.run(ccdExposure, camera=camera, **isrData.getDict())
Expand Down
18 changes: 4 additions & 14 deletions tests/test_addDistortionModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@
import lsst.ip.isr.isrFunctions as isrFunctions


class ApplyLookupTableTestCase(lsst.utils.tests.TestCase):
"""Test IsrTask.addDistortionModel
class AddDistortionModelTestCase(lsst.utils.tests.TestCase):
"""Test IsrTask.addDistortionModel.
DEPRECATED: to be removed with addDistortionModel
"""

def setUp(self):
Expand Down Expand Up @@ -83,18 +85,6 @@ def makeDesiredDistortedWcs(self):
focalPlaneToFieldAngle = self.camera.getTransformMap().getTransform(FOCAL_PLANE, FIELD_ANGLE)
return makeDistortedTanWcs(self.wcs, pixelToFocalPlane, focalPlaneToFieldAngle)

def testRunWithAddDistortionModel(self):
"""Test IsrTask.run with config.doAddDistortionModel true"""
isrConfig = self.makeMinimalIsrConfig()
isrConfig.doAddDistortionModel = True
isrTask = IsrTask(config=isrConfig)
with self.assertRaises(RuntimeError):
# the camera argument is required
isrTask.run(ccdExposure=self.exposure)
exposure = isrTask.run(ccdExposure=self.exposure, camera=self.camera).exposure
desiredWcs = self.makeDesiredDistortedWcs()
self.assertWcsAlmostEqualOverBBox(desiredWcs, exposure.getWcs(), self.bbox)

def testRunWithoutAddDistortionModel(self):
"""Test IsrTask.run with config.doAddDistortionModel false"""
isrConfig = self.makeMinimalIsrConfig()
Expand Down

0 comments on commit c9e059b

Please sign in to comment.