22__all__ = [
"addDetectorBuilderFromConfig",
23 "makeCameraFromPath",
"makeCameraFromAmpLists"]
27from ._cameraGeom
import FOCAL_PLANE, FIELD_ANGLE, PIXELS, TAN_PIXELS, ACTUAL_PIXELS, CameraSys
28from ._cameraGeom
import Amplifier
29from ._camera
import Camera
30from ._makePixelToTanPixel
import makePixelToTanPixel
31from .pupil
import PupilFactory
33cameraSysList = [FIELD_ANGLE, FOCAL_PLANE, PIXELS, TAN_PIXELS, ACTUAL_PIXELS]
34cameraSysMap = dict((sys.getSysName(), sys)
for sys
in cameraSysList)
38 """Build a dictionary of Detector constructor keyword arguments.
40 The returned dictionary can be passed as keyword arguments to the Detector
41 constructor, providing all required arguments. However, using these
42 arguments directly constructs a Detector
with knowledge of only the
43 coordinate systems that are *directly* mapped to its own PIXELS coordinate
44 system. To construct Detectors
with a shared TransformMap
for the full
45 Camera, use makeCameraFromCatalogs
or makeCameraFromPath instead of
46 calling this function
or makeDetector directly.
50 cameraBuilder : `lsst.afw.cameraGeonm.Camera.Builder`
51 Camera builder object to which the new Detector Builder
54 Configuration
for this detector.
56 amplifier information
for this detector
58 FOCAL_PLANE to FIELD_ANGLE Transform
63 A builder object
for a detector corresponding to the given config,
64 associated
with the given camera builder object.
66 detectorBuilder = cameraBuilder.add(detectorConfig.name, detectorConfig.id)
67 detectorBuilder.fromConfig(detectorConfig)
69 for ampBuilder
in amplifiers:
70 detectorBuilder.append(ampBuilder)
80 detectorNativeSysPrefix = cameraSysMap.get(detectorConfig.transformDict.nativeSys, PIXELS)
81 assert detectorNativeSysPrefix == PIXELS,
"Detectors with nativeSys != PIXELS are not supported."
83 for toSys, transform
in transforms.items():
84 detectorBuilder.setTransformFromPixelsTo(toSys, transform)
85 tanPixSys = CameraSys(TAN_PIXELS, detectorConfig.name)
86 transforms[tanPixSys] = makePixelToTanPixel(
87 bbox=detectorBuilder.getBBox(),
88 orientation=detectorBuilder.getOrientation(),
89 focalPlaneToField=focalPlaneToField,
90 pixelSizeMm=detectorBuilder.getPixelSize(),
93 for toSys, transform
in transforms.items():
94 detectorBuilder.setTransformFromPixelsTo(toSys, transform)
96 detectorBuilder.setCrosstalk(detectorConfig.getCrosstalk(len(amplifiers)))
98 return detectorBuilder
102 """Make a dictionary of CameraSys: lsst.afw.geom.Transform from a config dict.
107 registry; keys are camera system names.
115 if transformConfigDict
is not None:
116 for key
in transformConfigDict:
117 transform = transformConfigDict[key].transform.apply()
118 resMap[CameraSys(key)] = transform
122def makeCameraFromPath(cameraConfig, ampInfoPath, shortNameFunc,
123 pupilFactoryClass=PupilFactory):
124 """Make a Camera instance from a directory of ampInfo files
126 The directory must contain one ampInfo fits file for each detector
in cameraConfig.detectorList.
127 The name of each ampInfo file must be shortNameFunc(fullDetectorName) +
".fits".
131 cameraConfig : `CameraConfig`
132 Config describing camera
and its detectors.
134 Path to ampInfo data files.
135 shortNameFunc : callable
136 A function that converts a long detector name to a short one.
137 pupilFactoryClass : `type`, optional
146 for detectorConfig
in cameraConfig.detectorList.values():
147 shortName = shortNameFunc(detectorConfig.name)
148 ampCatPath = os.path.join(ampInfoPath, shortName +
".fits")
149 catalog = BaseCatalog.readFits(ampCatPath)
150 ampListDict[detectorConfig.name] = [Amplifier.Builder.fromRecord(record)
151 for record
in catalog]
153 return makeCameraFromAmpLists(cameraConfig, ampListDict, pupilFactoryClass)
156def makeCameraFromAmpLists(cameraConfig, ampListDict,
157 pupilFactoryClass=PupilFactory):
158 """Construct a Camera instance from a dictionary of detector name: list of
163 cameraConfig : `CameraConfig`
164 Config describing camera and its detectors.
167 pupilFactoryClass : `type`, optional
175 nativeSys = cameraSysMap[cameraConfig.transformDict.nativeSys]
181 assert nativeSys == FOCAL_PLANE,
"Cameras with nativeSys != FOCAL_PLANE are not supported."
184 cameraBuilder.setPupilFactoryClass(pupilFactoryClass)
187 focalPlaneToField = transformDict[FIELD_ANGLE]
189 for toSys, transform
in transformDict.items():
190 cameraBuilder.setTransformFromFocalPlaneTo(toSys, transform)
192 for detectorConfig
in cameraConfig.detectorList.values():
195 detectorConfig=detectorConfig,
196 amplifiers=ampListDict[detectorConfig.name],
197 focalPlaneToField=focalPlaneToField,
200 return cameraBuilder.finish()
A mutable Amplifier subclass class that can be used to incrementally construct or modify Amplifiers.
Geometry and electronic information about raw amplifier images.
A helper class for creating and modifying cameras.
An immutable representation of a camera.
A helper class that allows the properties of a detector to be modified in the course of modifying a f...
addDetectorBuilderFromConfig(cameraBuilder, detectorConfig, amplifiers, focalPlaneToField)
makeTransformDict(transformConfigDict)