LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
Public Member Functions | Private Member Functions | Private Attributes | List of all members
lsst.afw.cameraGeom.camera.Camera Class Reference

A collection of Detectors that also supports coordinate transformation. More...

Inheritance diagram for lsst.afw.cameraGeom.camera.Camera:

Public Member Functions

def __init__
 Construct a Camera. More...
 
def getName
 Return the camera name. More...
 
def findDetectors
 Find the detectors that cover a given cameraPoint, or empty list. More...
 
def findDetectorsList
 Find the detectors that cover a list of points specified by x and y coordinates in any system. More...
 
def getTransformMap
 Obtain the transform registry. More...
 
def transform
 Transform a CameraPoint to a different CameraSys. More...
 
def makeCameraPoint
 Make a CameraPoint from a Point2D and a CameraSys. More...
 

Private Member Functions

def _transformFromNativeSys
 Transform a point in the native coordinate system to another coordinate system. More...
 
def _transformSingleSysArray
 Transform an array of points from once CameraSys to another CameraSys. More...
 
def _transformSingleSys
 Transform a CameraPoint with a CameraSys to another CameraSys. More...
 

Private Attributes

 _name
 
 _transformMap
 
 _nativeCameraSys
 

Detailed Description

A collection of Detectors that also supports coordinate transformation.

Definition at line 27 of file camera.py.

Constructor & Destructor Documentation

def lsst.afw.cameraGeom.camera.Camera.__init__ (   self,
  name,
  detectorList,
  transformMap 
)

Construct a Camera.

Parameters
[in]namename of camera
[in]detectorLista sequence of detectors in index order
[in]transformMapa CameraTransformMap whose native system is FOCAL_PLANE and that at least supports PUPIL coordinates

Definition at line 30 of file camera.py.

30 
31  def __init__(self, name, detectorList, transformMap):
32  """!Construct a Camera
33 
34  @param[in] name name of camera
35  @param[in] detectorList a sequence of detectors in index order
36  @param[in] transformMap a CameraTransformMap whose native system is FOCAL_PLANE
37  and that at least supports PUPIL coordinates
38  """
39  self._name = name
40  self._transformMap = transformMap
41  self._nativeCameraSys = self._transformMap.getNativeCoordSys()
42  super(Camera, self).__init__(detectorList)
def __init__
Construct a Camera.
Definition: camera.py:30

Member Function Documentation

def lsst.afw.cameraGeom.camera.Camera._transformFromNativeSys (   self,
  nativePoint,
  toSys 
)
private

Transform a point in the native coordinate system to another coordinate system.

Parameters
[in]nativePointCameraPoint in the native system for the camera
[in]toSysdestination CameraSys
Returns
CameraPoint in the destination CameraSys

Definition at line 48 of file camera.py.

48 
49  def _transformFromNativeSys(self, nativePoint, toSys):
50  """!Transform a point in the native coordinate system to another coordinate system.
51 
52  @param[in] nativePoint CameraPoint in the native system for the camera
53  @param[in] toSys destination CameraSys
54  @return CameraPoint in the destination CameraSys
55  """
56  if isinstance(toSys, CameraSysPrefix):
57  # Must be in a detector. Find the detector and transform it.
58  detList = self.findDetectors(nativePoint)
59  if len(detList) == 0:
60  raise RuntimeError("No detectors found")
61  elif len(detList) > 1:
62  raise RuntimeError("More than one detector found")
63  else:
64  det = detList[0]
65  return det.transform(nativePoint, toSys)
66  else:
67  return self._transformSingleSys(nativePoint, toSys)
def findDetectors
Find the detectors that cover a given cameraPoint, or empty list.
Definition: camera.py:114
def _transformSingleSys
Transform a CameraPoint with a CameraSys to another CameraSys.
Definition: camera.py:91
def _transformFromNativeSys
Transform a point in the native coordinate system to another coordinate system.
Definition: camera.py:48
def lsst.afw.cameraGeom.camera.Camera._transformSingleSys (   self,
  cameraPoint,
  toSys 
)
private

Transform a CameraPoint with a CameraSys to another CameraSys.

Warning
This method only handles a single jump, not a transform linked by a common native sys.
Parameters
[in]cameraPointCameraPoint to transform
[in]toSysDestination coordinate system

Definition at line 91 of file camera.py.

