34 from contextlib
import contextmanager
36 from .overscan
import OverscanCorrectionTask, OverscanCorrectionTaskConfig
37 from .defects
import Defects
41 """Make a double Gaussian PSF.
46 FWHM of double Gaussian smoothing kernel.
50 psf : `lsst.meas.algorithms.DoubleGaussianPsf`
51 The created smoothing kernel.
53 ksize = 4*int(fwhm) + 1
54 return measAlg.DoubleGaussianPsf(ksize, ksize, fwhm/(2*math.sqrt(2*math.log(2))))
58 """Make a transposed copy of a masked image.
62 maskedImage : `lsst.afw.image.MaskedImage`
67 transposed : `lsst.afw.image.MaskedImage`
68 The transposed copy of the input image.
70 transposed = maskedImage.Factory(
lsst.geom.Extent2I(maskedImage.getHeight(), maskedImage.getWidth()))
71 transposed.getImage().getArray()[:] = maskedImage.getImage().getArray().T
72 transposed.getMask().getArray()[:] = maskedImage.getMask().getArray().T
73 transposed.getVariance().getArray()[:] = maskedImage.getVariance().getArray().T
78 """Interpolate over defects specified in a defect list.
82 maskedImage : `lsst.afw.image.MaskedImage`
84 defectList : `lsst.meas.algorithms.Defects`
85 List of defects to interpolate over.
87 FWHM of double Gaussian smoothing kernel.
88 fallbackValue : scalar, optional
89 Fallback value if an interpolated value cannot be determined.
90 If None, then the clipped mean of the image is used.
93 if fallbackValue
is None:
95 if 'INTRP' not in maskedImage.getMask().getMaskPlaneDict():
96 maskedImage.getMask().addMaskPlane(
'INTRP')
97 measAlg.interpolateOverDefects(maskedImage, psf, defectList, fallbackValue,
True)
102 """Mask pixels based on threshold detection.
106 maskedImage : `lsst.afw.image.MaskedImage`
107 Image to process. Only the mask plane is updated.
110 growFootprints : scalar, optional
111 Number of pixels to grow footprints of detected regions.
112 maskName : str, optional
113 Mask plane name, or list of names to convert
117 defectList : `lsst.meas.algorithms.Defects`
118 Defect list constructed from pixels above the threshold.
121 thresh = afwDetection.Threshold(threshold)
122 fs = afwDetection.FootprintSet(maskedImage, thresh)
124 if growFootprints > 0:
125 fs = afwDetection.FootprintSet(fs, rGrow=growFootprints, isotropic=
False)
126 fpList = fs.getFootprints()
129 mask = maskedImage.getMask()
130 bitmask = mask.getPlaneBitMask(maskName)
131 afwDetection.setMaskFromFootprintList(mask, fpList, bitmask)
133 return Defects.fromFootprintList(fpList)
136 def growMasks(mask, radius=0, maskNameList=['BAD'], maskValue="BAD"):
137 """Grow a mask by an amount and add to the requested plane.
141 mask : `lsst.afw.image.Mask`
142 Mask image to process.
144 Amount to grow the mask.
145 maskNameList : `str` or `list` [`str`]
146 Mask names that should be grown.
148 Mask plane to assign the newly masked pixels to.
151 thresh = afwDetection.Threshold(mask.getPlaneBitMask(maskNameList), afwDetection.Threshold.BITMASK)
152 fpSet = afwDetection.FootprintSet(mask, thresh)
153 fpSet = afwDetection.FootprintSet(fpSet, rGrow=radius, isotropic=
False)
154 fpSet.setMask(mask, maskValue)
158 maskNameList=['SAT'], fallbackValue=None):
159 """Interpolate over defects identified by a particular set of mask planes.
163 maskedImage : `lsst.afw.image.MaskedImage`
166 FWHM of double Gaussian smoothing kernel.
167 growSaturatedFootprints : scalar, optional
168 Number of pixels to grow footprints for saturated pixels.
169 maskNameList : `List` of `str`, optional
171 fallbackValue : scalar, optional
172 Value of last resort for interpolation.
174 mask = maskedImage.getMask()
176 if growSaturatedFootprints > 0
and "SAT" in maskNameList:
179 growMasks(mask, radius=growSaturatedFootprints, maskNameList=[
'SAT'], maskValue=
"SAT")
181 thresh = afwDetection.Threshold(mask.getPlaneBitMask(maskNameList), afwDetection.Threshold.BITMASK)
182 fpSet = afwDetection.FootprintSet(mask, thresh)
183 defectList = Defects.fromFootprintList(fpSet.getFootprints())
192 """Mark saturated pixels and optionally interpolate over them
196 maskedImage : `lsst.afw.image.MaskedImage`
199 Saturation level used as the detection threshold.
201 FWHM of double Gaussian smoothing kernel.
202 growFootprints : scalar, optional
203 Number of pixels to grow footprints of detected regions.
204 interpolate : Bool, optional
205 If True, saturated pixels are interpolated over.
206 maskName : str, optional
208 fallbackValue : scalar, optional
209 Value of last resort for interpolation.
212 maskedImage=maskedImage,
213 threshold=saturation,
214 growFootprints=growFootprints,
224 """Compute number of edge trim pixels to match the calibration data.
226 Use the dimension difference between the raw exposure and the
227 calibration exposure to compute the edge trim pixels. This trim
228 is applied symmetrically, with the same number of pixels masked on
233 rawMaskedImage : `lsst.afw.image.MaskedImage`
235 calibMaskedImage : `lsst.afw.image.MaskedImage`
236 Calibration image to draw new bounding box from.
240 replacementMaskedImage : `lsst.afw.image.MaskedImage`
241 ``rawMaskedImage`` trimmed to the appropriate size
245 Rasied if ``rawMaskedImage`` cannot be symmetrically trimmed to
246 match ``calibMaskedImage``.
248 nx, ny = rawMaskedImage.getBBox().getDimensions() - calibMaskedImage.getBBox().getDimensions()
250 raise RuntimeError(
"Raw and calib maskedImages are trimmed differently in X and Y.")
252 raise RuntimeError(
"Calibration maskedImage is trimmed unevenly in X.")
254 raise RuntimeError(
"Calibration maskedImage is larger than raw data.")
258 replacementMaskedImage = rawMaskedImage[nEdge:-nEdge, nEdge:-nEdge, afwImage.LOCAL]
259 SourceDetectionTask.setEdgeBits(
261 replacementMaskedImage.getBBox(),
262 rawMaskedImage.getMask().getPlaneBitMask(
"EDGE")
265 replacementMaskedImage = rawMaskedImage
267 return replacementMaskedImage
271 """Apply bias correction in place.
275 maskedImage : `lsst.afw.image.MaskedImage`
276 Image to process. The image is modified by this method.
277 biasMaskedImage : `lsst.afw.image.MaskedImage`
278 Bias image of the same size as ``maskedImage``
279 trimToFit : `Bool`, optional
280 If True, raw data is symmetrically trimmed to match
286 Raised if ``maskedImage`` and ``biasMaskedImage`` do not have
293 if maskedImage.getBBox(afwImage.LOCAL) != biasMaskedImage.getBBox(afwImage.LOCAL):
294 raise RuntimeError(
"maskedImage bbox %s != biasMaskedImage bbox %s" %
295 (maskedImage.getBBox(afwImage.LOCAL), biasMaskedImage.getBBox(afwImage.LOCAL)))
296 maskedImage -= biasMaskedImage
299 def darkCorrection(maskedImage, darkMaskedImage, expScale, darkScale, invert=False, trimToFit=False):
300 """Apply dark correction in place.
304 maskedImage : `lsst.afw.image.MaskedImage`
305 Image to process. The image is modified by this method.
306 darkMaskedImage : `lsst.afw.image.MaskedImage`
307 Dark image of the same size as ``maskedImage``.
309 Dark exposure time for ``maskedImage``.
311 Dark exposure time for ``darkMaskedImage``.
312 invert : `Bool`, optional
313 If True, re-add the dark to an already corrected image.
314 trimToFit : `Bool`, optional
315 If True, raw data is symmetrically trimmed to match
321 Raised if ``maskedImage`` and ``darkMaskedImage`` do not have
326 The dark correction is applied by calculating:
327 maskedImage -= dark * expScaling / darkScaling
332 if maskedImage.getBBox(afwImage.LOCAL) != darkMaskedImage.getBBox(afwImage.LOCAL):
333 raise RuntimeError(
"maskedImage bbox %s != darkMaskedImage bbox %s" %
334 (maskedImage.getBBox(afwImage.LOCAL), darkMaskedImage.getBBox(afwImage.LOCAL)))
336 scale = expScale / darkScale
338 maskedImage.scaledMinus(scale, darkMaskedImage)
340 maskedImage.scaledPlus(scale, darkMaskedImage)
344 """Set the variance plane based on the image plane.
348 maskedImage : `lsst.afw.image.MaskedImage`
349 Image to process. The variance plane is modified.
351 The amplifier gain in electrons/ADU.
353 The amplifier read nmoise in ADU/pixel.
355 var = maskedImage.getVariance()
356 var[:] = maskedImage.getImage()
361 def flatCorrection(maskedImage, flatMaskedImage, scalingType, userScale=1.0, invert=False, trimToFit=False):
362 """Apply flat correction in place.
366 maskedImage : `lsst.afw.image.MaskedImage`
367 Image to process. The image is modified.
368 flatMaskedImage : `lsst.afw.image.MaskedImage`
369 Flat image of the same size as ``maskedImage``
371 Flat scale computation method. Allowed values are 'MEAN',
373 userScale : scalar, optional
374 Scale to use if ``scalingType``='USER'.
375 invert : `Bool`, optional
376 If True, unflatten an already flattened image.
377 trimToFit : `Bool`, optional
378 If True, raw data is symmetrically trimmed to match
384 Raised if ``maskedImage`` and ``flatMaskedImage`` do not have
385 the same size or if ``scalingType`` is not an allowed value.
390 if maskedImage.getBBox(afwImage.LOCAL) != flatMaskedImage.getBBox(afwImage.LOCAL):
391 raise RuntimeError(
"maskedImage bbox %s != flatMaskedImage bbox %s" %
392 (maskedImage.getBBox(afwImage.LOCAL), flatMaskedImage.getBBox(afwImage.LOCAL)))
397 if scalingType
in (
'MEAN',
'MEDIAN'):
400 elif scalingType ==
'USER':
401 flatScale = userScale
403 raise RuntimeError(
'%s : %s not implemented' % (
"flatCorrection", scalingType))
406 maskedImage.scaledDivides(1.0/flatScale, flatMaskedImage)
408 maskedImage.scaledMultiplies(1.0/flatScale, flatMaskedImage)
412 """Apply illumination correction in place.
416 maskedImage : `lsst.afw.image.MaskedImage`
417 Image to process. The image is modified.
418 illumMaskedImage : `lsst.afw.image.MaskedImage`
419 Illumination correction image of the same size as ``maskedImage``.
421 Scale factor for the illumination correction.
422 trimToFit : `Bool`, optional
423 If True, raw data is symmetrically trimmed to match
429 Raised if ``maskedImage`` and ``illumMaskedImage`` do not have
435 if maskedImage.getBBox(afwImage.LOCAL) != illumMaskedImage.getBBox(afwImage.LOCAL):
436 raise RuntimeError(
"maskedImage bbox %s != illumMaskedImage bbox %s" %
437 (maskedImage.getBBox(afwImage.LOCAL), illumMaskedImage.getBBox(afwImage.LOCAL)))
439 maskedImage.scaledDivides(1.0/illumScale, illumMaskedImage)
443 statControl=None, overscanIsInt=True):
444 """Apply overscan correction in place.
448 ampMaskedImage : `lsst.afw.image.MaskedImage`
449 Image of amplifier to correct; modified.
450 overscanImage : `lsst.afw.image.Image` or `lsst.afw.image.MaskedImage`
451 Image of overscan; modified.
453 Type of fit for overscan correction. May be one of:
455 - ``MEAN``: use mean of overscan.
456 - ``MEANCLIP``: use clipped mean of overscan.
457 - ``MEDIAN``: use median of overscan.
458 - ``MEDIAN_PER_ROW``: use median per row of overscan.
459 - ``POLY``: fit with ordinary polynomial.
460 - ``CHEB``: fit with Chebyshev polynomial.
461 - ``LEG``: fit with Legendre polynomial.
462 - ``NATURAL_SPLINE``: fit with natural spline.
463 - ``CUBIC_SPLINE``: fit with cubic spline.
464 - ``AKIMA_SPLINE``: fit with Akima spline.
467 Polynomial order or number of spline knots; ignored unless
468 ``fitType`` indicates a polynomial or spline.
469 statControl : `lsst.afw.math.StatisticsControl`
470 Statistics control object. In particular, we pay attention to numSigmaClip
471 overscanIsInt : `bool`
472 Treat the overscan region as consisting of integers, even if it's been
473 converted to float. E.g. handle ties properly.
477 result : `lsst.pipe.base.Struct`
478 Result struct with components:
480 - ``imageFit``: Value(s) removed from image (scalar or
481 `lsst.afw.image.Image`)
482 - ``overscanFit``: Value(s) removed from overscan (scalar or
483 `lsst.afw.image.Image`)
484 - ``overscanImage``: Overscan corrected overscan region
485 (`lsst.afw.image.Image`)
489 Raised if ``fitType`` is not an allowed value.
493 The ``ampMaskedImage`` and ``overscanImage`` are modified, with the fit
494 subtracted. Note that the ``overscanImage`` should not be a subimage of
495 the ``ampMaskedImage``, to avoid being subtracted twice.
497 Debug plots are available for the SPLINE fitTypes by setting the
498 `debug.display` for `name` == "lsst.ip.isr.isrFunctions". These
499 plots show the scatter plot of the overscan data (collapsed along
500 the perpendicular dimension) as a function of position on the CCD
501 (normalized between +/-1).
503 ampImage = ampMaskedImage.getImage()
507 config.fitType = fitType
511 config.numSigmaClip = collapseRej
513 config.overscanIsInt =
True
516 return overscanTask.run(ampImage, overscanImage)
520 """Apply brighter fatter correction in place for the image.
524 exposure : `lsst.afw.image.Exposure`
525 Exposure to have brighter-fatter correction applied. Modified
527 kernel : `numpy.ndarray`
528 Brighter-fatter kernel to apply.
530 Number of correction iterations to run.
532 Convergence threshold in terms of the sum of absolute
533 deviations between an iteration and the previous one.
535 If True, then the exposure values are scaled by the gain prior
537 gains : `dict` [`str`, `float`]
538 A dictionary, keyed by amplifier name, of the gains to use.
539 If gains is None, the nominal gains in the amplifier object are used.
544 Final difference between iterations achieved in correction.
546 Number of iterations used to calculate correction.
550 This correction takes a kernel that has been derived from flat
551 field images to redistribute the charge. The gradient of the
552 kernel is the deflection field due to the accumulated charge.
554 Given the original image I(x) and the kernel K(x) we can compute
555 the corrected image Ic(x) using the following equation:
557 Ic(x) = I(x) + 0.5*d/dx(I(x)*d/dx(int( dy*K(x-y)*I(y))))
559 To evaluate the derivative term we expand it as follows:
561 0.5 * ( d/dx(I(x))*d/dx(int(dy*K(x-y)*I(y))) + I(x)*d^2/dx^2(int(dy* K(x-y)*I(y))) )
563 Because we use the measured counts instead of the incident counts
564 we apply the correction iteratively to reconstruct the original
565 counts and the correction. We stop iterating when the summed
566 difference between the current corrected image and the one from
567 the previous iteration is below the threshold. We do not require
568 convergence because the number of iterations is too large a
569 computational cost. How we define the threshold still needs to be
570 evaluated, the current default was shown to work reasonably well
571 on a small set of images. For more information on the method see
572 DocuShare Document-19407.
574 The edges as defined by the kernel are not corrected because they
575 have spurious values due to the convolution.
577 image = exposure.getMaskedImage().getImage()
580 with gainContext(exposure, image, applyGain, gains):
582 kLx = numpy.shape(kernel)[0]
583 kLy = numpy.shape(kernel)[1]
584 kernelImage = afwImage.ImageD(kLx, kLy)
585 kernelImage.getArray()[:, :] = kernel
586 tempImage = image.clone()
588 nanIndex = numpy.isnan(tempImage.getArray())
589 tempImage.getArray()[nanIndex] = 0.
591 outImage = afwImage.ImageF(image.getDimensions())
592 corr = numpy.zeros_like(image.getArray())
593 prev_image = numpy.zeros_like(image.getArray())
605 for iteration
in range(maxIter):
608 tmpArray = tempImage.getArray()
609 outArray = outImage.getArray()
611 with numpy.errstate(invalid=
"ignore", over=
"ignore"):
613 gradTmp = numpy.gradient(tmpArray[startY:endY, startX:endX])
614 gradOut = numpy.gradient(outArray[startY:endY, startX:endX])
615 first = (gradTmp[0]*gradOut[0] + gradTmp[1]*gradOut[1])[1:-1, 1:-1]
618 diffOut20 = numpy.diff(outArray, 2, 0)[startY:endY, startX + 1:endX - 1]
619 diffOut21 = numpy.diff(outArray, 2, 1)[startY + 1:endY - 1, startX:endX]
620 second = tmpArray[startY + 1:endY - 1, startX + 1:endX - 1]*(diffOut20 + diffOut21)
622 corr[startY + 1:endY - 1, startX + 1:endX - 1] = 0.5*(first + second)
624 tmpArray[:, :] = image.getArray()[:, :]
625 tmpArray[nanIndex] = 0.
626 tmpArray[startY:endY, startX:endX] += corr[startY:endY, startX:endX]
629 diff = numpy.sum(numpy.abs(prev_image - tmpArray))
633 prev_image[:, :] = tmpArray[:, :]
635 image.getArray()[startY + 1:endY - 1, startX + 1:endX - 1] += \
636 corr[startY + 1:endY - 1, startX + 1:endX - 1]
638 return diff, iteration
643 """Context manager that applies and removes gain.
647 exp : `lsst.afw.image.Exposure`
648 Exposure to apply/remove gain.
649 image : `lsst.afw.image.Image`
650 Image to apply/remove gain.
652 If True, apply and remove the amplifier gain.
653 gains : `dict` [`str`, `float`]
654 A dictionary, keyed by amplifier name, of the gains to use.
655 If gains is None, the nominal gains in the amplifier object are used.
659 exp : `lsst.afw.image.Exposure`
660 Exposure with the gain applied.
664 if gains
and apply
is True:
665 ampNames = [amp.getName()
for amp
in exp.getDetector()]
666 for ampName
in ampNames:
667 if ampName
not in gains.keys():
668 raise RuntimeError(f
"Gains provided to gain context, but no entry found for amp {ampName}")
671 ccd = exp.getDetector()
673 sim = image.Factory(image, amp.getBBox())
675 gain = gains[amp.getName()]
684 ccd = exp.getDetector()
686 sim = image.Factory(image, amp.getBBox())
688 gain = gains[amp.getName()]
695 sensorTransmission=None, atmosphereTransmission=None):
696 """Attach a TransmissionCurve to an Exposure, given separate curves for
697 different components.
701 exposure : `lsst.afw.image.Exposure`
702 Exposure object to modify by attaching the product of all given
703 ``TransmissionCurves`` in post-assembly trimmed detector coordinates.
704 Must have a valid ``Detector`` attached that matches the detector
705 associated with sensorTransmission.
706 opticsTransmission : `lsst.afw.image.TransmissionCurve`
707 A ``TransmissionCurve`` that represents the throughput of the optics,
708 to be evaluated in focal-plane coordinates.
709 filterTransmission : `lsst.afw.image.TransmissionCurve`
710 A ``TransmissionCurve`` that represents the throughput of the filter
711 itself, to be evaluated in focal-plane coordinates.
712 sensorTransmission : `lsst.afw.image.TransmissionCurve`
713 A ``TransmissionCurve`` that represents the throughput of the sensor
714 itself, to be evaluated in post-assembly trimmed detector coordinates.
715 atmosphereTransmission : `lsst.afw.image.TransmissionCurve`
716 A ``TransmissionCurve`` that represents the throughput of the
717 atmosphere, assumed to be spatially constant.
721 combined : `lsst.afw.image.TransmissionCurve`
722 The TransmissionCurve attached to the exposure.
726 All ``TransmissionCurve`` arguments are optional; if none are provided, the
727 attached ``TransmissionCurve`` will have unit transmission everywhere.
729 combined = afwImage.TransmissionCurve.makeIdentity()
730 if atmosphereTransmission
is not None:
731 combined *= atmosphereTransmission
732 if opticsTransmission
is not None:
733 combined *= opticsTransmission
734 if filterTransmission
is not None:
735 combined *= filterTransmission
736 detector = exposure.getDetector()
737 fpToPix = detector.getTransform(fromSys=camGeom.FOCAL_PLANE,
738 toSys=camGeom.PIXELS)
739 combined = combined.transformedBy(fpToPix)
740 if sensorTransmission
is not None:
741 combined *= sensorTransmission
742 exposure.getInfo().setTransmissionCurve(combined)
746 def applyGains(exposure, normalizeGains=False, ptcGains=None):
747 """Scale an exposure by the amplifier gains.
751 exposure : `lsst.afw.image.Exposure`
752 Exposure to process. The image is modified.
753 normalizeGains : `Bool`, optional
754 If True, then amplifiers are scaled to force the median of
755 each amplifier to equal the median of those medians.
756 ptcGains : `dict`[`str`], optional
757 Dictionary keyed by amp name containing the PTC gains.
759 ccd = exposure.getDetector()
760 ccdImage = exposure.getMaskedImage()
764 sim = ccdImage.Factory(ccdImage, amp.getBBox())
766 sim *= ptcGains[amp.getName()]
771 medians.append(numpy.median(sim.getImage().getArray()))
774 median = numpy.median(numpy.array(medians))
775 for index, amp
in enumerate(ccd):
776 sim = ccdImage.Factory(ccdImage, amp.getBBox())
777 if medians[index] != 0.0:
778 sim *= median/medians[index]
782 """Grow the saturation trails by an amount dependent on the width of the trail.
786 mask : `lsst.afw.image.Mask`
787 Mask which will have the saturated areas grown.
791 for i
in range(1, 6):
793 for i
in range(6, 8):
795 for i
in range(8, 10):
799 if extraGrowMax <= 0:
802 saturatedBit = mask.getPlaneBitMask(
"SAT")
804 xmin, ymin = mask.getBBox().getMin()
805 width = mask.getWidth()
807 thresh = afwDetection.Threshold(saturatedBit, afwDetection.Threshold.BITMASK)
808 fpList = afwDetection.FootprintSet(mask, thresh).getFootprints()
811 for s
in fp.getSpans():
812 x0, x1 = s.getX0(), s.getX1()
814 extraGrow = extraGrowDict.get(x1 - x0 + 1, extraGrowMax)
817 x0 -= xmin + extraGrow
818 x1 -= xmin - extraGrow
825 mask.array[y, x0:x1+1] |= saturatedBit
829 """Set all BAD areas of the chip to the average of the rest of the exposure
833 exposure : `lsst.afw.image.Exposure`
834 Exposure to mask. The exposure mask is modified.
835 badStatistic : `str`, optional
836 Statistic to use to generate the replacement value from the
837 image data. Allowed values are 'MEDIAN' or 'MEANCLIP'.
841 badPixelCount : scalar
842 Number of bad pixels masked.
843 badPixelValue : scalar
844 Value substituted for bad pixels.
849 Raised if `badStatistic` is not an allowed value.
851 if badStatistic ==
"MEDIAN":
852 statistic = afwMath.MEDIAN
853 elif badStatistic ==
"MEANCLIP":
854 statistic = afwMath.MEANCLIP
856 raise RuntimeError(
"Impossible method %s of bad region correction" % badStatistic)
858 mi = exposure.getMaskedImage()
860 BAD = mask.getPlaneBitMask(
"BAD")
861 INTRP = mask.getPlaneBitMask(
"INTRP")
864 sctrl.setAndMask(BAD)
867 maskArray = mask.getArray()
868 imageArray = mi.getImage().getArray()
869 badPixels = numpy.logical_and((maskArray & BAD) > 0, (maskArray & INTRP) == 0)
870 imageArray[:] = numpy.where(badPixels, value, imageArray)
872 return badPixels.sum(), value
876 """Check to see if an exposure is in a filter specified by a list.
878 The goal of this is to provide a unified filter checking interface
879 for all filter dependent stages.
883 exposure : `lsst.afw.image.Exposure`
885 filterList : `list` [`str`]
886 List of physical_filter names to check.
887 log : `logging.Logger`
888 Logger to handle messages.
893 True if the exposure's filter is contained in the list.
895 thisFilter = exposure.getFilterLabel()
896 if thisFilter
is None:
897 log.warning(
"No FilterLabel attached to this exposure!")
901 if thisPhysicalFilter
in filterList:
903 elif thisFilter.bandLabel
in filterList:
905 log.warning(
"Physical filter (%s) should be used instead of band %s for filter configurations"
906 " (%s)", thisPhysicalFilter, thisFilter.bandLabel, filterList)
913 """Get the physical filter label associated with the given filterLabel.
915 If ``filterLabel`` is `None` or there is no physicalLabel attribute
916 associated with the given ``filterLabel``, the returned label will be
921 filterLabel : `lsst.afw.image.FilterLabel`
922 The `lsst.afw.image.FilterLabel` object from which to derive the
923 physical filter label.
924 log : `logging.Logger`
925 Logger to handle messages.
929 physicalFilter : `str`
930 The value returned by the physicalLabel attribute of ``filterLabel`` if
931 it exists, otherwise set to \"Unknown\".
933 if filterLabel
is None:
934 physicalFilter =
"Unknown"
935 log.warning(
"filterLabel is None. Setting physicalFilter to \"Unknown\".")
938 physicalFilter = filterLabel.physicalLabel
940 log.warning(
"filterLabel has no physicalLabel attribute. Setting physicalFilter to \"Unknown\".")
941 physicalFilter =
"Unknown"
942 return physicalFilter
Parameters to control convolution.
A kernel created from an Image.
Pass parameters to a Statistics object.
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects.
Statistics makeStatistics(lsst::afw::image::Image< Pixel > const &img, lsst::afw::image::Mask< image::MaskPixel > const &msk, int const flags, StatisticsControl const &sctrl=StatisticsControl())
Handle a watered-down front-end to the constructor (no variance)
void convolve(OutImageT &convolvedImage, InImageT const &inImage, KernelT const &kernel, ConvolutionControl const &convolutionControl=ConvolutionControl())
Convolve an Image or MaskedImage with a Kernel, setting pixels of an existing output image.
Property stringToStatisticsProperty(std::string const property)
Conversion function to switch a string to a Property (see Statistics.h)
def biasCorrection(maskedImage, biasMaskedImage, trimToFit=False)
def growMasks(mask, radius=0, maskNameList=['BAD'], maskValue="BAD")
def darkCorrection(maskedImage, darkMaskedImage, expScale, darkScale, invert=False, trimToFit=False)
def saturationCorrection(maskedImage, saturation, fwhm, growFootprints=1, interpolate=True, maskName='SAT', fallbackValue=None)
def interpolateDefectList(maskedImage, defectList, fwhm, fallbackValue=None)
def illuminationCorrection(maskedImage, illumMaskedImage, illumScale, trimToFit=True)
def checkFilter(exposure, filterList, log)
def gainContext(exp, image, apply, gains=None)
def brighterFatterCorrection(exposure, kernel, maxIter, threshold, applyGain, gains=None)
def makeThresholdMask(maskedImage, threshold, growFootprints=1, maskName='SAT')
def setBadRegions(exposure, badStatistic="MEDIAN")
def applyGains(exposure, normalizeGains=False, ptcGains=None)
def getPhysicalFilter(filterLabel, log)
def trimToMatchCalibBBox(rawMaskedImage, calibMaskedImage)
def updateVariance(maskedImage, gain, readNoise)
def overscanCorrection(ampMaskedImage, overscanImage, fitType='MEDIAN', order=1, collapseRej=3.0, statControl=None, overscanIsInt=True)
def interpolateFromMask(maskedImage, fwhm, growSaturatedFootprints=1, maskNameList=['SAT'], fallbackValue=None)
def transposeMaskedImage(maskedImage)
def flatCorrection(maskedImage, flatMaskedImage, scalingType, userScale=1.0, invert=False, trimToFit=False)
def attachTransmissionCurve(exposure, opticsTransmission=None, filterTransmission=None, sensorTransmission=None, atmosphereTransmission=None)
def widenSaturationTrails(mask)
Fit spatial kernel using approximate fluxes for candidates, and solving a linear system of equations.