def testDistortion(self): """Test computePixelToDistortedPixel with distortion pixelToDistortedPixel -> self.tanWcs should match a WCS created with makeDistortedTanWcs """ focalPlaneToFieldAngle = afwGeom.makeRadialTransform([0.0, self.radPerMm, 0.0, self.radPerMm]) pixelToDistortedPixel = computePixelToDistortedPixel( pixelToFocalPlane=self.pixelToFocalPlane, focalPlaneToFieldAngle=focalPlaneToFieldAngle, ) # Do not try to make pixelToDistortedPixel -> self.tanWcs into a WCS # because the frame names will be wrong; use a TransformPoint2Tolsst.geom.SpherePoint instead tanWcsTransform = afwGeom.TransformPoint2ToSpherePoint(self.tanWcs.getFrameDict()) pixelToDistortedSky = pixelToDistortedPixel.then(tanWcsTransform) wcs = makeDistortedTanWcs( tanWcs=self.tanWcs, pixelToFocalPlane=self.pixelToFocalPlane, focalPlaneToFieldAngle=focalPlaneToFieldAngle, ) bboxD = lsst.geom.Box2D(self.bbox) pixelPoints = bboxD.getCorners() pixelPoints.append(bboxD.getCenter()) skyPoints1 = pixelToDistortedSky.applyForward(pixelPoints) skyPoints2 = wcs.pixelToSky(pixelPoints) self.assertSpherePointListsAlmostEqual(skyPoints1, skyPoints2) pixelPoints1 = pixelToDistortedSky.applyInverse(skyPoints1) pixelPoints2 = wcs.skyToPixel(skyPoints1) assert_allclose(pixelPoints1, pixelPoints2)
def testDistortion(self): """Test computePixelToDistortedPixel with distortion pixelToDistortedPixel -> self.tanWcs should match a WCS created with makeDistortedTanWcs """ focalPlaneToFieldAngle = afwGeom.makeRadialTransform( [0.0, self.radPerMm, 0.0, self.radPerMm]) pixelToDistortedPixel = computePixelToDistortedPixel( pixelToFocalPlane=self.pixelToFocalPlane, focalPlaneToFieldAngle=focalPlaneToFieldAngle, ) # Do not try to make pixelToDistortedPixel -> self.tanWcs into a WCS # because the frame names will be wrong; use a TransformPoint2Tolsst.geom.SpherePoint instead tanWcsTransform = afwGeom.TransformPoint2ToSpherePoint( self.tanWcs.getFrameDict()) pixelToDistortedSky = pixelToDistortedPixel.then(tanWcsTransform) wcs = makeDistortedTanWcs( tanWcs=self.tanWcs, pixelToFocalPlane=self.pixelToFocalPlane, focalPlaneToFieldAngle=focalPlaneToFieldAngle, ) bboxD = lsst.geom.Box2D(self.bbox) pixelPoints = bboxD.getCorners() pixelPoints.append(bboxD.getCenter()) skyPoints1 = pixelToDistortedSky.applyForward(pixelPoints) skyPoints2 = wcs.pixelToSky(pixelPoints) self.assertSpherePointListsAlmostEqual(skyPoints1, skyPoints2) pixelPoints1 = pixelToDistortedSky.applyInverse(skyPoints1) pixelPoints2 = wcs.skyToPixel(skyPoints1) assert_allclose(pixelPoints1, pixelPoints2)
def testNoDistortion(self): """Test computePixelToDistortedPixel without distortion Use an affine transform for pixelToFocalPlane; the transform returned by computePixelToDistortedPixel should be the identity transform """ focalPlaneToFieldAngle = self.makeAffineTransform(scale=self.radPerMm) pixelToDistortedPixel = computePixelToDistortedPixel( pixelToFocalPlane=self.pixelToFocalPlane, focalPlaneToFieldAngle=focalPlaneToFieldAngle, ) bboxD = lsst.geom.Box2D(self.bbox) pixelPoints = bboxD.getCorners() pixelPoints.append(bboxD.getCenter()) assert_allclose(pixelToDistortedPixel.applyForward(pixelPoints), pixelPoints) assert_allclose(pixelToDistortedPixel.applyInverse(pixelPoints), pixelPoints)