25 import lsst.afw.cameraGeom
as cameraGeom
26 import lsst.afw.geom
as afwGeom
27 from lsst.afw.table
import AmpInfoCatalog, AmpInfoTable
28 from lsst.afw.cameraGeom.cameraFactory
import makeDetector
32 """The Commissioning Camera (comCam) 38 with open(cameraYamlFile)
as fd:
39 cameraParams = yaml.load(fd, Loader=yaml.Loader)
41 plateScale = afwGeom.Angle(cameraParams[
"plateScale"], afwGeom.arcseconds)
46 radialCoeffs = np.array(cameraParams[
"radialCoeffs"])/plateScale.asRadians()
47 fieldAngleToFocalPlane = afwGeom.makeRadialTransform(radialCoeffs)
48 focalPlaneToFieldAngle = fieldAngleToFocalPlane.getInverse()
49 cameraTransformMap = cameraGeom.TransformMap(cameraGeom.FOCAL_PLANE,
50 {cameraGeom.FIELD_ANGLE: focalPlaneToFieldAngle})
51 detectorList = self.
_makeDetectorList(cameraParams[
"CCDs"], focalPlaneToFieldAngle)
52 cameraGeom.Camera.__init__(self, cameraParams[
"name"], detectorList, cameraTransformMap)
54 def _makeDetectorList(self, ccdParams, focalPlaneToFieldAngle):
55 """!Make a list of detectors 56 @param[in] ccdParams Dict of YAML descriptions of CCDs 57 @param[in] focalPlaneToFieldAngle lsst.afw.geom.TransformPoint2ToPoint2 58 from FOCAL_PLANE to FIELD_ANGLE coordinates 59 @return a list of detectors (lsst.afw.cameraGeom.Detector) 63 for ccd, detectorConfig
in zip(ccdParams.values(), detectorConfigList):
65 detector = makeDetector(detectorConfig, ampInfoCatalog, focalPlaneToFieldAngle)
66 detectorList.append(detector)
69 def _makeDetectorConfigList(self, ccdParams):
70 """!Make a list of detector configs 72 @return a list of detector configs (lsst.afw.cameraGeom.DetectorConfig) 75 for name, ccd
in ccdParams.items():
76 detectorConfig = cameraGeom.DetectorConfig()
77 detectorConfigs.append(detectorConfig)
79 detectorConfig.name = name
80 detectorConfig.id = ccd[
'id']
81 detectorConfig.serial = ccd[
'serial']
82 detectorConfig.detectorType = ccd[
'detectorType']
84 detectorConfig.bbox_x0, detectorConfig.bbox_y0 = ccd[
'bbox'][0]
85 detectorConfig.bbox_x1, detectorConfig.bbox_y1 = ccd[
'bbox'][1]
86 detectorConfig.pixelSize_x, detectorConfig.pixelSize_y = ccd[
'pixelSize']
87 detectorConfig.transformDict.nativeSys = ccd[
'transformDict'][
'nativeSys']
88 transforms = ccd[
'transformDict'][
'transforms']
89 detectorConfig.transformDict.transforms =
None if transforms ==
'None' else transforms
90 detectorConfig.refpos_x, detectorConfig.refpos_y = ccd[
'refpos']
91 detectorConfig.offset_x, detectorConfig.offset_y = ccd[
'offset']
92 detectorConfig.transposeDetector = ccd[
'transposeDetector']
93 detectorConfig.pitchDeg = ccd[
'pitch']
94 detectorConfig.yawDeg = ccd[
'yaw']
95 detectorConfig.rollDeg = ccd[
'roll']
96 if 'crosstalk' in ccd:
97 detectorConfig.crosstalk = ccd[
'crosstalk']
99 return detectorConfigs
102 def _makeBBoxFromList(ylist):
103 """Given a list [(x0, y0), (xsize, ysize)], probably from a yaml file, return a BoxI 105 (x0, y0), (xsize, ysize) = ylist
106 return afwGeom.BoxI(afwGeom.PointI(x0, y0), afwGeom.ExtentI(xsize, ysize))
108 def _makeAmpInfoCatalog(self, ccd):
109 """Construct an amplifier info catalog 112 assert len(ccd[
'amplifiers']) > 0
113 amp = ccd[
'amplifiers'].values()[0]
116 xRawExtent, yRawExtent = rawBBox.getDimensions()
118 from lsst.afw.table
import LL, LR, UL, UR
119 readCorners = dict(LL = LL, LR = LR, UL = UL, UR = UR)
121 schema = AmpInfoTable.makeMinimalSchema()
123 linThreshKey = schema.addField(
'linearityThreshold', type=float)
124 linMaxKey = schema.addField(
'linearityMaximum', type=float)
125 linUnitsKey = schema.addField(
'linearityUnits', type=str, size=9)
126 hduKey = schema.addField(
'hdu', type=np.int32)
129 ampCatalog = AmpInfoCatalog(schema)
130 for name, amp
in sorted(ccd[
'amplifiers'].items(), key=
lambda x: x[1][
'hdu']):
131 record = ampCatalog.addNew()
133 record.set(hduKey, amp[
'hdu'])
136 perAmpData = amp[
'perAmpData']
140 x0, y0 = ix*xRawExtent, iy*yRawExtent
143 xDataExtent, yDataExtent = rawDataBBox.getDimensions()
144 record.setBBox(afwGeom.BoxI(
145 afwGeom.PointI(ix*xDataExtent, iy*yDataExtent), rawDataBBox.getDimensions()))
148 rawBBox.shift(afwGeom.ExtentI(x0, y0))
149 record.setRawBBox(rawBBox)
152 rawDataBBox.shift(afwGeom.ExtentI(x0, y0))
153 record.setRawDataBBox(rawDataBBox)
156 rawSerialOverscanBBox.shift(afwGeom.ExtentI(x0, y0))
157 record.setRawHorizontalOverscanBBox(rawSerialOverscanBBox)
160 rawParallelOverscanBBox.shift(afwGeom.ExtentI(x0, y0))
161 record.setRawVerticalOverscanBBox(rawParallelOverscanBBox)
164 rawSerialPrescanBBox.shift(afwGeom.ExtentI(x0, y0))
165 record.setRawPrescanBBox(rawSerialPrescanBBox)
168 record.setRawXYOffset(afwGeom.Extent2I(ix*xRawExtent, iy*yRawExtent))
170 record.setRawXYOffset(afwGeom.Extent2I(0, 0))
172 record.setReadoutCorner(readCorners[amp[
'readCorner']])
173 record.setGain(amp[
'gain'])
174 record.setReadNoise(amp[
'readNoise'])
175 record.setSaturation(amp[
'saturation'])
176 record.setHasRawInfo(
True)
178 flipX, flipY = amp.get(
"flipXY")
180 record.setRawFlipX(flipX)
181 record.setRawFlipY(flipY)
183 record.setLinearityCoeffs([float(val)
for val
in amp[
'linearityCoeffs']])
184 record.setLinearityType(amp[
'linearityType'])
185 record.set(linThreshKey, float(amp[
'linearityThreshold']))
186 record.set(linMaxKey, float(amp[
'linearityMax']))
187 record.set(linUnitsKey,
"DN")
def _makeAmpInfoCatalog(self, ccd)
def _makeDetectorList(self, ccdParams, focalPlaneToFieldAngle)
Make a list of detectors.
def __init__(self, cameraYamlFile)
def _makeBBoxFromList(ylist)
def _makeDetectorConfigList(self, ccdParams)
Make a list of detector configs.