91 
92  def _transformSingleSys(self, cameraPoint, toSys):
93  """!Transform a CameraPoint with a CameraSys to another CameraSys.
94 
95  @warning This method only handles a single jump, not a transform linked by a common native sys.
96 
97  @param[in] cameraPoint CameraPoint to transform
98  @param[in] toSys Destination coordinate system
99  """
100  fromSys = cameraPoint.getCameraSys()
101  if fromSys.hasDetectorName():
102  # use from detector to transform
103  det = self[fromSys.getDetectorName()]
104  return det.transform(cameraPoint, toSys)
105  elif toSys.hasDetectorName():
106  # use the to detector to transform
107  det = self[toSys.getDetectorName()]
108  return det.transform(cameraPoint, toSys)
109  elif toSys in self._transformMap:
110  # use camera transform map
111  outPoint = self._transformMap.transform(cameraPoint.getPoint(), cameraPoint.getCameraSys(), toSys)
112  return CameraPoint(outPoint, toSys)
113  raise RuntimeError("Could not find mapping from %s to %s"%(cameraPoint.getCameraSys(), toSys))
def _transformSingleSys
Transform a CameraPoint with a CameraSys to another CameraSys.
Definition: camera.py:91
def lsst.afw.cameraGeom.camera.Camera._transformSingleSysArray (   self,
  positionList,
  fromSys,
  toSys 
)
private

Transform an array of points from once CameraSys to another CameraSys.

Warning
This method only handles a single jump, not a transform linked by a common native sys.
Parameters
[in]positionListList of Point2D objects, one per position
[in]fromSysInitial camera coordinate system
[in]toSysDestination camera coordinate system
Returns
an array of Point2D objects containing the transformed coordinates in the destination system.

Definition at line 68 of file camera.py.

68 
69  def _transformSingleSysArray(self, positionList, fromSys, toSys):
70  """!Transform an array of points from once CameraSys to another CameraSys
71  @warning This method only handles a single jump, not a transform linked by a common native sys.
72 
73  @param[in] positionList List of Point2D objects, one per position
74  @param[in] fromSys Initial camera coordinate system
75  @param[in] toSys Destination camera coordinate system
76 
77  @returns an array of Point2D objects containing the transformed coordinates in the destination system.
78  """
79  if fromSys.hasDetectorName():
80  det = self[fromSys.getDetectorname()]
81  detTrans = det.getTransfromMap()
82  return detTrans.transform(positionList, fromSys, toSys)
83  elif toSys.hasDetectorName():
84  det = self[toSys.getDetectorName()]
85  detTrans = det.getTransformMap()
86  return detTrans.transform(positionList, fromSys, toSys)
87  elif toSys in self._transformMap:
88  # use camera transform map
89  return self._transformMap.transform(positionList, fromSys, toSys)
90  raise RuntimeError("Could not find mapping from %s to %s"%(fromSys, toSys))
def _transformSingleSysArray
Transform an array of points from once CameraSys to another CameraSys.
Definition: camera.py:68
def lsst.afw.cameraGeom.camera.Camera.findDetectors (   self,
  cameraPoint 
)

Find the detectors that cover a given cameraPoint, or empty list.

Parameters
[in]cameraPointposition to use in lookup
Returns
a list of zero or more Detectors that overlap the specified point

Definition at line 114 of file camera.py.

115  def findDetectors(self, cameraPoint):
116  """!Find the detectors that cover a given cameraPoint, or empty list
117 
118  @param[in] cameraPoint position to use in lookup
119  @return a list of zero or more Detectors that overlap the specified point
120  """
121  # first convert to focalPlane since the point may be in another overlapping detector
122  nativePoint = self._transformSingleSys(cameraPoint, self._nativeCameraSys)
123 
124  detectorList = []
125  for detector in self:
126  cameraSys = detector.makeCameraSys(PIXELS)
127  detPoint = detector.transform(nativePoint, cameraSys)
128  #This is safe because CameraPoint is not templated and getPoint() returns a Point2D.
129  if afwGeom.Box2D(detector.getBBox()).contains(detPoint.getPoint()):
130  detectorList.append(detector)
131  return detectorList
def findDetectors
Find the detectors that cover a given cameraPoint, or empty list.
Definition: camera.py:114
A floating-point coordinate rectangle geometry.
Definition: Box.h:271
def _transformSingleSys
Transform a CameraPoint with a CameraSys to another CameraSys.
Definition: camera.py:91
def lsst.afw.cameraGeom.camera.Camera.findDetectorsList (   self,
  cameraPointList,
  coordSys 
)

Find the detectors that cover a list of points specified by x and y coordinates in any system.

Parameters
[in]cameraPointLista list of cameraPoints
[in]coordSysthe camera coordinate system in which cameraPointList is defined
Returns
a list of lists; each list contains the names of all detectors which contain the corresponding point

Definition at line 132 of file camera.py.

