213 """Construct a list of DetectorConfig, one per detector
218 with open(detFile)
as fh:
219 names = fh.readline().rstrip().lstrip(
"#").split(
"|")
221 els = line.rstrip().split(
"|")
222 detectorProps = dict([(name, el)
223 for name, el
in zip(names, els)])
224 detectors.append(detectorProps)
226 for i, detector
in enumerate(detectors):
227 detectorId = (i + 1) * 10
228 detectorName = detector[
'name']
230 detConfig.name = detectorName
231 detConfig.id = detectorId
232 detConfig.bbox_x0 = 0
233 detConfig.bbox_y0 = 0
234 detConfig.bbox_x1 = int(detector[
'npix_x']) - 1
235 detConfig.bbox_y1 = int(detector[
'npix_y']) - 1
236 detConfig.serial = str(detector[
'serial'])
237 detConfig.detectorType = int(detector[
'detectorType'])
238 detConfig.offset_x = float(detector[
'x'])
239 detConfig.offset_y = float(detector[
'y'])
240 detConfig.offset_z = float(detector[
'z'])
241 detConfig.refpos_x = float(detector[
'refPixPos_x'])
242 detConfig.refpos_y = float(detector[
'refPixPos_y'])
243 detConfig.yawDeg = float(detector[
'yaw'])
244 detConfig.pitchDeg = float(detector[
'pitch'])
245 detConfig.rollDeg = float(detector[
'roll'])
246 detConfig.pixelSize_x = float(detector[
'pixelSize'])
247 detConfig.pixelSize_y = float(detector[
'pixelSize'])
248 detConfig.transposeDetector =
False
249 detConfig.transformDict.nativeSys = PIXELS.getSysName()
250 detectorConfigs.append(detConfig)
253 return detectorConfigs
256 """Construct a dict of list of Amplifer, one list per detector.
261 Path to amplifier data file.
263 If True then there is one raw image per amplifier;
264 if False then there is one raw image per detector.
267 'LL': ReadoutCorner.LL,
268 'LR': ReadoutCorner.LR,
269 'UR': ReadoutCorner.UR,
270 'UL': ReadoutCorner.UL,
273 with open(ampFile)
as fh:
274 names = fh.readline().rstrip().lstrip(
"#").split(
"|")
276 els = line.rstrip().split(
"|")
277 ampProps = dict([(name, el)
for name, el
in zip(names, els)])
278 ampDataList.append(ampProps)
281 for ampData
in ampDataList:
282 if ampData[
'ccd_name']
in ampListDict:
283 ampList = ampListDict[ampData[
'ccd_name']]
284 self.
ampDataDict[ampData[
'ccd_name']][
'namps'] += 1
287 ampListDict[ampData[
'ccd_name']] = ampList
288 self.
ampDataDict[ampData[
'ccd_name']] = {
'namps': 1,
'linInfo': {}}
291 int(ampData[
'trimmed_ymin'])),
293 int(ampData[
'trimmed_ymax'])))
295 int(ampData[
'raw_ymin'])),
297 int(ampData[
'raw_ymax'])))
300 int(ampData[
'raw_data_ymin'])),
302 int(ampData[
'raw_data_ymax'])))
305 int(ampData[
'hoscan_ymin'])),
307 int(ampData[
'hoscan_ymax'])))
310 int(ampData[
'voscan_ymin'])),
312 int(ampData[
'voscan_ymax'])))
315 int(ampData[
'pscan_ymin'])),
317 int(ampData[
'pscan_ymax'])))
318 xoffset = int(ampData[
'x_offset'])
319 yoffset = int(ampData[
'y_offset'])
320 flipx = bool(int(ampData[
'flipx']))
321 flipy = bool(int(ampData[
'flipy']))
326 xExt = rawBbox.getDimensions().getX()
328 rawDataBbox.flipLR(xExt)
329 rawHOverscanBbox.flipLR(xExt)
330 rawVOverscanBbox.flipLR(xExt)
331 rawPrescanBbox.flipLR(xExt)
333 yExt = rawBbox.getDimensions().getY()
335 rawDataBbox.flipTB(yExt)
336 rawHOverscanBbox.flipTB(yExt)
337 rawVOverscanBbox.flipTB(yExt)
338 rawPrescanBbox.flipTB(yExt)
339 if not flipx
and not flipy:
341 elif flipx
and not flipy:
343 elif flipx
and flipy:
345 elif not flipx
and flipy:
348 raise RuntimeError(
"Couldn't find read corner")
352 rawBbox.shift(offext)
353 rawDataBbox.shift(offext)
354 rawHOverscanBbox.shift(offext)
355 rawVOverscanBbox.shift(offext)
356 rawPrescanBbox.shift(offext)
360 builder.setBBox(bbox)
361 builder.setRawXYOffset(offset)
362 builder.setName(str(ampData[
'name']))
363 builder.setReadoutCorner(readoutMap[readcorner])
364 builder.setGain(float(ampData[
'gain']))
365 builder.setReadNoise(float(ampData[
'readnoise']))
366 linCoeffs = np.array([float(ampData[
'lin_coeffs']), ], dtype=float)
367 builder.setLinearityCoeffs(linCoeffs)
368 builder.setLinearityType(str(ampData[
'lin_type']))
369 builder.setRawFlipX(flipx)
370 builder.setRawFlipY(flipy)
371 builder.setRawBBox(rawBbox)
372 builder.setRawDataBBox(rawDataBbox)
373 builder.setRawHorizontalOverscanBBox(rawHOverscanBbox)
374 builder.setRawVerticalOverscanBBox(rawVOverscanBbox)
375 builder.setRawPrescanBBox(rawPrescanBbox)
376 builder.setLinearityThreshold(float(ampData[
'lin_thresh']))
377 builder.setLinearityMaximum(float(ampData[
'lin_max']))
378 builder.setLinearityUnits(str(ampData[
'lin_units']))
379 self.
ampDataDict[ampData[
'ccd_name']][
'linInfo'][ampData[
'name']] = \
380 {
'lincoeffs': linCoeffs,
'lintype': str(ampData[
'lin_type']),
381 'linthresh': float(ampData[
'lin_thresh']),
'linmax': float(ampData[
'lin_max']),
382 'linunits': str(ampData[
'lin_units'])}
383 ampList.append(builder)
387 """Make camera config and amp catalog dictionary, using default
388 detector and amp files.
393 If True then there is one raw image per amplifier;
394 if False then there is one raw image per detector.
396 detFile = os.path.join(self.
_afwTestDataDir,
"testCameraDetectors.dat")
399 ampListDict = self.
makeAmpLists(ampFile, isLsstLike=isLsstLike)
401 camConfig.name =
"testCamera%s"%(
'LSST' if isLsstLike
else 'SC')
402 camConfig.detectorList = dict((i, detConfig)
403 for i, detConfig
in enumerate(detectorConfigs))
406 radialDistortCoeffs = [0.0, 1.0/pScaleRad,
408 tConfig = afwGeom.TransformConfig()
409 tConfig.transform.name =
'inverted'
410 radialClass = afwGeom.transformRegistry[
'radial']
411 tConfig.transform.active.transform.retarget(radialClass)
412 tConfig.transform.active.transform.coeffs = radialDistortCoeffs
414 tmc.nativeSys = FOCAL_PLANE.getSysName()
415 tmc.transforms = {FIELD_ANGLE.getSysName(): tConfig}
416 camConfig.transformDict = tmc
417 return camConfig, ampListDict