22 __all__ = [
'assembleAmplifierImage',
'assembleAmplifierRawImage',
23 'makeUpdatedDetector']
29 False: slice(
None,
None, 1),
30 True: slice(
None,
None, -1),
34 def _insertPixelChunk(outView, inView, amplifier, hasArrays):
39 xSlice = _SliceDict[amplifier.getRawFlipX()]
40 ySlice = _SliceDict[amplifier.getRawFlipY()]
43 inArrList = inView.getArrays()
44 outArrList = outView.getArrays()
46 inArrList = [inView.getArray()]
47 outArrList = [outView.getArray()]
49 for inArr, outArr
in zip(inArrList, outArrList):
51 outArr[:] = inArr[ySlice, xSlice]
55 """Assemble the amplifier region of an image from a raw image.
59 destImage : `lsst.afw.image.Image` or `lsst.afw.image.MaskedImage`
60 Assembled image; the region amplifier.getBBox() is overwritten with
61 the assembled amplifier image.
62 rawImage : `lsst.afw.image.Image` or `lsst.afw.image.MaskedImage`
63 Raw image (same type as destImage).
64 amplifier : `lsst.afw.cameraGeom.Amplifier`
65 Amplifier geometry, with raw amplifier info.
70 Raised if image types do not match or amplifier has no raw amplifier info.
72 if type(destImage.Factory) !=
type(rawImage.Factory):
73 raise RuntimeError(f
"destImage type = {type(destImage.Factory).__name__} != "
74 f
"{type(rawImage.Factory).__name__} = rawImage type")
75 inView = rawImage.Factory(rawImage, amplifier.getRawDataBBox())
76 outView = destImage.Factory(destImage, amplifier.getBBox())
78 _insertPixelChunk(outView, inView, amplifier,
79 hasattr(rawImage,
"getArrays"))
83 """Assemble the amplifier region of a raw CCD image.
85 For most cameras this is a no-op: the raw image already is an assembled
87 However, it is useful for camera such as LSST for which each amplifier
88 image is a separate image.
92 destImage : `lsst.afw.image.Image` or `lsst.afw.image.MaskedImage`
93 CCD Image; the region amplifier.getRawAmplifier().getBBox()
94 is overwritten with the raw amplifier image.
95 rawImage : `lsst.afw.image.Image` or `lsst.afw.image.MaskedImage`
96 Raw image (same type as destImage).
97 amplifier : `lsst.afw.cameraGeom.Amplifier`
98 Amplifier geometry with raw amplifier info
103 Raised if image types do not match or amplifier has no raw amplifier info.
105 if type(destImage.Factory) !=
type(rawImage.Factory):
106 raise RuntimeError(f
"destImage type = {type(destImage.Factory).__name__} != "
107 f
"{type(rawImage.Factory).__name__} = rawImage type")
108 inBBox = amplifier.getRawBBox()
109 inView = rawImage.Factory(rawImage, inBBox)
110 outBBox = amplifier.getRawBBox()
111 outBBox.shift(amplifier.getRawXYOffset())
112 outView = destImage.Factory(destImage, outBBox)
114 _insertPixelChunk(outView, inView, amplifier,
115 hasattr(rawImage,
"getArrays"))
119 """Return a Detector that has had the definitions of amplifier geometry
120 updated post assembly.
124 ccd : `lsst.afw.image.Detector`
125 The detector to copy and update.
127 builder = ccd.rebuild()
128 for amp
in builder.getAmplifiers():
129 bbox = amp.getRawBBox()
130 awidth, aheight = bbox.getDimensions()
134 boxMin0 = bbox.getMin()
135 if amp.getRawFlipX():
137 if amp.getRawFlipY():
139 shift = boxMin0 - bbox.getMin()
142 "HorizontalOverscan",
146 bbox = getattr(amp, f
"getRaw{bboxName}BBox")()
147 if amp.getRawFlipX():
149 if amp.getRawFlipY():
151 bbox.shift(amp.getRawXYOffset() + shift)
153 getattr(amp, f
"setRaw{bboxName}BBox")(bbox)
158 amp.setRawFlipX(
False)
159 amp.setRawFlipY(
False)
161 return builder.finish()