22 __all__ = [
"makeCameraFromPath",
"makeCameraFromCatalogs",
23 "makeDetector",
"copyDetector"]
28 from .cameraGeomLib
import FOCAL_PLANE, FIELD_ANGLE, PIXELS, TAN_PIXELS, ACTUAL_PIXELS, CameraSys, \
29 Detector, DetectorType, Orientation, TransformMap
30 from .camera
import Camera
31 from .makePixelToTanPixel
import makePixelToTanPixel
32 from .pupil
import PupilFactory
34 cameraSysList = [FIELD_ANGLE, FOCAL_PLANE, PIXELS, TAN_PIXELS, ACTUAL_PIXELS]
35 cameraSysMap = dict((sys.getSysName(), sys)
for sys
in cameraSysList)
39 """Build a dictionary of Detector constructor keyword arguments. 41 The returned dictionary can be passed as keyword arguments to the Detector 42 constructor, providing all required arguments. However, using these 43 arguments directly constructs a Detector with knowledge of only the 44 coordinate systems that are *directly* mapped to its own PIXELS coordinate 45 system. To construct Detectors with a shared TransformMap for the full 46 Camera, use makeCameraFromCatalogs or makeCameraFromPath instead of 47 calling this function or makeDetector directly. 51 detectorConfig : `lsst.pex.config.Config` 52 Configuration for this detector. 53 ampInfoCatalog : `lsst.afw.table.AmpInfoCatalog` 54 amplifier information for this detector 55 focalPlaneToField : `lsst.afw.geom.TransformPoint2ToPoint2` 56 FOCAL_PLANE to FIELD_ANGLE Transform 61 Contains the following keys: name, id, type, serial, bbox, orientation, 62 pixelSize, transforms, ampInfoCatalog, and optionally crosstalk. 63 The transforms key is a dictionary whose values are Transforms that map 64 the Detector's PIXEL coordinate system to the CameraSys in the key. 68 name=detectorConfig.name,
70 type=DetectorType(detectorConfig.detectorType),
71 serial=detectorConfig.serial,
72 ampInfoCatalog=ampInfoCatalog,
82 transforms[FOCAL_PLANE] = data[
"orientation"].makePixelFpTransform(data[
"pixelSize"])
84 tanPixSys = CameraSys(TAN_PIXELS, detectorConfig.name)
87 orientation=data[
"orientation"],
88 focalPlaneToField=focalPlaneToField,
89 pixelSizeMm=data[
"pixelSize"],
92 data[
"transforms"] = transforms
94 crosstalk = detectorConfig.getCrosstalk(len(ampInfoCatalog))
95 if crosstalk
is not None:
96 data[
"crosstalk"] = crosstalk
102 """Make a Detector instance from a detector config and amp info catalog 106 detectorConfig : `lsst.pex.config.Config` 107 Configuration for this detector. 108 ampInfoCatalog : `lsst.afw.table.AmpInfoCatalog` 109 amplifier information for this detector 110 focalPlaneToField : `lsst.afw.geom.TransformPoint2ToPoint2` 111 FOCAL_PLANE to FIELD_ANGLE Transform 115 detector : `lsst.afw.cameraGeom.Detector` 116 New Detector instance. 123 """Return a copy of a Detector with possibly-updated amplifier information. 125 No deep copies are made; the input transformDict is used unmodified 129 detector : `lsst.afw.cameraGeom.Detector` 130 The Detector to clone 131 ampInfoCatalog The ampInfoCatalog to use; default use original 135 detector : `lsst.afw.cameraGeom.Detector` 136 New Detector instance. 138 if ampInfoCatalog
is None:
139 ampInfoCatalog = detector.getAmpInfoCatalog()
141 return Detector(detector.getName(), detector.getId(), detector.getType(),
142 detector.getSerial(), detector.getBBox(),
143 ampInfoCatalog, detector.getOrientation(), detector.getPixelSize(),
144 detector.getTransformMap(), detector.getCrosstalk())
148 """Make an Orientation instance from a detector config 152 detectorConfig : `lsst.pex.config.Config` 153 Configuration for this detector. 157 orientation : `lsst.afw.cameraGeom.Orientation` 158 Location and rotation of the Detector. 165 return Orientation(offset, refPos, yaw, pitch, roll)
169 """Make a dictionary of CameraSys: lsst.afw.geom.Transform from a config dict. 173 transformConfigDict : value obtained from a `lsst.pex.config.ConfigDictField` 174 registry; keys are camera system names. 179 A dict of CameraSys or CameraSysPrefix: lsst.afw.geom.Transform 182 if transformConfigDict
is not None:
183 for key
in transformConfigDict:
184 transform = transformConfigDict[key].transform.apply()
185 resMap[CameraSys(key)] = transform
190 pupilFactoryClass=PupilFactory):
191 """Make a Camera instance from a directory of ampInfo files 193 The directory must contain one ampInfo fits file for each detector in cameraConfig.detectorList. 194 The name of each ampInfo file must be shortNameFunc(fullDetectorName) + ".fits". 198 cameraConfig : `CameraConfig` 199 Config describing camera and its detectors. 201 Path to ampInfo data files. 202 shortNameFunc : callable 203 A function that converts a long detector name to a short one. 204 pupilFactoryClass : `type`, optional 205 Class to attach to camera; default is `lsst.afw.cameraGeom.PupilFactory`. 209 camera : `lsst.afw.cameraGeom.Camera` 212 ampInfoCatDict = dict()
213 for detectorConfig
in cameraConfig.detectorList.values():
214 shortName = shortNameFunc(detectorConfig.name)
215 ampCatPath = os.path.join(ampInfoPath, shortName +
".fits")
216 ampInfoCatalog = AmpInfoCatalog.readFits(ampCatPath)
217 ampInfoCatDict[detectorConfig.name] = ampInfoCatalog
223 pupilFactoryClass=PupilFactory):
224 """Construct a Camera instance from a dictionary of detector name: AmpInfoCatalog 228 cameraConfig : `CameraConfig` 229 Config describing camera and its detectors. 230 ampInfoCatDict : `dict` 231 A dictionary of detector name: AmpInfoCatalog 232 pupilFactoryClass : `type`, optional 233 Class to attach to camera; `lsst.default afw.cameraGeom.PupilFactory`. 237 camera : `lsst.afw.cameraGeom.Camera` 240 nativeSys = cameraSysMap[cameraConfig.transformDict.nativeSys]
247 assert nativeSys == FOCAL_PLANE,
"Cameras with nativeSys != FOCAL_PLANE are not supported." 250 focalPlaneToField = transformDict[FIELD_ANGLE]
252 transformMapBuilder.connect(transformDict)
257 for detectorConfig
in cameraConfig.detectorList.values():
263 detectorConfig=detectorConfig,
264 ampInfoCatalog=ampInfoCatDict[detectorConfig.name],
265 focalPlaneToField=focalPlaneToField,
270 thisDetectorTransforms = thisDetectorData.pop(
"transforms")
273 detectorData.append(thisDetectorData)
279 detectorNativeSysPrefix = cameraSysMap.get(detectorConfig.transformDict.nativeSys, PIXELS)
288 assert detectorNativeSysPrefix == PIXELS,
"Detectors with nativeSys != PIXELS are not supported." 289 detectorNativeSys = CameraSys(detectorNativeSysPrefix, detectorConfig.name)
292 transformMapBuilder.connect(detectorNativeSys, thisDetectorTransforms)
296 transformMap = transformMapBuilder.build()
299 detectorList = [
Detector(transformMap=transformMap, **kw)
for kw
in detectorData]
301 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)
def makeTransformDict(transformConfigDict)
def makeDetector(detectorConfig, ampInfoCatalog, focalPlaneToField)
An integer coordinate rectangle.