255 def makeAmpLists(self, ampFile, isLsstLike=False):
256 """Construct a dict of list of Amplifer, one list per detector.
257
258 Parameters
259 ----------
260 ampFile : `str`
261 Path to amplifier data file.
262 isLsstLike : `bool`
263 If True then there is one raw image per amplifier;
264 if False then there is one raw image per detector.
265 """
266 readoutMap = {
267 'LL': ReadoutCorner.LL,
268 'LR': ReadoutCorner.LR,
269 'UR': ReadoutCorner.UR,
270 'UL': ReadoutCorner.UL,
271 }
272 ampDataList = []
273 with open(ampFile) as fh:
274 names = fh.readline().rstrip().lstrip("#").split("|")
275 for line in fh:
276 els = line.rstrip().split("|")
277 ampProps = dict([(name, el) for name, el in zip(names, els)])
278 ampDataList.append(ampProps)
279 ampListDict = {}
280 self.ampDataDict = {}
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
285 else:
286 ampList = []
287 ampListDict[ampData['ccd_name']] = ampList
288 self.ampDataDict[ampData['ccd_name']] = {'namps': 1, 'linInfo': {}}
289 builder = Amplifier.Builder()
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']))
322 readcorner = 'LL'
323 if not isLsstLike:
325 if flipx:
326 xExt = rawBbox.getDimensions().getX()
327 rawBbox.flipLR(xExt)
328 rawDataBbox.flipLR(xExt)
329 rawHOverscanBbox.flipLR(xExt)
330 rawVOverscanBbox.flipLR(xExt)
331 rawPrescanBbox.flipLR(xExt)
332 if flipy:
333 yExt = rawBbox.getDimensions().getY()
334 rawBbox.flipTB(yExt)
335 rawDataBbox.flipTB(yExt)
336 rawHOverscanBbox.flipTB(yExt)
337 rawVOverscanBbox.flipTB(yExt)
338 rawPrescanBbox.flipTB(yExt)
339 if not flipx and not flipy:
340 readcorner = 'LL'
341 elif flipx and not flipy:
342 readcorner = 'LR'
343 elif flipx and flipy:
344 readcorner = 'UR'
345 elif not flipx and flipy:
346 readcorner = 'UL'
347 else:
348 raise RuntimeError("Couldn't find read corner")
349
350 flipx = False
351 flipy = False
352 rawBbox.shift(offext)
353 rawDataBbox.shift(offext)
354 rawHOverscanBbox.shift(offext)
355 rawVOverscanBbox.shift(offext)
356 rawPrescanBbox.shift(offext)
357 xoffset = 0
358 yoffset = 0
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)
384 return ampListDict
385
An integer coordinate rectangle.