133  def findDetectorsList(self, cameraPointList, coordSys):
134  """!Find the detectors that cover a list of points specified by x and y coordinates in any system
135 
136  @param[in] cameraPointList a list of cameraPoints
137  @param[in] coordSys the camera coordinate system in which cameraPointList is defined
138  @return a list of lists; each list contains the names of all detectors which contain the
139  corresponding point
140  """
141 
142  #transform the points to the native coordinate system
143  nativePointList = self._transformSingleSysArray(cameraPointList, coordSys, self._nativeCameraSys)
144 
145  detectorList = []
146  for i in range(len(cameraPointList)):
147  detectorList.append([])
148 
149  for detector in self:
150  coordMap = detector.getTransformMap()
151  cameraSys = detector.makeCameraSys(PIXELS)
152  detectorPointList = coordMap.transform(nativePointList, self._nativeCameraSys, cameraSys)
153  box = afwGeom.Box2D(detector.getBBox())
154  for i, pt in enumerate(detectorPointList):
155  if box.contains(pt):
156  detectorList[i].append(detector)
157 
158  return detectorList
def _transformSingleSysArray
Transform an array of points from once CameraSys to another CameraSys.
Definition: camera.py:68
def findDetectorsList
Find the detectors that cover a list of points specified by x and y coordinates in any system...
Definition: camera.py:132
A floating-point coordinate rectangle geometry.
Definition: Box.h:271
def lsst.afw.cameraGeom.camera.Camera.getName (   self)

Return the camera name.

Definition at line 43 of file camera.py.

43 
44  def getName(self):
45  """!Return the camera name
46  """
47  return self._name
def getName
Return the camera name.
Definition: camera.py:43
def lsst.afw.cameraGeom.camera.Camera.getTransformMap (   self)

Obtain the transform registry.

Returns
a TransformMap
Note
: TransformRegistries are immutable, so this should be safe.

Definition at line 159 of file camera.py.

160  def getTransformMap(self):
161  """!Obtain the transform registry.
162 
163  @return a TransformMap
164 
165  @note: TransformRegistries are immutable, so this should be safe.
166  """
167  return self._transformMap
def getTransformMap
Obtain the transform registry.
Definition: camera.py:159
def lsst.afw.cameraGeom.camera.Camera.makeCameraPoint (   self,
  point,
  cameraSys 
)

Make a CameraPoint from a Point2D and a CameraSys.

Parameters
[in]pointan lsst.afw.geom.Point2D
[in]cameraSysa CameraSys
Returns
the CameraPoint

Definition at line 179 of file camera.py.

180  def makeCameraPoint(self, point, cameraSys):
181  """!Make a CameraPoint from a Point2D and a CameraSys
182 
183  @param[in] point an lsst.afw.geom.Point2D
184  @param[in] cameraSys a CameraSys
185  @return the CameraPoint
186  """
187  if isinstance(cameraSys, CameraSysPrefix):
188  raise TypeError("Use the detector method to make a camera point from a CameraSysPrefix.")
189  if cameraSys in self._transformMap:
190  return CameraPoint(point, cameraSys)
191  if cameraSys.hasDetectorName():
192  if cameraSys in self[cameraSys.getDetectorName()].getTransformMap():
193  return CameraPoint(point, cameraSys)
194  raise RuntimeError("Could not find %s in any transformMap"%(cameraSys))
def makeCameraPoint
Make a CameraPoint from a Point2D and a CameraSys.
Definition: camera.py:179
def getTransformMap
Obtain the transform registry.
Definition: camera.py:159
def lsst.afw.cameraGeom.camera.Camera.transform (   self,
  cameraPoint,
  toSys 
)

Transform a CameraPoint to a different CameraSys.

Parameters
[in]cameraPointCameraPoint to transform
[in]toSysTransform to this CameraSys
Returns
a CameraPoint in the the specified CameraSys

Definition at line 168 of file camera.py.

169  def transform(self, cameraPoint, toSys):
170  """!Transform a CameraPoint to a different CameraSys
171 
172  @param[in] cameraPoint CameraPoint to transform
173  @param[in] toSys Transform to this CameraSys
174  @return a CameraPoint in the the specified CameraSys
175  """
176  # All transform maps should know about the native coordinate system
177  nativePoint = self._transformSingleSys(cameraPoint, self._nativeCameraSys)
178  return self._transformFromNativeSys(nativePoint, toSys)
def transform
Transform a CameraPoint to a different CameraSys.
Definition: camera.py:168
def _transformSingleSys
Transform a CameraPoint with a CameraSys to another CameraSys.
Definition: camera.py:91
def _transformFromNativeSys
Transform a point in the native coordinate system to another coordinate system.
Definition: camera.py:48

Member Data Documentation

lsst.afw.cameraGeom.camera.Camera._name
private

Definition at line 38 of file camera.py.

lsst.afw.cameraGeom.camera.Camera._nativeCameraSys
private

Definition at line 40 of file camera.py.

lsst.afw.cameraGeom.camera.Camera._transformMap
private

Definition at line 39 of file camera.py.


The documentation for this class was generated from the following file: