180 backgroundMethod=
"None"):
181 """Subtract the intra-CCD crosstalk from an exposure 183 We set the mask plane indicated by ``crosstalkStr`` in a target amplifier 184 for pixels in a source amplifier that exceed `minPixelToMask`. Note that 185 the correction is applied to all pixels in the amplifier, but only those 186 that have a substantial crosstalk are masked with ``crosstalkStr``. 188 The uncorrected image is used as a template for correction. This is good 189 enough if the crosstalk is small (e.g., coefficients < ~ 1e-3), but if it's 190 larger you may want to iterate. 192 This method needs unittests (DM-18876), but such testing requires 193 DM-18610 to allow the test detector to have the crosstalk 198 exposure : `lsst.afw.image.Exposure` 199 Exposure for which to subtract crosstalk. 200 badPixels : `list` of `str` 201 Mask planes to ignore. 202 minPixelToMask : `float` 203 Minimum pixel value (relative to the background level) in 204 source amplifier for which to set ``crosstalkStr`` mask plane 207 Mask plane name for pixels greatly modified by crosstalk. 209 The image is already trimmed. 210 This should no longer be needed once DM-15409 is resolved. 211 backgroundMethod : `str` 212 Method used to subtract the background. "AMP" uses 213 amplifier-by-amplifier background levels, "DETECTOR" uses full 214 exposure/maskedImage levels. Any other value results in no 215 background subtraction. 217 mi = exposure.getMaskedImage()
220 ccd = exposure.getDetector()
222 coeffs = ccd.getCrosstalk()
223 assert coeffs.shape == (numAmps, numAmps)
231 backgrounds = [0.0
for amp
in ccd]
232 if backgroundMethod
is None:
234 elif backgroundMethod ==
"AMP":
236 elif backgroundMethod ==
"DETECTOR":
240 crosstalkPlane = mask.addMaskPlane(crosstalkStr)
242 thresholdBackground))
243 footprints.setMask(mask, crosstalkStr)
244 crosstalk = mask.getPlaneBitMask(crosstalkStr)
247 subtrahend = mi.Factory(mi.getBBox())
248 subtrahend.set((0, 0, 0))
249 for ii, iAmp
in enumerate(ccd):
250 iImage = subtrahend[iAmp.getBBox()
if isTrimmed
else iAmp.getRawDataBBox()]
251 for jj, jAmp
in enumerate(ccd):
253 assert coeffs[ii, jj] == 0.0
254 if coeffs[ii, jj] == 0.0:
257 jImage =
extractAmp(mi, jAmp, iAmp.getReadoutCorner(), isTrimmed)
258 jImage.getMask().getArray()[:] &= crosstalk
259 jImage -= backgrounds[jj]
261 iImage.scaledPlus(coeffs[ii, jj], jImage)
265 mask.clearMaskPlane(crosstalkPlane)
A Threshold is used to pass a threshold value to detection algorithms.
def calculateBackground(mi, badPixels=["BAD"])
def extractAmp(image, amp, corner, isTrimmed=False)