25 "attachTransmissionCurve",
28 "compareCameraKeywords",
41 "illuminationCorrection",
42 "interpolateDefectList",
43 "interpolateFromMask",
45 "saturationCorrection",
47 "transposeMaskedImage",
48 "trimToMatchCalibBBox",
50 "widenSaturationTrails",
52 "getExposureReadNoises",
69from contextlib
import contextmanager
71from .defects
import Defects
75 """Make a double Gaussian PSF.
80 FWHM of double Gaussian smoothing kernel.
84 psf : `lsst.meas.algorithms.DoubleGaussianPsf`
85 The created smoothing kernel.
87 ksize = 4*int(fwhm) + 1
88 return measAlg.DoubleGaussianPsf(ksize, ksize, fwhm/(2*math.sqrt(2*math.log(2))))
92 """Make a transposed copy of a masked image.
96 maskedImage : `lsst.afw.image.MaskedImage`
101 transposed : `lsst.afw.image.MaskedImage`
102 The transposed copy of the input image.
104 transposed = maskedImage.Factory(
lsst.geom.Extent2I(maskedImage.getHeight(), maskedImage.getWidth()))
105 transposed.getImage().getArray()[:] = maskedImage.getImage().getArray().T
106 transposed.getMask().getArray()[:] = maskedImage.getMask().getArray().T
107 transposed.getVariance().getArray()[:] = maskedImage.getVariance().getArray().T
112 maskNameList=None, useLegacyInterp=True):
113 """Interpolate over defects specified in a defect list.
117 maskedImage : `lsst.afw.image.MaskedImage`
119 defectList : `lsst.meas.algorithms.Defects`
120 List of defects to interpolate over.
122 FWHM of double Gaussian smoothing kernel.
123 fallbackValue : scalar, optional
124 Fallback value if an interpolated value cannot be determined.
125 If None, then the clipped mean of the image is used.
126 maskNameList : `list [string]`
127 List of the defects to interpolate over (used for GP interpolator).
128 useLegacyInterp : `bool`
129 Use the legacy interpolation (polynomial interpolation) if True. Use
130 Gaussian Process interpolation if False.
134 The ``fwhm`` parameter is used to create a PSF, but the underlying
135 interpolation code (`lsst.meas.algorithms.interpolateOverDefects`) does
136 not currently make use of this information in legacy Interpolation, but use
137 if for the Gaussian Process as an estimation of the correlation lenght.
140 if fallbackValue
is None:
142 fallbackValue = numpy.nanmedian(maskedImage.image.array[::4, ::4])
143 if 'INTRP' not in maskedImage.getMask().getMaskPlaneDict():
144 maskedImage.getMask().addMaskPlane(
'INTRP')
155 kwargs = {
"bin_spacing": 20,
156 "threshold_dynamic_binning": 2000,
157 "threshold_subdivide": 20000}
160 measAlg.interpolateOverDefects(maskedImage, psf, defectList,
161 fallbackValue=fallbackValue,
162 useFallbackValueAtEdge=
True,
164 useLegacyInterp=useLegacyInterp,
165 maskNameList=maskNameList, **kwargs)
170 """Mask pixels based on threshold detection.
174 maskedImage : `lsst.afw.image.MaskedImage`
175 Image to process. Only the mask plane is updated.
178 growFootprints : scalar, optional
179 Number of pixels to grow footprints of detected regions.
180 maskName : str, optional
181 Mask plane name, or list of names to convert
185 defectList : `lsst.meas.algorithms.Defects`
186 Defect list constructed from pixels above the threshold.
189 thresh = afwDetection.Threshold(threshold)
190 fs = afwDetection.FootprintSet(maskedImage, thresh)
192 if growFootprints > 0:
193 fs = afwDetection.FootprintSet(fs, rGrow=growFootprints, isotropic=
False)
194 fpList = fs.getFootprints()
197 mask = maskedImage.getMask()
198 bitmask = mask.getPlaneBitMask(maskName)
199 afwDetection.setMaskFromFootprintList(mask, fpList, bitmask)
201 return Defects.fromFootprintList(fpList)
204def growMasks(mask, radius=0, maskNameList=['BAD'], maskValue="BAD"):
205 """Grow a mask by an amount and add to the requested plane.
209 mask : `lsst.afw.image.Mask`
210 Mask image to process.
212 Amount to grow the mask.
213 maskNameList : `str` or `list` [`str`]
214 Mask names that should be grown.
216 Mask plane to assign the newly masked pixels to.
219 spans = SpanSet.fromMask(mask, mask.getPlaneBitMask(maskNameList))
222 spans = spans.dilated(radius, Stencil.MANHATTAN)
223 spans = spans.clippedTo(mask.getBBox())
224 spans.setMask(mask, mask.getPlaneBitMask(maskValue))
228 e2vEdgeBleedSatMaxArea=100000,
229 e2vEdgeBleedYMax=350,
230 saturatedMaskName="SAT", log=None):
231 """Mask edge bleeds in E2V detectors.
235 exposure : `lsst.afw.image.Exposure`
236 Exposure to apply masking to.
237 e2vEdgeBleedSatMinArea : `int`, optional
238 Minimum limit of saturated cores footprint area.
239 e2vEdgeBleedSatMaxArea : `int`, optional
240 Maximum limit of saturated cores footprint area.
241 e2vEdgeBleedYMax: `float`, optional
242 Height of edge bleed masking.
243 saturatedMaskName : `str`, optional
244 Mask name for saturation.
245 log : `logging.Logger`, optional
246 Logger to handle messages.
249 log = log
if log
else logging.getLogger(__name__)
251 maskedImage = exposure.maskedImage
252 saturatedBit = maskedImage.mask.getPlaneBitMask(saturatedMaskName)
254 thresh = afwDetection.Threshold(saturatedBit, afwDetection.Threshold.BITMASK)
256 fpList = afwDetection.FootprintSet(exposure.mask, thresh).getFootprints()
258 satAreas = numpy.asarray([fp.getArea()
for fp
in fpList])
259 largeAreas, = numpy.where((satAreas >= e2vEdgeBleedSatMinArea)
260 & (satAreas < e2vEdgeBleedSatMaxArea))
261 for largeAreasIndex
in largeAreas:
262 fpCore = fpList[largeAreasIndex]
263 xCore, yCore = fpCore.getCentroid()
267 for amp
in exposure.getDetector():
268 if amp.getBBox().contains(xCore, yCore):
269 ampName = amp.getName()
270 if ampName[:2] ==
'C0':
273 if fpCore.getBBox().getMinY() == 0:
281 log.info(
"Found E2V edge bleed in amp %s, column %d.", ampName, xCore)
282 maskedImage.mask[amp.getBBox()].array[:e2vEdgeBleedYMax, :] |= saturatedBit
286 nRowsCheck=20, nRowsCheckShort=5, minUsablePixelsPerRow=30,
287 minLowFraction=0.03, minLowFractionExtent=0.01, minBlockedRows=5,
288 marginFraction=0.125, saturatedMaskName="SAT", log=None):
289 """Mask DECam-style edge bleeds with low rows next to the read register.
291 For each amplifier that contains a large saturated footprint reaching
292 within ``approachRows`` of its read edge, this function identifies a dip
293 using the per-row fraction of usable pixels more than ``nSigma`` below
294 the clipped sky, measures how far the dip extends inward, and marks
295 those rows (plus a margin) with the saturation mask plane.
297 Rows next to the read edge that are unusable are the signature of a
298 drained serial register, which the overscan correction flags as bad;
299 ``minBlockedRows`` rows are also flagged, despite not having a
304 exposure : `lsst.afw.image.Exposure`
305 Assembled exposure to mask.
306 satMinArea : `int`, optional
307 Minimum area (pixels) of a saturated footprint to be considered.
308 approachRows : `int`, optional
309 A saturated footprint must come within this many rows of the read edge
310 to trigger the edge bleed check.
311 nSigma : `float`, optional
312 A pixel is "low" if it is more than this many sigma below sky.
313 nRowsCheck : `int`, optional
314 Number of rows from the read edge to check for an edge bleed dip.
315 nRowsCheckShort : `int`, optional
316 A second, shorter window from the read edge to check for a short
318 minUsablePixelsPerRow : `int`, optional
319 Minimum number of pixels not saturated, bad or missing to search for
320 dips. Rows with fewer pixels may be "blocked" due to a drained
322 minLowFraction : `float`, optional
323 Mean fraction of usable pixels that are low, over either ``nRowsCheck``
324 or ``nRowsCheckShort``, to confirm a dip.
325 minLowFractionExtent : `float`, optional
326 Fraction of usable pixels that are low that each row must exceed
327 to count toward the bleed height; the scan stops after five consecutive
328 rows that do not. Should not exceed ``minLowFraction``.
329 minBlockedRows : `int`, optional
330 Minimum number of blocked rows beyond the normal border at the read
331 edge to be masked if found.
332 marginFraction : `float`, optional
333 Extra rows masked beyond the measured height, as a fraction of
334 that height (plus one row).
335 saturatedMaskName : `str`, optional
336 Mask plane name for saturation.
337 log : `logging.Logger`, optional
338 Logger to handle messages.
343 Raised if the exposure has no detector with amplifiers.
345 log = log
if log
else logging.getLogger(__name__)
347 detector = exposure.getDetector()
348 if detector
is None or len(detector) == 0:
349 raise RuntimeError(
"Cannot mask DECam edge bleeds: exposure has no detector with amplifiers.")
351 maskedImage = exposure.maskedImage
352 saturatedBit = maskedImage.mask.getPlaneBitMask(saturatedMaskName)
353 borderBits = maskedImage.mask.getPlaneBitMask([
"BAD",
"NO_DATA"])
354 unusableBits = borderBits | saturatedBit
355 excludeStatsBits = unusableBits | maskedImage.mask.getPlaneBitMask(
"SUSPECT")
358 thresh = afwDetection.Threshold(saturatedBit, afwDetection.Threshold.BITMASK)
359 fpList = afwDetection.FootprintSet(maskedImage.mask, thresh).getFootprints()
362 if fp.getArea() >= satMinArea:
363 xCore, yCore = fp.getCentroid()
364 candidates.append((int(xCore), int(yCore), fp.getBBox()))
366 log.debug(
"No saturated footprints large enough for the DECam edge bleed check.")
369 statsCtrl = afwMath.StatisticsControl()
370 statsCtrl.setAndMask(excludeStatsBits)
376 ampBBox = amp.getBBox()
377 if not exposure.getBBox().contains(ampBBox):
379 readTop = amp.getReadoutCorner()
in (camGeom.ReadoutCorner.UL, camGeom.ReadoutCorner.UR)
383 reachesReadEdge = any(ampBBox.contains(x, y)
384 and fpBBox.getMaxY() >= ampBBox.getMaxY() - approachRows
385 for x, y, fpBBox
in candidates)
387 reachesReadEdge = any(ampBBox.contains(x, y)
388 and fpBBox.getMinY() <= ampBBox.getMinY() + approachRows
389 for x, y, fpBBox
in candidates)
390 if not reachesReadEdge:
393 ampImage = maskedImage[ampBBox]
394 stats = afwMath.makeStatistics(ampImage, afwMath.MEANCLIP | afwMath.STDEVCLIP | afwMath.NPOINT,
396 if stats.getValue(afwMath.NPOINT) < 1000:
397 log.debug(
"Skipping DECam edge bleed check in amp %s: too few unmasked pixels.",
400 sky = stats.getValue(afwMath.MEANCLIP)
401 sigma = stats.getValue(afwMath.STDEVCLIP)
403 usable = (ampImage.mask.array & unusableBits) == 0
404 low = (ampImage.image.array < sky - nSigma*sigma) & usable
406 nLow = low.sum(axis=1)
407 nUsable = usable.sum(axis=1)
408 nBorderUsable = ((ampImage.mask.array & borderBits) == 0).sum(axis=1)
411 nUsable = nUsable[::-1]
413 nBorderUsable = nBorderUsable[::-1]
415 enoughUsable = numpy.nonzero(nUsable >= minUsablePixelsPerRow)[0]
416 if len(enoughUsable) == 0:
417 log.debug(
"Skipping DECam edge bleed check in amp %s: no rows with usable pixels.",
420 start = int(enoughUsable[0])
421 borderRows = numpy.nonzero(nBorderUsable >= minUsablePixelsPerRow)[0]
422 border = int(borderRows[0])
if len(borderRows)
else 0
423 blocked = start - border
425 fraction = numpy.zeros(len(nLow), dtype=float)
426 good = nUsable >= minUsablePixelsPerRow
427 fraction[good] = nLow[good]/nUsable[good]
429 dipFound = fraction[start:start + nRowsCheck].mean() > minLowFraction
430 if nRowsCheckShort > 0:
431 dipFound |= fraction[start:start + nRowsCheckShort].mean() > minLowFraction
432 if not dipFound
and blocked < minBlockedRows:
433 log.debug(
"Saturated footprint reaches read edge of amp %s but no dip found.",
437 height = start
if blocked >= minBlockedRows
else 0
439 for i
in range(start, len(fraction)):
440 if fraction[i] > minLowFractionExtent:
445 if nBelow >= nRowsStop:
447 height += int(height*marginFraction) + 1
448 height = min(height, ampBBox.getHeight())
451 maskedImage.mask[ampBBox].array[-height:, :] |= saturatedBit
453 maskedImage.mask[ampBBox].array[:height, :] |= saturatedBit
454 log.info(
"Found DECam edge bleed in amp %s at the %s read edge (%d blocked rows); masked %d rows.",
455 amp.getName(),
"top" if readTop
else "bottom", max(blocked, 0), height)
459 fpCore, itlEdgeBleedSatMinArea=10000,
460 itlEdgeBleedSatMaxArea=100000,
461 itlEdgeBleedThreshold=5000.,
462 itlEdgeBleedModelConstant=0.02,
463 saturatedMaskName="SAT", log=None):
464 """Mask edge bleeds in ITL detectors.
468 ccdExposure : `lsst.afw.image.Exposure`
469 Exposure to apply masking to.
470 badAmpDict : `dict` [`str`, `bool`]
471 Dictionary of amplifiers, keyed by name, value is True if
472 amplifier is fully masked.
473 fpCore : `lsst.afw.detection._detection.Footprint`
474 Footprint of saturated core.
475 itlEdgeBleedThreshold : `float`, optional
476 Threshold above median sky background for edge bleed detection
478 itlEdgeBleedModelConstant : `float`, optional
479 Constant in the decaying exponential in the edge bleed masking.
480 saturatedMaskName : `str`, optional
481 Mask name for saturation.
482 log : `logging.Logger`, optional
483 Logger to handle messages.
486 log = log
if log
else logging.getLogger(__name__)
489 satLevel = numpy.nanmedian([ccdExposure.metadata[f
"LSST ISR SATURATION LEVEL {amp.getName()}"]
490 for amp
in ccdExposure.getDetector()
if not badAmpDict[amp.getName()]])
494 xCore, yCore = fpCore.getCentroid()
496 yCoreFP = int(yCore) - fpCore.getBBox().getMinY()
500 checkCoreNbRow = fpCore.getSpans().asArray()[yCoreFP, :]
503 indexSwitchFalse = []
504 if checkCoreNbRow[0]:
508 indexSwitchTrue.append(0)
513 for i, value
in enumerate(checkCoreNbRow):
516 indexSwitchTrue.append(i)
521 indexSwitchFalse.append(i)
529 xEdgesCores.append(int((indexSwitchTrue[1] + indexSwitchFalse[0])/2))
530 xEdgesCores.append(fpCore.getSpans().asArray().shape[1])
532 for i
in range(nbCore):
533 subfp = fpCore.getSpans().asArray()[:, xEdgesCores[i]:xEdgesCores[i+1]]
534 xCoreFP = int(xEdgesCores[i] + numpy.argmax(numpy.sum(subfp, axis=0)))
536 xCore = xCoreFP + fpCore.getBBox().getMinX()
539 if subfp.shape[0] <= 200:
540 yCoreFP = int(numpy.argmax(numpy.sum(subfp, axis=1)))
542 yCoreFP = int(numpy.argmax(numpy.sum(subfp[100:-100, :],
544 yCoreFP = 100+yCoreFP
547 widthSat = numpy.sum(subfp[int(yCoreFP), :])
549 subfpArea = numpy.sum(subfp)
550 if subfpArea > itlEdgeBleedSatMinArea
and subfpArea < itlEdgeBleedSatMaxArea:
553 itlEdgeBleedThreshold,
554 itlEdgeBleedModelConstant,
555 saturatedMaskName, log)
559 "Too many (%d) cores in saturated footprint to mask edge bleeds.",
564 xCore, yCore = fpCore.getCentroid()
566 yCoreFP = yCore - fpCore.getBBox().getMinY()
568 widthSat = numpy.sum(fpCore.getSpans().asArray()[int(yCoreFP), :])
570 satLevel, widthSat, itlEdgeBleedThreshold,
571 itlEdgeBleedModelConstant, saturatedMaskName, log)
576 itlEdgeBleedThreshold=5000.,
577 itlEdgeBleedModelConstant=0.03,
578 saturatedMaskName="SAT", log=None):
579 """Apply ITL edge bleed masking model.
583 ccdExposure : `lsst.afw.image.Exposure`
584 Exposure to apply masking to.
586 X coordinate of the saturated core.
588 Minimum saturation level of the detector.
590 Width of the saturated core.
591 itlEdgeBleedThreshold : `float`, optional
592 Threshold above median sky background for edge bleed detection
594 itlEdgeBleedModelConstant : `float`, optional
595 Constant in the decaying exponential in the edge bleed masking.
596 saturatedMaskName : `str`, optional
597 Mask name for saturation.
598 log : `logging.Logger`, optional
599 Logger to handle messages.
601 log = log
if log
else logging.getLogger(__name__)
603 maskedImage = ccdExposure.maskedImage
604 xmax = maskedImage.image.array.shape[1]
605 saturatedBit = maskedImage.mask.getPlaneBitMask(saturatedMaskName)
607 for amp
in ccdExposure.getDetector():
613 yBox = amp.getBBox().getCenter()[1]
614 if amp.getBBox().contains(xCore, yBox):
617 ampName = amp.getName()
627 if ampName[:2] ==
'C1':
628 sliceImage = maskedImage.image.array[:200, :]
629 sliceMask = maskedImage.mask.array[:200, :]
630 elif ampName[:2] ==
'C0':
631 sliceImage = numpy.flipud(maskedImage.image.array[-200:, :])
632 sliceMask = numpy.flipud(maskedImage.mask.array[-200:, :])
644 lowerRangeSmall = int(xCore)-5
645 upperRangeSmall = int(xCore)+5
646 if lowerRangeSmall < 0:
648 if upperRangeSmall > xmax:
649 upperRangeSmall = xmax
650 ampImageBG = numpy.median(maskedImage[amp.getBBox()].image.array)
651 edgeMedian = numpy.median(sliceImage[:50, lowerRangeSmall:upperRangeSmall])
652 if edgeMedian > (ampImageBG + itlEdgeBleedThreshold):
654 log.info(
"Found ITL edge bleed in amp %s, column %d.", ampName, xCore)
663 subImageXMin = int(xCore)-250
664 subImageXMax = int(xCore)+250
667 elif subImageXMax > xmax:
670 subImage = sliceImage[:100, subImageXMin:subImageXMax]
671 maxWidthEdgeBleed = numpy.max(numpy.sum(subImage > 0.45*satLevel,
676 edgeBleedHalfWidth = \
677 int(((maxWidthEdgeBleed)*numpy.exp(-itlEdgeBleedModelConstant*y)
679 lowerRange = int(xCore)-edgeBleedHalfWidth
680 upperRange = int(xCore)+edgeBleedHalfWidth
686 if upperRange > xmax:
688 sliceMask[y, lowerRange:upperRange] |= saturatedBit
692 """Mask columns presenting saturation sag in saturated footprints in
697 ccdExposure : `lsst.afw.image.Exposure`
698 Exposure to apply masking to.
699 fpCore : `lsst.afw.detection._detection.Footprint`
700 Footprint of saturated core.
701 saturatedMaskName : `str`, optional
702 Mask name for saturation.
707 maskedImage = ccdExposure.maskedImage
708 saturatedBit = maskedImage.mask.getPlaneBitMask(saturatedMaskName)
710 cc = numpy.sum(fpCore.getSpans().asArray(), axis=0)
713 columnsToMaskFP = numpy.where(cc > fpCore.getSpans().asArray().shape[0]/5.)
715 columnsToMask = [x + int(fpCore.getBBox().getMinX())
for x
in columnsToMaskFP]
716 maskedImage.mask.array[:, columnsToMask] |= saturatedBit
719def maskITLDip(exposure, detectorConfig, maskPlaneNames=["SUSPECT", "ITL_DIP"], log=None):
720 """Add mask bits according to the ITL dip model.
724 exposure : `lsst.afw.image.Exposure`
725 Exposure to do ITL dip masking.
726 detectorConfig : `lsst.ip.isr.overscanAmpConfig.OverscanDetectorConfig`
727 Configuration for this detector.
728 maskPlaneNames : `list [`str`], optional
729 Name of the ITL Dip mask planes.
730 log : `logging.Logger`, optional
731 If not set, a default logger will be used.
733 if detectorConfig.itlDipBackgroundFraction == 0.0:
738 log = logging.getLogger(__name__)
740 thresh = afwDetection.Threshold(
741 exposure.mask.getPlaneBitMask(
"SAT"),
742 afwDetection.Threshold.BITMASK,
744 fpList = afwDetection.FootprintSet(exposure.mask, thresh).getFootprints()
746 heights = numpy.asarray([fp.getBBox().getHeight()
for fp
in fpList])
748 largeHeights, = numpy.where(heights >= detectorConfig.itlDipMinHeight)
750 if len(largeHeights) == 0:
754 approxBackground = numpy.median(exposure.image.array)
755 maskValue = exposure.mask.getPlaneBitMask(maskPlaneNames)
757 maskBak = exposure.mask.array.copy()
760 for index
in largeHeights:
762 center = fp.getCentroid()
764 nSat = numpy.sum(fp.getSpans().asArray(), axis=0)
765 width = numpy.sum(nSat > detectorConfig.itlDipMinHeight)
767 if width < detectorConfig.itlDipMinWidth:
770 width = numpy.clip(width,
None, detectorConfig.itlDipMaxWidth)
772 dipMax = detectorConfig.itlDipBackgroundFraction * approxBackground * width
775 if dipMax < detectorConfig.itlDipMinBackgroundNoiseFraction * numpy.sqrt(approxBackground):
778 minCol = int(center.getX() - (detectorConfig.itlDipWidthScale * width) / 2.)
779 maxCol = int(center.getX() + (detectorConfig.itlDipWidthScale * width) / 2.)
780 minCol = numpy.clip(minCol, 0,
None)
781 maxCol = numpy.clip(maxCol,
None, exposure.mask.array.shape[1] - 1)
784 "Found ITL dip (width %d; bkg %.2f); masking column %d to %d.",
791 exposure.mask.array[:, minCol: maxCol + 1] |= maskValue
793 nMaskedCols += (maxCol - minCol + 1)
795 if nMaskedCols > detectorConfig.itlDipMaxColsPerImage:
797 "Too many (%d) columns would be masked on this image from dip masking; restoring original mask.",
800 exposure.mask.array[:, :] = maskBak
804 maskNameList=['SAT'], fallbackValue=None, useLegacyInterp=True):
805 """Interpolate over defects identified by a particular set of mask planes.
809 maskedImage : `lsst.afw.image.MaskedImage`
812 FWHM of double Gaussian smoothing kernel.
813 growSaturatedFootprints : scalar, optional
814 Number of pixels to grow footprints for saturated pixels.
815 maskNameList : `List` of `str`, optional
817 fallbackValue : scalar, optional
818 Value of last resort for interpolation.
822 The ``fwhm`` parameter is used to create a PSF, but the underlying
823 interpolation code (`lsst.meas.algorithms.interpolateOverDefects`) does
824 not currently make use of this information.
826 mask = maskedImage.getMask()
828 if growSaturatedFootprints > 0
and "SAT" in maskNameList:
832 growMasks(mask, radius=growSaturatedFootprints, maskNameList=[
'SAT'], maskValue=
"SAT")
834 thresh = afwDetection.Threshold(mask.getPlaneBitMask(maskNameList), afwDetection.Threshold.BITMASK)
835 fpSet = afwDetection.FootprintSet(mask, thresh)
836 defectList = Defects.fromFootprintList(fpSet.getFootprints())
839 maskNameList=maskNameList, useLegacyInterp=useLegacyInterp)
845 fallbackValue=None, useLegacyInterp=True):
846 """Mark saturated pixels and optionally interpolate over them
850 maskedImage : `lsst.afw.image.MaskedImage`
853 Saturation level used as the detection threshold.
855 FWHM of double Gaussian smoothing kernel.
856 growFootprints : scalar, optional
857 Number of pixels to grow footprints of detected regions.
858 interpolate : Bool, optional
859 If True, saturated pixels are interpolated over.
860 maskName : str, optional
862 fallbackValue : scalar, optional
863 Value of last resort for interpolation.
867 The ``fwhm`` parameter is used to create a PSF, but the underlying
868 interpolation code (`lsst.meas.algorithms.interpolateOverDefects`) does
869 not currently make use of this information.
872 maskedImage=maskedImage,
873 threshold=saturation,
874 growFootprints=growFootprints,
879 maskNameList=[maskName], useLegacyInterp=useLegacyInterp)
885 """Compute number of edge trim pixels to match the calibration data.
887 Use the dimension difference between the raw exposure and the
888 calibration exposure to compute the edge trim pixels. This trim
889 is applied symmetrically, with the same number of pixels masked on
894 rawMaskedImage : `lsst.afw.image.MaskedImage`
896 calibMaskedImage : `lsst.afw.image.MaskedImage`
897 Calibration image to draw new bounding box from.
901 replacementMaskedImage : `lsst.afw.image.MaskedImage`
902 ``rawMaskedImage`` trimmed to the appropriate size.
907 Raised if ``rawMaskedImage`` cannot be symmetrically trimmed to
908 match ``calibMaskedImage``.
910 nx, ny = rawMaskedImage.getBBox().getDimensions() - calibMaskedImage.getBBox().getDimensions()
912 raise RuntimeError(
"Raw and calib maskedImages are trimmed differently in X and Y.")
914 raise RuntimeError(
"Calibration maskedImage is trimmed unevenly in X.")
916 raise RuntimeError(
"Calibration maskedImage is larger than raw data.")
920 replacementMaskedImage = rawMaskedImage[nEdge:-nEdge, nEdge:-nEdge, afwImage.LOCAL]
921 SourceDetectionTask.setEdgeBits(
923 replacementMaskedImage.getBBox(),
924 rawMaskedImage.getMask().getPlaneBitMask(
"EDGE")
927 replacementMaskedImage = rawMaskedImage
929 return replacementMaskedImage
932def biasCorrection(maskedImage, biasMaskedImage, trimToFit=False, imageOnly=False):
933 """Apply bias correction in place.
937 maskedImage : `lsst.afw.image.MaskedImage`
938 Image to process. The image is modified by this method.
939 biasMaskedImage : `lsst.afw.image.MaskedImage`
940 Bias image of the same size as ``maskedImage``
941 trimToFit : `Bool`, optional
942 If True, raw data is symmetrically trimmed to match
944 imageOnly : `bool`, optional
945 Apply the bias to the image plane only, skipping mask
951 Raised if ``maskedImage`` and ``biasMaskedImage`` do not have
958 if maskedImage.getBBox(afwImage.LOCAL) != biasMaskedImage.getBBox(afwImage.LOCAL):
959 raise RuntimeError(
"maskedImage bbox %s != biasMaskedImage bbox %s" %
960 (maskedImage.getBBox(afwImage.LOCAL), biasMaskedImage.getBBox(afwImage.LOCAL)))
962 maskedImage.image -= biasMaskedImage.image
964 maskedImage -= biasMaskedImage
976 """Apply dark correction in place.
980 maskedImage : `lsst.afw.image.MaskedImage`
981 Image to process. The image is modified by this method.
982 darkMaskedImage : `lsst.afw.image.MaskedImage`
983 Dark image of the same size as ``maskedImage``.
985 Dark exposure time for ``maskedImage``.
987 Dark exposure time for ``darkMaskedImage``.
988 invert : `Bool`, optional
989 If True, re-add the dark to an already corrected image.
990 trimToFit : `Bool`, optional
991 If True, raw data is symmetrically trimmed to match
993 imageOnly : `bool`, optional
994 Apply the dark to the image plane only, skipping mask
1000 Raised if ``maskedImage`` and ``darkMaskedImage`` do not have
1005 The dark correction is applied by calculating:
1006 maskedImage -= dark * expScaling / darkScaling
1011 if maskedImage.getBBox(afwImage.LOCAL) != darkMaskedImage.getBBox(afwImage.LOCAL):
1012 raise RuntimeError(
"maskedImage bbox %s != darkMaskedImage bbox %s" %
1013 (maskedImage.getBBox(afwImage.LOCAL), darkMaskedImage.getBBox(afwImage.LOCAL)))
1015 scale = expScale / darkScale
1018 maskedImage.image.scaledMinus(scale, darkMaskedImage.image)
1020 maskedImage.scaledMinus(scale, darkMaskedImage)
1023 maskedImage.image.scaledPlus(scale, darkMaskedImage.image)
1025 maskedImage.scaledPlus(scale, darkMaskedImage)
1029 """Set the variance plane based on the image plane.
1031 The maskedImage must have units of `adu` (if gain != 1.0) or
1032 electron (if gain == 1.0). This routine will always produce a
1033 variance plane in the same units as the image.
1037 maskedImage : `lsst.afw.image.MaskedImage`
1038 Image to process. The variance plane is modified.
1040 The amplifier gain in electron/adu.
1042 The amplifier read noise in electron/pixel.
1043 replace : `bool`, optional
1044 Replace the current variance? If False, the image
1045 variance will be added to the current variance plane.
1047 var = maskedImage.variance
1049 var[:, :] = maskedImage.image
1051 var[:, :] += maskedImage.image
1053 var += (readNoise/gain)**2
1065 """Apply flat correction in place.
1069 maskedImage : `lsst.afw.image.MaskedImage`
1070 Image to process. The image is modified.
1071 flatMaskedImage : `lsst.afw.image.MaskedImage`
1072 Flat image of the same size as ``maskedImage``
1074 Flat scale computation method. Allowed values are 'MEAN',
1075 'MEDIAN', or 'USER'.
1076 userScale : scalar, optional
1077 Scale to use if ``scalingType='USER'``.
1078 invert : `bool`, optional
1079 If True, unflatten an already flattened image.
1080 trimToFit : `bool`, optional
1081 If True, raw data is symmetrically trimmed to match
1083 imageOnly : `bool`, optional
1084 Apply the flat to the image plane only, skipping mask
1090 Raised if ``maskedImage`` and ``flatMaskedImage`` do not have
1091 the same size or if ``scalingType`` is not an allowed value.
1096 if maskedImage.getBBox(afwImage.LOCAL) != flatMaskedImage.getBBox(afwImage.LOCAL):
1097 raise RuntimeError(
"maskedImage bbox %s != flatMaskedImage bbox %s" %
1098 (maskedImage.getBBox(afwImage.LOCAL), flatMaskedImage.getBBox(afwImage.LOCAL)))
1104 if scalingType
in (
'MEAN',
'MEDIAN'):
1105 scalingType = afwMath.stringToStatisticsProperty(scalingType)
1106 flatScale = afwMath.makeStatistics(flatMaskedImage.image, scalingType).getValue()
1107 elif scalingType ==
'USER':
1108 flatScale = userScale
1110 raise RuntimeError(
'%s : %s not implemented' % (
"flatCorrection", scalingType))
1114 maskedImage.image.scaledDivides(1.0/flatScale, flatMaskedImage.image)
1116 maskedImage.scaledDivides(1.0/flatScale, flatMaskedImage)
1119 maskedImage.image.scaledMultiplies(1.0/flatScale, flatMaskedImage.image)
1121 maskedImage.scaledMultiplies(1.0/flatScale, flatMaskedImage)
1125 """Apply illumination correction in place.
1129 maskedImage : `lsst.afw.image.MaskedImage`
1130 Image to process. The image is modified.
1131 illumMaskedImage : `lsst.afw.image.MaskedImage`
1132 Illumination correction image of the same size as ``maskedImage``.
1134 Scale factor for the illumination correction.
1135 trimToFit : `Bool`, optional
1136 If True, raw data is symmetrically trimmed to match
1142 Raised if ``maskedImage`` and ``illumMaskedImage`` do not have
1148 if maskedImage.getBBox(afwImage.LOCAL) != illumMaskedImage.getBBox(afwImage.LOCAL):
1149 raise RuntimeError(
"maskedImage bbox %s != illumMaskedImage bbox %s" %
1150 (maskedImage.getBBox(afwImage.LOCAL), illumMaskedImage.getBBox(afwImage.LOCAL)))
1152 maskedImage.scaledDivides(1.0/illumScale, illumMaskedImage)
1156def gainContext(exp, image, apply, gains=None, invert=False, isTrimmed=True):
1157 """Context manager that applies and removes gain.
1161 exp : `lsst.afw.image.Exposure`
1162 Exposure to apply/remove gain.
1163 image : `lsst.afw.image.Image`
1164 Image to apply/remove gain.
1166 If True, apply and remove the amplifier gain.
1167 gains : `dict` [`str`, `float`], optional
1168 A dictionary, keyed by amplifier name, of the gains to use.
1169 If gains is None, the nominal gains in the amplifier object are used.
1170 invert : `bool`, optional
1171 Invert the gains (e.g. convert electrons to adu temporarily)?
1172 isTrimmed : `bool`, optional
1173 Is this a trimmed exposure?
1177 exp : `lsst.afw.image.Exposure`
1178 Exposure with the gain applied.
1182 if gains
and apply
is True:
1183 ampNames = [amp.getName()
for amp
in exp.getDetector()]
1184 for ampName
in ampNames:
1185 if ampName
not in gains.keys():
1186 raise RuntimeError(f
"Gains provided to gain context, but no entry found for amp {ampName}")
1189 ccd = exp.getDetector()
1191 sim = image.Factory(image, amp.getBBox()
if isTrimmed
else amp.getRawBBox())
1193 gain = gains[amp.getName()]
1195 gain = amp.getGain()
1205 ccd = exp.getDetector()
1207 sim = image.Factory(image, amp.getBBox()
if isTrimmed
else amp.getRawBBox())
1209 gain = gains[amp.getName()]
1211 gain = amp.getGain()
1219 sensorTransmission=None, atmosphereTransmission=None):
1220 """Attach a TransmissionCurve to an Exposure, given separate curves for
1221 different components.
1225 exposure : `lsst.afw.image.Exposure`
1226 Exposure object to modify by attaching the product of all given
1227 ``TransmissionCurves`` in post-assembly trimmed detector coordinates.
1228 Must have a valid ``Detector`` attached that matches the detector
1229 associated with sensorTransmission.
1230 opticsTransmission : `lsst.afw.image.TransmissionCurve`
1231 A ``TransmissionCurve`` that represents the throughput of the optics,
1232 to be evaluated in focal-plane coordinates.
1233 filterTransmission : `lsst.afw.image.TransmissionCurve`
1234 A ``TransmissionCurve`` that represents the throughput of the filter
1235 itself, to be evaluated in focal-plane coordinates.
1236 sensorTransmission : `lsst.afw.image.TransmissionCurve`
1237 A ``TransmissionCurve`` that represents the throughput of the sensor
1238 itself, to be evaluated in post-assembly trimmed detector coordinates.
1239 atmosphereTransmission : `lsst.afw.image.TransmissionCurve`
1240 A ``TransmissionCurve`` that represents the throughput of the
1241 atmosphere, assumed to be spatially constant.
1245 combined : `lsst.afw.image.TransmissionCurve`
1246 The TransmissionCurve attached to the exposure.
1250 All ``TransmissionCurve`` arguments are optional; if none are provided, the
1251 attached ``TransmissionCurve`` will have unit transmission everywhere.
1253 combined = afwImage.TransmissionCurve.makeIdentity()
1254 if atmosphereTransmission
is not None:
1255 combined *= atmosphereTransmission
1256 if opticsTransmission
is not None:
1257 combined *= opticsTransmission
1258 if filterTransmission
is not None:
1259 combined *= filterTransmission
1260 detector = exposure.getDetector()
1261 fpToPix = detector.getTransform(fromSys=camGeom.FOCAL_PLANE,
1262 toSys=camGeom.PIXELS)
1263 combined = combined.transformedBy(fpToPix)
1264 if sensorTransmission
is not None:
1265 combined *= sensorTransmission
1266 exposure.getInfo().setTransmissionCurve(combined)
1270def applyGains(exposure, normalizeGains=False, ptcGains=None, isTrimmed=True):
1271 """Scale an exposure by the amplifier gains.
1275 exposure : `lsst.afw.image.Exposure`
1276 Exposure to process. The image is modified.
1277 normalizeGains : `Bool`, optional
1278 If True, then amplifiers are scaled to force the median of
1279 each amplifier to equal the median of those medians.
1280 ptcGains : `dict`[`str`], optional
1281 Dictionary keyed by amp name containing the PTC gains.
1282 isTrimmed : `bool`, optional
1283 Is the input image trimmed?
1285 ccd = exposure.getDetector()
1286 ccdImage = exposure.getMaskedImage()
1291 sim = ccdImage.Factory(ccdImage, amp.getBBox())
1293 sim = ccdImage.Factory(ccdImage, amp.getRawBBox())
1295 sim *= ptcGains[amp.getName()]
1297 sim *= amp.getGain()
1300 medians.append(numpy.median(sim.getImage().getArray()))
1303 median = numpy.median(numpy.array(medians))
1304 for index, amp
in enumerate(ccd):
1306 sim = ccdImage.Factory(ccdImage, amp.getBBox())
1308 sim = ccdImage.Factory(ccdImage, amp.getRawBBox())
1309 if medians[index] != 0.0:
1310 sim *= median/medians[index]
1314 """Grow the saturation trails by an amount dependent on the width of the
1319 mask : `lsst.afw.image.Mask`
1320 Mask which will have the saturated areas grown.
1324 for i
in range(1, 6):
1325 extraGrowDict[i] = 0
1326 for i
in range(6, 8):
1327 extraGrowDict[i] = 1
1328 for i
in range(8, 10):
1329 extraGrowDict[i] = 3
1332 if extraGrowMax <= 0:
1335 saturatedBit = mask.getPlaneBitMask(
"SAT")
1337 xmin, ymin = mask.getBBox().getMin()
1338 width = mask.getWidth()
1340 thresh = afwDetection.Threshold(saturatedBit, afwDetection.Threshold.BITMASK)
1341 fpList = afwDetection.FootprintSet(mask, thresh).getFootprints()
1344 for s
in fp.getSpans():
1345 x0, x1 = s.getX0(), s.getX1()
1347 extraGrow = extraGrowDict.get(x1 - x0 + 1, extraGrowMax)
1350 x0 -= xmin + extraGrow
1351 x1 -= xmin - extraGrow
1358 mask.array[y, x0:x1+1] |= saturatedBit
1362 """Set all BAD areas of the chip to the average of the rest of the exposure
1366 exposure : `lsst.afw.image.Exposure`
1367 Exposure to mask. The exposure mask is modified.
1368 badStatistic : `str`, optional
1369 Statistic to use to generate the replacement value from the
1370 image data. Allowed values are 'MEDIAN' or 'MEANCLIP'.
1374 badPixelCount : scalar
1375 Number of bad pixels masked.
1376 badPixelValue : scalar
1377 Value substituted for bad pixels.
1382 Raised if `badStatistic` is not an allowed value.
1384 if badStatistic ==
"MEDIAN":
1385 statistic = afwMath.MEDIAN
1386 elif badStatistic ==
"MEANCLIP":
1387 statistic = afwMath.MEANCLIP
1389 raise RuntimeError(
"Impossible method %s of bad region correction" % badStatistic)
1391 mi = exposure.getMaskedImage()
1393 BAD = mask.getPlaneBitMask(
"BAD")
1394 INTRP = mask.getPlaneBitMask(
"INTRP")
1396 sctrl = afwMath.StatisticsControl()
1397 sctrl.setAndMask(BAD)
1398 value = afwMath.makeStatistics(mi, statistic, sctrl).getValue()
1400 maskArray = mask.getArray()
1401 imageArray = mi.getImage().getArray()
1402 badPixels = numpy.logical_and((maskArray & BAD) > 0, (maskArray & INTRP) == 0)
1403 imageArray[:] = numpy.where(badPixels, value, imageArray)
1405 return badPixels.sum(), value
1409 """Check to see if an exposure is in a filter specified by a list.
1411 The goal of this is to provide a unified filter checking interface
1412 for all filter dependent stages.
1416 exposure : `lsst.afw.image.Exposure`
1417 Exposure to examine.
1418 filterList : `list` [`str`]
1419 List of physical_filter names to check.
1420 log : `logging.Logger`
1421 Logger to handle messages.
1426 True if the exposure's filter is contained in the list.
1428 if len(filterList) == 0:
1430 thisFilter = exposure.getFilter()
1431 if thisFilter
is None:
1432 log.warning(
"No FilterLabel attached to this exposure!")
1436 if thisPhysicalFilter
in filterList:
1438 elif thisFilter.bandLabel
in filterList:
1440 log.warning(
"Physical filter (%s) should be used instead of band %s for filter configurations"
1441 " (%s)", thisPhysicalFilter, thisFilter.bandLabel, filterList)
1448 """Get the physical filter label associated with the given filterLabel.
1450 If ``filterLabel`` is `None` or there is no physicalLabel attribute
1451 associated with the given ``filterLabel``, the returned label will be
1456 filterLabel : `lsst.afw.image.FilterLabel`
1457 The `lsst.afw.image.FilterLabel` object from which to derive the
1458 physical filter label.
1459 log : `logging.Logger`
1460 Logger to handle messages.
1464 physicalFilter : `str`
1465 The value returned by the physicalLabel attribute of ``filterLabel`` if
1466 it exists, otherwise set to \"Unknown\".
1468 if filterLabel
is None:
1469 physicalFilter =
"Unknown"
1470 log.warning(
"filterLabel is None. Setting physicalFilter to \"Unknown\".")
1473 physicalFilter = filterLabel.physicalLabel
1474 except RuntimeError:
1475 log.warning(
"filterLabel has no physicalLabel attribute. Setting physicalFilter to \"Unknown\".")
1476 physicalFilter =
"Unknown"
1477 return physicalFilter
1481 """Count the number of pixels in a given mask plane.
1485 maskedIm : `~lsst.afw.image.MaskedImage`
1486 Masked image to examine.
1488 Name of the mask plane to examine.
1493 Number of pixels in the requested mask plane.
1495 maskBit = maskedIm.mask.getPlaneBitMask(maskPlane)
1496 nPix = numpy.where(numpy.bitwise_and(maskedIm.mask.array, maskBit))[0].flatten().size
1501 """Get the per-amplifier gains used for this exposure.
1505 exposure : `lsst.afw.image.Exposure`
1506 The exposure to find gains for.
1510 gains : `dict` [`str` `float`]
1511 Dictionary of gain values, keyed by amplifier name.
1512 Returns empty dict when detector is None.
1514 det = exposure.getDetector()
1518 metadata = exposure.getMetadata()
1521 ampName = amp.getName()
1523 if (key1 := f
"LSST ISR GAIN {ampName}")
in metadata:
1524 gains[ampName] = metadata[key1]
1525 elif (key2 := f
"LSST GAIN {ampName}")
in metadata:
1526 gains[ampName] = metadata[key2]
1528 gains[ampName] = amp.getGain()
1533 """Get the per-amplifier read noise used for this exposure.
1537 exposure : `lsst.afw.image.Exposure`
1538 The exposure to find read noise for.
1542 readnoises : `dict` [`str` `float`]
1543 Dictionary of read noise values, keyed by amplifier name.
1544 Returns empty dict when detector is None.
1546 det = exposure.getDetector()
1550 metadata = exposure.getMetadata()
1553 ampName = amp.getName()
1555 if (key1 := f
"LSST ISR READNOISE {ampName}")
in metadata:
1556 readnoises[ampName] = metadata[key1]
1557 elif (key2 := f
"LSST READNOISE {ampName}")
in metadata:
1558 readnoises[ampName] = metadata[key2]
1560 readnoises[ampName] = amp.getReadNoise()
1565 """Check if the unused pixels (pre-/over-scan pixels) have
1566 been trimmed from an exposure.
1570 exposure : `lsst.afw.image.Exposure`
1571 The exposure to check.
1576 True if the image is trimmed, else False.
1578 return exposure.getDetector().getBBox() == exposure.getBBox()
1582 """Check if the unused pixels (pre-/over-scan pixels) have
1583 been trimmed from an image
1587 image : `lsst.afw.image.Image`
1589 detector : `lsst.afw.cameraGeom.Detector`
1590 The detector associated with the image.
1595 True if the image is trimmed, else False.
1597 return detector.getBBox() == image.getBBox()
1601 doRaiseOnCalibMismatch,
1602 cameraKeywordsToCompare,
1608 """Compare header keywords to confirm camera states match.
1612 doRaiseOnCalibMismatch : `bool`
1613 Raise on calibration mismatch? Otherwise, log a warning.
1614 cameraKeywordsToCompare : `list` [`str`]
1615 List of camera keywords to compare.
1616 exposureMetadata : `lsst.daf.base.PropertyList`
1617 Header for the exposure being processed.
1618 calib : `lsst.afw.image.Exposure` or `lsst.ip.isr.IsrCalib`
1619 Calibration to be applied.
1621 Calib type for log message.
1622 log : `logging.Logger`, optional
1623 Logger to handle messages.
1626 calibMetadata = calib.metadata
1627 except AttributeError:
1630 log = log
if log
else logging.getLogger(__name__)
1632 missingKeywords = []
1633 for keyword
in cameraKeywordsToCompare:
1634 exposureValue = exposureMetadata.get(keyword,
None)
1635 if exposureValue
is None:
1636 log.debug(
"Sequencer keyword %s not found in exposure metadata.", keyword)
1639 calibValue = calibMetadata.get(keyword,
None)
1642 if calibValue
is None:
1643 missingKeywords.append(keyword)
1646 if exposureValue != calibValue:
1647 if doRaiseOnCalibMismatch:
1649 "Sequencer mismatch for %s [%s]: exposure: %s calib: %s",
1657 "Sequencer mismatch for %s [%s]: exposure: %s calib: %s",
1663 exposureMetadata[f
"ISR {calibName.upper()} SEQUENCER MISMATCH"] =
True
1667 "Calibration %s missing keywords %s, which were not checked.",
1669 ",".join(missingKeywords),
1674 """ Copy array over 4 quadrants prior to convolution.
1678 inputarray : `numpy.array`
1679 Input array to symmetrize.
1683 aSym : `numpy.array`
1686 targetShape = list(inputArray.shape)
1687 r1, r2 = inputArray.shape[-1], inputArray.shape[-2]
1688 targetShape[-1] = 2*r1-1
1689 targetShape[-2] = 2*r2-1
1690 aSym = numpy.ndarray(tuple(targetShape))
1691 aSym[..., r2-1:, r1-1:] = inputArray
1692 aSym[..., r2-1:, r1-1::-1] = inputArray
1693 aSym[..., r2-1::-1, r1-1::-1] = inputArray
1694 aSym[..., r2-1::-1, r1-1:] = inputArray
gainContext(exp, image, apply, gains=None, invert=False, isTrimmed=True)
makeThresholdMask(maskedImage, threshold, growFootprints=1, maskName='SAT')
maskITLDip(exposure, detectorConfig, maskPlaneNames=["SUSPECT", "ITL_DIP"], log=None)
_applyMaskITLEdgeBleed(ccdExposure, xCore, satLevel, widthSat, itlEdgeBleedThreshold=5000., itlEdgeBleedModelConstant=0.03, saturatedMaskName="SAT", log=None)
illuminationCorrection(maskedImage, illumMaskedImage, illumScale, trimToFit=True)
setBadRegions(exposure, badStatistic="MEDIAN")
isTrimmedImage(image, detector)
getExposureReadNoises(exposure)
maskE2VEdgeBleed(exposure, e2vEdgeBleedSatMinArea=10000, e2vEdgeBleedSatMaxArea=100000, e2vEdgeBleedYMax=350, saturatedMaskName="SAT", log=None)
applyGains(exposure, normalizeGains=False, ptcGains=None, isTrimmed=True)
trimToMatchCalibBBox(rawMaskedImage, calibMaskedImage)
updateVariance(maskedImage, gain, readNoise, replace=True)
darkCorrection(maskedImage, darkMaskedImage, expScale, darkScale, invert=False, trimToFit=False, imageOnly=False)
interpolateFromMask(maskedImage, fwhm, growSaturatedFootprints=1, maskNameList=['SAT'], fallbackValue=None, useLegacyInterp=True)
maskITLSatSag(ccdExposure, fpCore, saturatedMaskName="SAT")
isTrimmedExposure(exposure)
growMasks(mask, radius=0, maskNameList=['BAD'], maskValue="BAD")
biasCorrection(maskedImage, biasMaskedImage, trimToFit=False, imageOnly=False)
checkFilter(exposure, filterList, log)
transposeMaskedImage(maskedImage)
maskDECamEdgeBleed(exposure, satMinArea=10000, approachRows=20, nSigma=5.0, nRowsCheck=20, nRowsCheckShort=5, minUsablePixelsPerRow=30, minLowFraction=0.03, minLowFractionExtent=0.01, minBlockedRows=5, marginFraction=0.125, saturatedMaskName="SAT", log=None)
compareCameraKeywords(doRaiseOnCalibMismatch, cameraKeywordsToCompare, exposureMetadata, calib, calibName, log=None)
interpolateDefectList(maskedImage, defectList, fwhm, fallbackValue=None, maskNameList=None, useLegacyInterp=True)
countMaskedPixels(maskedIm, maskPlane)
getExposureGains(exposure)
getPhysicalFilter(filterLabel, log)
saturationCorrection(maskedImage, saturation, fwhm, growFootprints=1, interpolate=True, maskName='SAT', fallbackValue=None, useLegacyInterp=True)
flatCorrection(maskedImage, flatMaskedImage, scalingType, userScale=1.0, invert=False, trimToFit=False, imageOnly=False)
widenSaturationTrails(mask)
attachTransmissionCurve(exposure, opticsTransmission=None, filterTransmission=None, sensorTransmission=None, atmosphereTransmission=None)
maskITLEdgeBleed(ccdExposure, badAmpDict, fpCore, itlEdgeBleedSatMinArea=10000, itlEdgeBleedSatMaxArea=100000, itlEdgeBleedThreshold=5000., itlEdgeBleedModelConstant=0.02, saturatedMaskName="SAT", log=None)