22 __all__ = [
'assembleAmplifierImage',
'assembleAmplifierRawImage',
23 'makeUpdatedDetector']
26 from .
import copyDetector
30 False: slice(
None,
None, 1),
31 True: slice(
None,
None, -1),
35 def _insertPixelChunk(outView, inView, amplifier, hasArrays):
40 xSlice = _SliceDict[amplifier.getRawFlipX()]
41 ySlice = _SliceDict[amplifier.getRawFlipY()]
44 inArrList = inView.getArrays()
45 outArrList = outView.getArrays()
47 inArrList = [inView.getArray()]
48 outArrList = [outView.getArray()]
50 for inArr, outArr
in zip(inArrList, outArrList):
52 outArr[:] = inArr[ySlice, xSlice]
56 """Assemble the amplifier region of an image from a raw image. 60 destImage : `lsst.afw.image.Image` or `lsst.afw.image.MaskedImage` 61 Assembled image; the region amplifier.getBBox() is overwritten with 62 the assembled amplifier image. 63 rawImage : `lsst.afw.image.Image` or `lsst.afw.image.MaskedImage` 64 Raw image (same type as destImage). 65 amplifier : `lsst.afw.table.AmpInfoRecord` 66 Amplifier geometry, with raw amplifier info. 71 Raised if image types do not match or amplifier has no raw amplifier info. 73 if not amplifier.getHasRawInfo():
74 raise RuntimeError(
"amplifier must contain raw amplifier info")
75 if type(destImage.Factory) !=
type(rawImage.Factory):
76 raise RuntimeError(
"destImage type = %s != %s = rawImage type" %
77 type(destImage.Factory).__name__,
type(rawImage.Factory).__name__)
78 inView = rawImage.Factory(rawImage, amplifier.getRawDataBBox())
79 outView = destImage.Factory(destImage, amplifier.getBBox())
81 _insertPixelChunk(outView, inView, amplifier,
82 hasattr(rawImage,
"getArrays"))
86 """Assemble the amplifier region of a raw CCD image. 88 For most cameras this is a no-op: the raw image already is an assembled 90 However, it is useful for camera such as LSST for which each amplifier 91 image is a separate image. 95 destImage : `lsst.afw.image.Image` or `lsst.afw.image.MaskedImage` 96 CCD Image; the region amplifier.getRawAmplifier().getBBox() 97 is overwritten with the raw amplifier image. 98 rawImage : `lsst.afw.image.Image` or `lsst.afw.image.MaskedImage` 99 Raw image (same type as destImage). 100 amplifier : `lsst.afw.table.AmpInfoRecord` 101 Amplifier geometry with raw amplifier info 106 Raised if image types do not match or amplifier has no raw amplifier info. 108 if not amplifier.getHasRawInfo():
109 raise RuntimeError(
"amplifier must contain raw amplifier info")
110 if type(destImage.Factory) !=
type(rawImage.Factory):
111 raise RuntimeError(
"destImage type = %s != %s = rawImage type" %
112 type(destImage.Factory).__name__,
type(rawImage.Factory).__name__)
113 inBBox = amplifier.getRawBBox()
114 inView = rawImage.Factory(rawImage, inBBox)
115 outBBox = amplifier.getRawBBox()
116 outBBox.shift(amplifier.getRawXYOffset())
117 outView = destImage.Factory(destImage, outBBox)
119 _insertPixelChunk(outView, inView, amplifier,
120 hasattr(rawImage,
"getArrays"))
124 """Return a Detector that has had the definitions of amplifier geometry 125 updated post assembly. 129 ccd : `lsst.afw.image.Detector` 130 The detector to copy and update. 132 ampInfoCatalog = ccd.getAmpInfoCatalog().copy(deep=
True)
134 for amp
in ampInfoCatalog:
135 assert amp.getHasRawInfo()
137 bbox = amp.getRawBBox()
138 awidth, aheight = bbox.getDimensions()
142 boxMin0 = bbox.getMin()
143 if amp.getRawFlipX():
145 if amp.getRawFlipY():
147 shift = boxMin0 - bbox.getMin()
150 "HorizontalOverscan",
154 bbox = getattr(amp,
"getRaw%sBBox" % bboxName)()
155 if amp.getRawFlipX():
157 if amp.getRawFlipY():
159 bbox.shift(amp.getRawXYOffset() + shift)
161 getattr(amp,
"setRaw%sBBox" % bboxName)(bbox)
166 amp.setRawFlipX(
False)
167 amp.setRawFlipY(
False)
def copyDetector(detector, ampInfoCatalog=None)
def makeUpdatedDetector(ccd)
def assembleAmplifierImage(destImage, rawImage, amplifier)
def assembleAmplifierRawImage(destImage, rawImage, amplifier)