LSSTApplications  16.0-1-gce273f5+20,16.0-10-g1758552,16.0-10-gc1446dd+21,16.0-12-g569485f+3,16.0-13-g5f20d24+1,16.0-13-g80874fd+2,16.0-13-gb122224+12,16.0-14-g08f9460+4,16.0-14-g8a3b804,16.0-14-ga5060d2,16.0-15-g77ef378+7,16.0-18-gdf247dd+2,16.0-18-ge18fa5b,16.0-18-ge4151178,16.0-2-g0febb12+16,16.0-2-g9d5294e+46,16.0-2-gc6e0ed0+5,16.0-23-ge8a9b866+3,16.0-3-g404ea43+13,16.0-3-gbc759ec+19,16.0-3-gcfd6c53+44,16.0-3-ge00e371,16.0-4-g03cf288+35,16.0-4-g13a27c5+21,16.0-4-g5f3a788+15,16.0-4-ga3eb747+5,16.0-5-g1991253+21,16.0-5-g1e9226d+3,16.0-5-g6a53317,16.0-5-g865efd9+23,16.0-5-gb3f8a4b+53,16.0-5-gd0f1235+10,16.0-52-gad2f36c79,16.0-7-g6043bfc+9,16.0-7-gd2eeba5+3,16.0-7-gde5bd64+3,16.0-8-g0e813a6+1,16.0-9-g52c50f7,16.0-9-g73415e6,master-g5768c874b9+5,w.2018.41
LSSTDataManagementBasePackage
detectorCollection.py
Go to the documentation of this file.
1 #
2 # LSST Data Management System
3 # Copyright 2014 LSST Corporation.
4 #
5 # This product includes software developed by the
6 # LSST Project (http://www.lsst.org/).
7 #
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
12 #
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the LSST License Statement and
19 # the GNU General Public License along with this program. If not,
20 # see <http://www.lsstcorp.org/LegalNotices/>.
21 #
22 from lsst.afw.geom import Box2D
23 from .cameraGeomLib import FOCAL_PLANE
24 
25 
27  """!An immutable collection of Detectors that can be accessed by name or ID
28  """
29 
30  def __init__(self, detectorList):
31  """!Construct a DetectorCollection
32 
33  @param[in] detectorList a sequence of detectors in index order
34  """
35  self._idDetectorDict = dict((d.getId(), d) for d in detectorList)
36  self._nameDetectorDict = dict((d.getName(), d) for d in detectorList)
37  self._fpBBox = Box2D()
38  for detector in detectorList:
39  for corner in detector.getCorners(FOCAL_PLANE):
40  self._fpBBox.include(corner)
41  if len(self._idDetectorDict) < len(detectorList):
42  raise RuntimeError("Detector IDs are not unique")
43  if len(self._nameDetectorDict) < len(detectorList):
44  raise RuntimeError("Detector names are not unique")
45 
46  def __iter__(self):
47  """!Support the iter function: return an iterator over all detectors in this collection
48  """
49  return iter(self._idDetectorDict.values())
50 
51  def __len__(self):
52  """!Support the len function: return the number of detectors
53  """
54  return len(self._idDetectorDict)
55 
56  def __getitem__(self, key):
57  """!Support the [key] operator: return the specified detector
58 
59  @param[in] key detector name or ID
60  """
61  if isinstance(key, str):
62  return self._nameDetectorDict[key]
63  else:
64  return self._idDetectorDict[key]
65 
66  def __contains__(self, key):
67  """!Implement the "in" operator: return true if the specified detector is in the collection
68 
69  @param[in] key detector name or ID
70  """
71  if isinstance(key, str):
72  return key in self._nameDetectorDict
73  else:
74  return key in self._idDetectorDict
75 
76  def getNameIter(self):
77  """!Get an iterator over detector names
78  """
79  return iter(self._nameDetectorDict.keys())
80 
81  def getIdIter(self):
82  """!Get an iterator over detector IDs
83  """
84  return iter(self._idDetectorDict.keys())
85 
86  def getFpBBox(self):
87  """!Return a focal plane bounding box that encompasses all detectors
88  """
89  return self._fpBBox
def __len__(self)
Support the len function: return the number of detectors.
A floating-point coordinate rectangle geometry.
Definition: Box.h:291
def __contains__(self, key)
Implement the "in" operator: return true if the specified detector is in the collection.
def getFpBBox(self)
Return a focal plane bounding box that encompasses all detectors.
def __getitem__(self, key)
Support the [key] operator: return the specified detector.
def __init__(self, detectorList)
Construct a DetectorCollection.
def getNameIter(self)
Get an iterator over detector names.
def __iter__(self)
Support the iter function: return an iterator over all detectors in this collection.
def getIdIter(self)
Get an iterator over detector IDs.
An immutable collection of Detectors that can be accessed by name or ID.