22 from __future__
import absolute_import, division, print_function
23 from builtins
import range
24 from .cameraGeomLib
import CameraPoint, CameraSysPrefix, PIXELS
25 from .detectorCollection
import DetectorCollection
26 from .pupil
import PupilFactory
31 """!A collection of Detectors that also supports coordinate transformation 34 def __init__(self, name, detectorList, transformMap, pupilFactoryClass=PupilFactory):
35 """!Construct a Camera 37 @param[in] name name of camera 38 @param[in] detectorList a sequence of detectors in index order 39 @param[in] transformMap a CameraTransformMap whose native system is FOCAL_PLANE 40 and that at least supports PUPIL coordinates 41 @param[in] pupilFactoryClass a PupilFactory class for this camera 42 [default: afw.cameraGeom.PupilFactory] 48 super(Camera, self).
__init__(detectorList)
51 """!Return the camera name 56 """!Construct a PupilFactory. 58 @param[in] visitInfo VisitInfo object for a particular exposure. 59 @param[in] pupilSize Size in meters of constructed Pupil array. 60 Note that this may be larger than the actual 61 diameter of the illuminated pupil to 62 accommodate zero-padding. 63 @param[in] npix Constructed Pupils will be npix x npix. 71 def _transformFromNativeSys(self, nativePoint, toSys):
72 """!Transform a point in the native coordinate system to another coordinate system. 74 @param[in] nativePoint CameraPoint in the native system for the camera 75 @param[in] toSys destination CameraSys 76 @return CameraPoint in the destination CameraSys 78 if isinstance(toSys, CameraSysPrefix):
82 raise RuntimeError(
"No detectors found")
83 elif len(detList) > 1:
84 raise RuntimeError(
"More than one detector found")
87 return det.transform(nativePoint, toSys)
91 def _transformSingleSysArray(self, positionList, fromSys, toSys):
92 """!Transform an array of points from once CameraSys to another CameraSys 93 @warning This method only handles a single jump, not a transform linked by a common native sys. 95 @param[in] positionList List of Point2D objects, one per position 96 @param[in] fromSys Initial camera coordinate system 97 @param[in] toSys Destination camera coordinate system 99 @returns an array of Point2D objects containing the transformed coordinates in the destination system. 101 if fromSys.hasDetectorName():
102 det = self[fromSys.getDetectorname()]
103 detTrans = det.getTransfromMap()
104 return detTrans.transform(positionList, fromSys, toSys)
105 elif toSys.hasDetectorName():
106 det = self[toSys.getDetectorName()]
107 detTrans = det.getTransformMap()
108 return detTrans.transform(positionList, fromSys, toSys)
113 "Could not find mapping from %s to %s"%(fromSys, toSys))
115 def _transformSingleSys(self, cameraPoint, toSys):
116 """!Transform a CameraPoint with a CameraSys to another CameraSys. 118 @warning This method only handles a single jump, not a transform linked by a common native sys. 120 @param[in] cameraPoint CameraPoint to transform 121 @param[in] toSys Destination coordinate system 123 fromSys = cameraPoint.getCameraSys()
124 if fromSys.hasDetectorName():
126 det = self[fromSys.getDetectorName()]
127 return det.transform(cameraPoint, toSys)
128 elif toSys.hasDetectorName():
130 det = self[toSys.getDetectorName()]
131 return det.transform(cameraPoint, toSys)
135 cameraPoint.getPoint(), cameraPoint.getCameraSys(), toSys)
136 return CameraPoint(outPoint, toSys)
137 raise RuntimeError(
"Could not find mapping from %s to %s" %
138 (cameraPoint.getCameraSys(), toSys))
141 """!Find the detectors that cover a given cameraPoint, or empty list 143 @param[in] cameraPoint position to use in lookup 144 @return a list of zero or more Detectors that overlap the specified point 152 for detector
in self:
153 cameraSys = detector.makeCameraSys(PIXELS)
154 detPoint = detector.transform(nativePoint, cameraSys)
157 if afwGeom.Box2D(detector.getBBox()).contains(detPoint.getPoint()):
158 detectorList.append(detector)
162 """!Find the detectors that cover a list of points specified by x and y coordinates in any system 164 @param[in] cameraPointList a list of cameraPoints 165 @param[in] coordSys the camera coordinate system in which cameraPointList is defined 166 @return a list of lists; each list contains the names of all detectors which contain the 175 for i
in range(len(cameraPointList)):
176 detectorList.append([])
178 for detector
in self:
179 coordMap = detector.getTransformMap()
180 cameraSys = detector.makeCameraSys(PIXELS)
181 detectorPointList = coordMap.transform(
184 for i, pt
in enumerate(detectorPointList):
186 detectorList[i].append(detector)
191 """!Obtain the transform registry. 193 @return a TransformMap 195 @note: TransformRegistries are immutable, so this should be safe. 200 """!Transform a CameraPoint to a different CameraSys 202 @param[in] cameraPoint CameraPoint to transform 203 @param[in] toSys Transform to this CameraSys 204 @return a CameraPoint in the the specified CameraSys 212 """!Make a CameraPoint from a Point2D and a CameraSys 214 @param[in] point an lsst.afw.geom.Point2D 215 @param[in] cameraSys a CameraSys 216 @return the CameraPoint 218 if isinstance(cameraSys, CameraSysPrefix):
220 "Use the detector method to make a camera point from a CameraSysPrefix.")
222 return CameraPoint(point, cameraSys)
223 if cameraSys.hasDetectorName():
225 return CameraPoint(point, cameraSys)
226 raise RuntimeError(
"Could not find %s in any transformMap"%(cameraSys))
def _transformFromNativeSys(self, nativePoint, toSys)
Transform a point in the native coordinate system to another coordinate system.
def __init__(self, name, detectorList, transformMap, pupilFactoryClass=PupilFactory)
Construct a Camera.
def getTransformMap(self)
Obtain the transform registry.
def findDetectors(self, cameraPoint)
Find the detectors that cover a given cameraPoint, or empty list.
def getName(self)
Return the camera name.
def getPupilFactory(self, visitInfo, pupilSize, npix)
Construct a PupilFactory.
def _transformSingleSysArray(self, positionList, fromSys, toSys)
Transform an array of points from once CameraSys to another CameraSys.
def makeCameraPoint(self, point, cameraSys)
Make a CameraPoint from a Point2D and a CameraSys.
def findDetectorsList(self, cameraPointList, coordSys)
Find the detectors that cover a list of points specified by x and y coordinates in any system...
def telescopeDiameter(self)
def transform(self, cameraPoint, toSys)
Transform a CameraPoint to a different CameraSys.
def _transformSingleSys(self, cameraPoint, toSys)
Transform a CameraPoint with a CameraSys to another CameraSys.
A collection of Detectors that also supports coordinate transformation.
A floating-point coordinate rectangle geometry.
An immutable collection of Detectors that can be accessed by name or ID.