def testCameraRaises(self): for cw in self.cameraList: camera = cw.camera point = lsst.geom.Point2D(0, 0) # non-existant source camera system with self.assertRaises(pexExcept.InvalidParameterError): camera.getTransform(CameraSys("badSystem"), FOCAL_PLANE) with self.assertRaises(pexExcept.InvalidParameterError): camera.transform(point, CameraSys("badSystem"), FOCAL_PLANE) # non-existant destination camera system with self.assertRaises(pexExcept.InvalidParameterError): camera.getTransform(FOCAL_PLANE, CameraSys("badSystem")) with self.assertRaises(pexExcept.InvalidParameterError): camera.transform(point, FOCAL_PLANE, CameraSys("badSystem")) # non-existent source detector with self.assertRaises(KeyError): camera.getTransform(CameraSys("pixels", "invalid"), FOCAL_PLANE) with self.assertRaises(KeyError): camera.transform(point, CameraSys("pixels", "invalid"), FOCAL_PLANE) # non-existent destination detector with self.assertRaises(KeyError): camera.getTransform(FOCAL_PLANE, CameraSys("pixels", "invalid")) with self.assertRaises(KeyError): camera.transform(point, FOCAL_PLANE, CameraSys("pixels", "invalid"))
def testCameraSysRepr(self): """Test CameraSys.__repr__ and CameraSysPrefix.__repr__ """ for sysName in ("FocalPlane", "FieldAngle", "Pixels", "foo"): cameraSys = CameraSys(sysName) predRepr = "CameraSys(%s)" % (sysName) self.assertEqual(repr(cameraSys), predRepr) cameraSysPrefix = CameraSysPrefix(sysName) predCSPRepr = "CameraSysPrefix(%s)" % (sysName) self.assertEqual(repr(cameraSysPrefix), predCSPRepr) for detectorName in ("Detector 1", "bar"): cameraSys2 = CameraSys(sysName, detectorName) predRepr2 = "CameraSys(%s, %s)" % (sysName, detectorName) self.assertEqual(repr(cameraSys2), predRepr2)
def testMakeCameraPoint(self): point = afwGeom.Point2D(0,0) for cw in self.cameraList: camera = cw.camera for coordSys in (PUPIL, FOCAL_PLANE): pt1 = afwGeom.Point2D(0.1, 0.3) pt2 = afwGeom.Point2D(0., 0.) pt3 = afwGeom.Point2D(-0.2, 0.2) pt4 = afwGeom.Point2D(0.02, -0.2) pt5 = afwGeom.Point2D(-0.2, -0.03) for pt in (pt1, pt2, pt3, pt4, pt5): cp = camera.makeCameraPoint(pt, coordSys) self.assertEquals(cp.getPoint(), pt) self.assertEquals(cp.getCameraSys().getSysName(), coordSys.getSysName()) # test == and != cp2 = camera.makeCameraPoint(pt, coordSys) self.assertTrue(cp == cp2) self.assertFalse(cp != cp2) det = camera[camera.getNameIter().next()] cp = camera.makeCameraPoint(point, FOCAL_PLANE) self.checkCamPoint(cp, point, FOCAL_PLANE) cp = camera.makeCameraPoint(point, det.makeCameraSys(PIXELS)) self.checkCamPoint(cp, point, det.makeCameraSys(PIXELS)) #non-existant camera sys in makeCameraPoint self.assertRaises(RuntimeError, camera.makeCameraPoint, point, CameraSys('abcd')) #CameraSysPrefix camera sys in makeCameraPoint self.assertRaises(TypeError, camera.makeCameraPoint, point, PIXELS)
def testCameraRaises(self): for cw in self.cameraList: camera = cw.camera cp = camera.makeCameraPoint(afwGeom.Point2D(1e6,1e6), FOCAL_PLANE) #Way off the focal plane self.assertRaises(RuntimeError, camera.transform, cp, PIXELS) #non-existant destination camera system cp = camera.makeCameraPoint(afwGeom.Point2D(0,0), FOCAL_PLANE) self.assertRaises(RuntimeError, camera.transform, cp, CameraSys('abcd'))