22 from __future__
import absolute_import, division
23 from .cameraGeomLib
import CameraPoint, CameraSysPrefix, PIXELS
24 from .detectorCollection
import DetectorCollection
28 """!A collection of Detectors that also supports coordinate transformation
30 def __init__(self, name, detectorList, transformMap):
31 """!Construct a Camera
33 @param[in] name name of camera
34 @param[in] detectorList a sequence of detectors in index order
35 @param[in] transformMap a CameraTransformMap whose native system is FOCAL_PLANE
36 and that at least supports PUPIL coordinates
41 super(Camera, self).
__init__(detectorList)
44 """!Return the camera name
49 """!Transform a point in the native coordinate system to another coordinate system.
51 @param[in] nativePoint CameraPoint in the native system for the camera
52 @param[in] toSys destination CameraSys
53 @return CameraPoint in the destination CameraSys
55 if isinstance(toSys, CameraSysPrefix):
59 raise RuntimeError(
"No detectors found")
60 elif len(detList) > 1:
61 raise RuntimeError(
"More than one detector found")
64 return det.transform(nativePoint, toSys)
69 """!Transform a CameraPoint with a CameraSys to another CameraSys.
71 @warning This method only handles a single jump, not a transform linked by a common native sys.
73 @param[in] cameraPoint CameraPoint to transform
74 @param[in] toSys Destination coordinate system
76 fromSys = cameraPoint.getCameraSys()
77 if fromSys.hasDetectorName():
79 det = self[fromSys.getDetectorName()]
80 return det.transform(cameraPoint, toSys)
81 elif toSys.hasDetectorName():
83 det = self[toSys.getDetectorName()]
84 return det.transform(cameraPoint, toSys)
87 outPoint = self._transformMap.transform(cameraPoint.getPoint(), cameraPoint.getCameraSys(), toSys)
88 return CameraPoint(outPoint, toSys)
89 raise RuntimeError(
"Could not find mapping from %s to %s"%(cameraPoint.getCameraSys(), toSys))
92 """!Find the detectors that cover a given cameraPoint, or empty list
94 @param[in] cameraPoint position to use in lookup
95 @return a list of zero or more Detectors that overlap the specified point
101 for detector
in self:
102 cameraSys = detector.makeCameraSys(PIXELS)
103 detPoint = detector.transform(nativePoint, cameraSys)
105 if afwGeom.Box2D(detector.getBBox()).contains(detPoint.getPoint()):
106 detectorList.append(detector)
110 """!Obtain a pointer to the transform registry.
112 @return a TransformMap
114 @note: TransformRegistries are immutable, so this should be safe.
119 """!Transform a CameraPoint to a different CameraSys
121 @param[in] cameraPoint CameraPoint to transform
122 @param[in] toSys Transform to this CameraSys
123 @return a CameraPoint in the the specified CameraSys
130 """!Make a CameraPoint from a Point2D and a CameraSys
132 @param[in] point an lsst.afw.geom.Point2D
133 @param[in] cameraSys a CameraSys
134 @return the CameraPoint
136 if isinstance(cameraSys, CameraSysPrefix):
137 raise TypeError(
"Use the detector method to make a camera point from a CameraSysPrefix.")
139 return CameraPoint(point, cameraSys)
140 if cameraSys.hasDetectorName():
142 return CameraPoint(point, cameraSys)
143 raise RuntimeError(
"Could not find %s in any transformMap"%(cameraSys))
def makeCameraPoint
Make a CameraPoint from a Point2D and a CameraSys.
def getTransformMap
Obtain a pointer to the transform registry.
def _tranformFromNativeSys
Transform a point in the native coordinate system to another coordinate system.
def transform
Transform a CameraPoint to a different CameraSys.
def __init__
Construct a Camera.
A collection of Detectors that also supports coordinate transformation.
def findDetectors
Find the detectors that cover a given cameraPoint, or empty list.
def getName
Return the camera name.
A floating-point coordinate rectangle geometry.
def _transformSingleSys
Transform a CameraPoint with a CameraSys to another CameraSys.