4 from .cameraGeomLib
import FOCAL_PLANE, FIELD_ANGLE, PIXELS, TAN_PIXELS, ACTUAL_PIXELS, CameraSys, \
5 Detector, DetectorType, Orientation, TransformMap
6 from .camera
import Camera
7 from .makePixelToTanPixel
import makePixelToTanPixel
8 from .pupil
import PupilFactory
10 __all__ = [
"makeCameraFromPath",
"makeCameraFromCatalogs",
11 "makeDetector",
"copyDetector"]
13 cameraSysList = [FIELD_ANGLE, FOCAL_PLANE, PIXELS, TAN_PIXELS, ACTUAL_PIXELS]
14 cameraSysMap = dict((sys.getSysName(), sys)
for sys
in cameraSysList)
18 """Build a dictionary of Detector constructor keyword arguments. 20 The returned dictionary can be passed as keyword arguments to the Detector 21 constructor, providing all required arguments. However, using these 22 arguments directly constructs a Detector with knowledge of only the 23 coordinate systems that are *directly* mapped to its own PIXELS coordinate 24 system. To construct Detectors with a shared TransformMap for the full 25 Camera, use makeCameraFromCatalogs or makeCameraFromPath instead of 26 calling this function or makeDetector directly. 30 detectorConfig : `lsst.pex.config.Config` 31 Configuration for this detector. 32 ampInfoCatalog : `lsst.afw.table.AmpInfoCatalog` 33 amplifier information for this detector 34 focalPlaneToField : `lsst.afw.geom.TransformPoint2ToPoint2` 35 FOCAL_PLANE to FIELD_ANGLE Transform 40 Contains the following keys: name, id, type, serial, bbox, orientation, 41 pixelSize, transforms, ampInfoCatalog, and optionally crosstalk. 42 The transforms key is a dictionary whose values are Transforms that map 43 the Detector's PIXEL coordinate system to the CameraSys in the key. 47 name=detectorConfig.name,
49 type=DetectorType(detectorConfig.detectorType),
50 serial=detectorConfig.serial,
51 ampInfoCatalog=ampInfoCatalog,
61 transforms[FOCAL_PLANE] = data[
"orientation"].makePixelFpTransform(data[
"pixelSize"])
63 tanPixSys = CameraSys(TAN_PIXELS, detectorConfig.name)
66 orientation=data[
"orientation"],
67 focalPlaneToField=focalPlaneToField,
68 pixelSizeMm=data[
"pixelSize"],
71 data[
"transforms"] = transforms
73 crosstalk = detectorConfig.getCrosstalk(len(ampInfoCatalog))
74 if crosstalk
is not None:
75 data[
"crosstalk"] = crosstalk
80 def makeDetector(detectorConfig, ampInfoCatalog, focalPlaneToField):
81 """Make a Detector instance from a detector config and amp info catalog 85 detectorConfig : `lsst.pex.config.Config` 86 Configuration for this detector. 87 ampInfoCatalog : `lsst.afw.table.AmpInfoCatalog` 88 amplifier information for this detector 89 focalPlaneToField : `lsst.afw.geom.TransformPoint2ToPoint2` 90 FOCAL_PLANE to FIELD_ANGLE Transform 94 detector : `lsst.afw.cameraGeom.Detector` 95 New Detector instance. 102 """Return a copy of a Detector with possibly-updated amplifier information. 104 No deep copies are made; the input transformDict is used unmodified 108 detector : `lsst.afw.cameraGeom.Detector` 109 The Detector to clone 110 ampInfoCatalog The ampInfoCatalog to use; default use original 114 detector : `lsst.afw.cameraGeom.Detector` 115 New Detector instance. 117 if ampInfoCatalog
is None:
118 ampInfoCatalog = detector.getAmpInfoCatalog()
120 return Detector(detector.getName(), detector.getId(), detector.getType(),
121 detector.getSerial(), detector.getBBox(),
122 ampInfoCatalog, detector.getOrientation(), detector.getPixelSize(),
123 detector.getTransformMap(), detector.getCrosstalk())
127 """Make an Orientation instance from a detector config 131 detectorConfig : `lsst.pex.config.Config` 132 Configuration for this detector. 136 orientation : `lsst.afw.cameraGeom.Orientation` 137 Location and rotation of the Detector. 144 return Orientation(offset, refPos, yaw, pitch, roll)
148 """Make a dictionary of CameraSys: lsst.afw.geom.Transform from a config dict. 152 transformConfigDict : value obtained from a `lsst.pex.config.ConfigDictField` 153 registry; keys are camera system names. 158 A dict of CameraSys or CameraSysPrefix: lsst.afw.geom.Transform 161 if transformConfigDict
is not None:
162 for key
in transformConfigDict:
163 transform = transformConfigDict[key].transform.apply()
164 resMap[CameraSys(key)] = transform
169 pupilFactoryClass=PupilFactory):
170 """Make a Camera instance from a directory of ampInfo files 172 The directory must contain one ampInfo fits file for each detector in cameraConfig.detectorList. 173 The name of each ampInfo file must be shortNameFunc(fullDetectorName) + ".fits". 177 cameraConfig : `CameraConfig` 178 Config describing camera and its detectors. 180 Path to ampInfo data files. 181 shortNameFunc : callable 182 A function that converts a long detector name to a short one. 183 pupilFactoryClass : `type`, optional 184 Class to attach to camera; default is `lsst.afw.cameraGeom.PupilFactory`. 188 camera : `lsst.afw.cameraGeom.Camera` 191 ampInfoCatDict = dict()
192 for detectorConfig
in cameraConfig.detectorList.values():
193 shortName = shortNameFunc(detectorConfig.name)
194 ampCatPath = os.path.join(ampInfoPath, shortName +
".fits")
195 ampInfoCatalog = AmpInfoCatalog.readFits(ampCatPath)
196 ampInfoCatDict[detectorConfig.name] = ampInfoCatalog
202 pupilFactoryClass=PupilFactory):
203 """Construct a Camera instance from a dictionary of detector name: AmpInfoCatalog 207 cameraConfig : `CameraConfig` 208 Config describing camera and its detectors. 209 ampInfoCatDict : `dict` 210 A dictionary of detector name: AmpInfoCatalog 211 pupilFactoryClass : `type`, optional 212 Class to attach to camera; `lsst.default afw.cameraGeom.PupilFactory`. 216 camera : `lsst.afw.cameraGeom.Camera` 219 nativeSys = cameraSysMap[cameraConfig.transformDict.nativeSys]
226 assert nativeSys == FOCAL_PLANE,
"Cameras with nativeSys != FOCAL_PLANE are not supported." 229 focalPlaneToField = transformDict[FIELD_ANGLE]
231 transformMapBuilder.connect(transformDict)
236 for detectorConfig
in cameraConfig.detectorList.values():
242 detectorConfig=detectorConfig,
243 ampInfoCatalog=ampInfoCatDict[detectorConfig.name],
244 focalPlaneToField=focalPlaneToField,
249 thisDetectorTransforms = thisDetectorData.pop(
"transforms")
252 detectorData.append(thisDetectorData)
258 detectorNativeSysPrefix = cameraSysMap.get(detectorConfig.transformDict.nativeSys, PIXELS)
267 assert detectorNativeSysPrefix == PIXELS,
"Detectors with nativeSys != PIXELS are not supported." 268 detectorNativeSys = CameraSys(detectorNativeSysPrefix, detectorConfig.name)
271 transformMapBuilder.connect(detectorNativeSys, thisDetectorTransforms)
275 transformMap = transformMapBuilder.build()
278 detectorList = [
Detector(transformMap=transformMap, **kw)
for kw
in detectorData]
280 return Camera(cameraConfig.name, detectorList, transformMap, pupilFactoryClass)
def copyDetector(detector, ampInfoCatalog=None)
def makeDetectorData(detectorConfig, ampInfoCatalog, focalPlaneToField)
def makeCameraFromCatalogs(cameraConfig, ampInfoCatDict, pupilFactoryClass=PupilFactory)
A class representing an angle.
Describe a detector's orientation in the focal plane.
def makeOrientation(detectorConfig)
def makeCameraFromPath(cameraConfig, ampInfoPath, shortNameFunc, pupilFactoryClass=PupilFactory)
Information about a CCD or other imaging detector.
def makePixelToTanPixel(bbox, orientation, focalPlaneToField, pixelSizeMm)
Make a Transform whose forward direction converts PIXELS to TAN_PIXELS for one detector.
def makeTransformDict(transformConfigDict)
def makeDetector(detectorConfig, ampInfoCatalog, focalPlaneToField)
An integer coordinate rectangle.