24 "FocalPlaneBackground",
25 "FocalPlaneBackgroundConfig",
28 "SkyMeasurementConfig",
37from scipy.ndimage
import gaussian_filter
40import lsst.afw.image
as afwImage
47from lsst.pex.config import Config, Field, ListField, ChoiceField, ConfigField, RangeField, ConfigurableField
52 """Measure a robust mean of an array
56 array : `numpy.ndarray`
57 Array for which to measure the mean.
59 k-sigma rejection threshold.
64 Robust mean of `array`.
66 q1, median, q3 = numpy.percentile(array, [25.0, 50.0, 100.0])
67 good = numpy.abs(array - median) < rej*0.74*(q3 - q1)
68 return array[good].mean()
72 """Configuration for background measurement"""
73 statistic =
ChoiceField(dtype=str, default=
"MEANCLIP", doc=
"type of statistic to use for grid points",
74 allowed={
"MEANCLIP":
"clipped mean",
75 "MEAN":
"unclipped mean",
77 xBinSize =
RangeField(dtype=int, default=32, min=1, doc=
"Superpixel size in x")
78 yBinSize =
RangeField(dtype=int, default=32, min=1, doc=
"Superpixel size in y")
79 algorithm =
ChoiceField(dtype=str, default=
"NATURAL_SPLINE", optional=
True,
80 doc=
"How to interpolate the background values. "
81 "This maps to an enum; see afw::math::Background",
83 "CONSTANT":
"Use a single constant value",
84 "LINEAR":
"Use linear interpolation",
85 "NATURAL_SPLINE":
"cubic spline with zero second derivative at endpoints",
86 "AKIMA_SPLINE":
"higher-level nonlinear spline that is more robust"
88 "NONE":
"No background estimation is to be attempted",
90 mask =
ListField(dtype=str, default=[
"SAT",
"BAD",
"EDGE",
"DETECTED",
"DETECTED_NEGATIVE",
"NO_DATA"],
91 doc=
"Names of mask planes to ignore while estimating the background")
95 """Parameters controlling the measurement of sky statistics"""
96 statistic =
ChoiceField(dtype=str, default=
"MEANCLIP", doc=
"type of statistic to use for grid points",
97 allowed={
"MEANCLIP":
"clipped mean",
98 "MEAN":
"unclipped mean",
100 clip =
Field(doc=
"Clipping threshold for background", dtype=float, default=3.0)
101 nIter =
Field(doc=
"Clipping iterations for background", dtype=int, default=3)
102 mask =
ListField(doc=
"Mask planes to reject", dtype=str,
103 default=[
"SAT",
"DETECTED",
"DETECTED_NEGATIVE",
"BAD",
"NO_DATA"])
107 """Configuration for SkyMeasurementTask"""
108 skyIter =
Field(dtype=int, default=3, doc=
"k-sigma rejection iterations for sky scale")
109 skyRej =
Field(dtype=float, default=3.0, doc=
"k-sigma rejection threshold for sky scale")
110 background =
ConfigField(dtype=BackgroundConfig, doc=
"Background measurement")
111 xNumSamples =
Field(dtype=int, default=4, doc=
"Number of samples in x for scaling sky frame")
112 yNumSamples =
Field(dtype=int, default=4, doc=
"Number of samples in y for scaling sky frame")
113 stats =
ConfigField(dtype=SkyStatsConfig, doc=
"Measurement of sky statistics in the samples")
117 """Task for creating, persisting and using sky frames
119 A sky frame is like a fringe frame (the sum of many exposures of the night sky,
120 combined with rejection to remove astrophysical objects) except the structure
121 is on larger scales, and hence we bin the images and represent them as a
122 background model (a `lsst.afw.math.BackgroundMI`). The sky frame represents
123 the dominant response of the camera to the sky background.
125 ConfigClass = SkyMeasurementConfig
129 """Convert an exposure to background model
131 Calibs need to be persisted as an Exposure, so we need to convert
132 the persisted Exposure to a background model.
136 bgExp : `lsst.afw.image.Exposure`
137 Background model in Exposure format.
141 bg : `lsst.afw.math.BackgroundList`
144 header = bgExp.getMetadata()
145 xMin = header.getScalar(
"BOX.MINX")
146 yMin = header.getScalar(
"BOX.MINY")
147 xMax = header.getScalar(
"BOX.MAXX")
148 yMax = header.getScalar(
"BOX.MAXY")
149 algorithm = header.getScalar(
"ALGORITHM")
155 afwMath.ApproximateControl.UNKNOWN,
159 """Convert a background model to an exposure
161 Calibs need to be persisted as an Exposure, so we need to convert
162 the background model to an Exposure.
166 statsImage : `lsst.afw.image.MaskedImageF`
167 Background model's statistics image.
168 bbox : `lsst.geom.Box2I`
169 Bounding box for image.
173 exp : `lsst.afw.image.Exposure`
174 Background model in Exposure format.
177 header = exp.getMetadata()
178 header.set(
"BOX.MINX", bbox.getMinX())
179 header.set(
"BOX.MINY", bbox.getMinY())
180 header.set(
"BOX.MAXX", bbox.getMaxX())
181 header.set(
"BOX.MAXY", bbox.getMaxY())
182 header.set(
"ALGORITHM", self.config.background.algorithm)
186 """Measure a background model for image
188 This doesn't use a full-featured background model (e.g., no Chebyshev
189 approximation) because we just want the binning behaviour. This will
190 allow us to average the bins later (`averageBackgrounds`).
192 The `BackgroundMI` is wrapped in a `BackgroundList` so it can be
193 pickled and persisted.
197 image : `lsst.afw.image.MaskedImage`
198 Image for which to measure background.
202 bgModel : `lsst.afw.math.BackgroundList`
206 stats.setAndMask(image.getMask().getPlaneBitMask(self.config.background.mask))
207 stats.setNanSafe(
True)
209 self.config.background.algorithm,
210 max(int(image.getWidth()/self.config.background.xBinSize + 0.5), 1),
211 max(int(image.getHeight()/self.config.background.yBinSize + 0.5), 1),
212 "REDUCE_INTERP_ORDER",
214 self.config.background.statistic
223 afwMath.ApproximateControl.UNKNOWN,
228 """Average multiple background models
230 The input background models should be a `BackgroundList` consisting
231 of a single `BackgroundMI`.
235 bgList : `list` of `lsst.afw.math.BackgroundList`
236 Background models to average.
240 bgExp : `lsst.afw.image.Exposure`
241 Background model in Exposure format.
243 assert all(len(bg) == 1
for bg
in bgList),
"Mixed bgList: %s" % ([len(bg)
for bg
in bgList],)
244 images = [bg[0][0].getStatsImage()
for bg
in bgList]
245 boxes = [bg[0][0].getImageBBox()
for bg
in bgList]
246 assert len(set((box.getMinX(), box.getMinY(), box.getMaxX(), box.getMaxY())
for box
in boxes)) == 1, \
247 "Bounding boxes not all equal"
251 maskVal = afwImage.Mask.getPlaneBitMask(
"BAD")
253 bad = numpy.isnan(img.getImage().getArray())
254 img.getMask().getArray()[bad] = maskVal
257 stats.setAndMask(maskVal)
258 stats.setNanSafe(
True)
265 array = combined.getImage().getArray()
266 bad = numpy.isnan(array)
267 median = numpy.median(array[~bad])
274 """Measure scale of background model in image
276 We treat the sky frame much as we would a fringe frame
277 (except the length scale of the variations is different):
278 we measure samples on the input image and the sky frame,
279 which we will use to determine the scaling factor in the
280 'solveScales` method.
284 image : `lsst.afw.image.Exposure` or `lsst.afw.image.MaskedImage`
285 Science image for which to measure scale.
286 skyBackground : `lsst.afw.math.BackgroundList`
287 Sky background model.
291 imageSamples : `numpy.ndarray`
292 Sample measurements on image.
293 skySamples : `numpy.ndarray`
294 Sample measurements on sky frame.
297 image = image.getMaskedImage()
299 xNumSamples = min(self.config.xNumSamples, image.getWidth())
300 yNumSamples = min(self.config.yNumSamples, image.getHeight())
301 xLimits = numpy.linspace(0, image.getWidth(), xNumSamples + 1, dtype=int)
302 yLimits = numpy.linspace(0, image.getHeight(), yNumSamples + 1, dtype=int)
303 sky = skyBackground.getImage()
304 maskVal = image.getMask().getPlaneBitMask(self.config.stats.mask)
309 for xIndex, yIndex
in itertools.product(range(xNumSamples), range(yNumSamples)):
311 xStart, xStop = xLimits[xIndex], xLimits[xIndex + 1] - 1
312 yStart, yStop = yLimits[yIndex], yLimits[yIndex + 1] - 1
314 subImage = image.Factory(image, box)
315 subSky = sky.Factory(sky, box)
318 return imageSamples, skySamples
321 """Solve multiple scales for a single scale factor
323 Having measured samples from the image and sky frame, we
324 fit for the scaling factor.
328 scales : `list` of a `tuple` of two `numpy.ndarray` arrays
329 A `list` of the results from `measureScale` method.
338 for ii, ss
in scales:
339 imageSamples.extend(ii)
340 skySamples.extend(ss)
341 assert len(imageSamples) == len(skySamples)
342 imageSamples = numpy.array(imageSamples)
343 skySamples = numpy.array(skySamples)
347 return afwMath.LeastSquares.fromDesignMatrix(skySamples[mask].reshape(mask.sum(), 1),
349 afwMath.LeastSquares.DIRECT_SVD).getSolution()[0]
351 mask = numpy.isfinite(imageSamples) & numpy.isfinite(skySamples)
352 for ii
in range(self.config.skyIter):
353 solution = solve(mask)
354 residuals = imageSamples - solution*skySamples
355 lq, uq = numpy.percentile(residuals[mask], [25, 75])
356 stdev = 0.741*(uq - lq)
357 with numpy.errstate(invalid=
"ignore"):
358 bad = numpy.abs(residuals) > self.config.skyRej*stdev
364 """Subtract sky frame from science image
368 image : `lsst.afw.image.Exposure` or `lsst.afw.image.MaskedImage`
370 skyBackground : `lsst.afw.math.BackgroundList`
371 Sky background model.
373 Scale to apply to background model.
374 bgList : `lsst.afw.math.BackgroundList`
375 List of backgrounds applied to image
378 image = image.getMaskedImage()
380 image = image.getImage()
381 image.scaledMinus(scale, skyBackground.getImage())
382 if bgList
is not None:
384 bgData = list(skyBackground[0])
386 statsImage = bg.getStatsImage().clone()
389 newBgData = [newBg] + bgData[1:]
390 bgList.append(newBgData)
394 """Interpolate in one dimension
396 Interpolates the curve provided by `xSample` and `ySample` at
397 the positions of `xInterp`. Automatically backs off the
398 interpolation method to achieve successful interpolation.
402 method : `lsst.afw.math.Interpolate.Style`
403 Interpolation method to use.
404 xSample : `numpy.ndarray`
406 ySample : `numpy.ndarray`
407 Vector of coordinates.
408 xInterp : `numpy.ndarray`
409 Vector of ordinates to which to interpolate.
413 yInterp : `numpy.ndarray`
414 Vector of interpolated coordinates.
417 if len(xSample) == 0:
418 return numpy.ones_like(xInterp)*numpy.nan
421 method).interpolate(xInterp.astype(float))
423 if method == afwMath.Interpolate.CONSTANT:
425 return numpy.ones_like(xInterp)*numpy.nan
427 if newMethod == method:
428 newMethod = afwMath.Interpolate.CONSTANT
433 """Interpolate bad pixels in an image array
435 The bad pixels are modified in the array.
439 array : `numpy.ndarray`
440 Image array with bad pixels.
441 isBad : `numpy.ndarray` of type `bool`
442 Boolean array indicating which pixels are bad.
443 interpolationStyle : `str`
444 Style for interpolation (see `lsst.afw.math.Background`);
445 supported values are CONSTANT, LINEAR, NATURAL_SPLINE,
449 raise RuntimeError(
"No good pixels in image array")
450 height, width = array.shape
451 xIndices = numpy.arange(width, dtype=float)
452 yIndices = numpy.arange(height, dtype=float)
455 for y
in range(height):
456 if numpy.any(isBad[y, :])
and numpy.any(isGood[y, :]):
457 array[y][isBad[y]] =
interpolate1D(method, xIndices[isGood[y]], array[y][isGood[y]],
460 isBad = numpy.isnan(array)
462 for x
in range(width):
463 if numpy.any(isBad[:, x])
and numpy.any(isGood[:, x]):
464 array[:, x][isBad[:, x]] =
interpolate1D(method, yIndices[isGood[:, x]],
465 array[:, x][isGood[:, x]], yIndices[isBad[:, x]])
469 """Configuration for FocalPlaneBackground
471 Note that `xSize` and `ySize` are floating-point values, as
472 the focal plane frame is usually defined in units of microns
473 or millimetres rather than pixels. As such, their values will
474 need to be revised according to each particular camera. For
475 this reason, no defaults are set for those.
477 xSize =
Field(dtype=float, doc=
"Bin size in x")
478 ySize =
Field(dtype=float, doc=
"Bin size in y")
479 pixelSize =
Field(dtype=float, default=1.0, doc=
"Pixel size in same units as xSize/ySize")
480 minFrac =
Field(dtype=float, default=0.1, doc=
"Minimum fraction of bin size for good measurement")
481 mask =
ListField(dtype=str, doc=
"Mask planes to treat as bad",
482 default=[
"BAD",
"SAT",
"INTRP",
"DETECTED",
"DETECTED_NEGATIVE",
"EDGE",
"NO_DATA"])
484 doc=
"how to interpolate the background values. This maps to an enum; see afw::math::Background",
485 dtype=str, default=
"AKIMA_SPLINE", optional=
True,
487 "CONSTANT":
"Use a single constant value",
488 "LINEAR":
"Use linear interpolation",
489 "NATURAL_SPLINE":
"cubic spline with zero second derivative at endpoints",
490 "AKIMA_SPLINE":
"higher-level nonlinear spline that is more robust to outliers",
491 "NONE":
"No background estimation is to be attempted",
494 doSmooth =
Field(dtype=bool, default=
False, doc=
"Do smoothing?")
495 smoothScale =
Field(dtype=float, default=2.0, doc=
"Smoothing scale, as a multiple of the bin size")
496 binning =
Field(dtype=int, default=64, doc=
"Binning to use for CCD background model (pixels)")
500 """Background model for a focal plane camera
502 We model the background empirically with the "superpixel" method: we
503 measure the background in each superpixel and interpolate between
504 superpixels to yield the model.
506 The principal difference between this and `lsst.afw.math.BackgroundMI`
507 is that here the superpixels are defined in the frame of the focal
508 plane of the camera which removes discontinuities across detectors.
510 The constructor you probably want to use is the `fromCamera` classmethod.
512 There are two use patterns for building a background model:
514 * Serial: create a `FocalPlaneBackground`, then `addCcd` for each of the
517 * Parallel: create a `FocalPlaneBackground`, then `clone` it for each
518 of the CCDs in an exposure and use those to `addCcd` their respective
519 CCD image. Finally, `merge` all the clones into the original.
521 Once you've built the background model, you can apply it to individual
522 CCDs with the `toCcdBackground` method.
526 """Construct from a camera object
530 config : `FocalPlaneBackgroundConfig`
531 Configuration for measuring backgrounds.
532 camera : `lsst.afw.cameraGeom.Camera`
533 Camera for which to measure backgrounds.
537 for point
in ccd.getCorners(afwCameraGeom.FOCAL_PLANE):
538 cameraBox.include(point)
540 width, height = cameraBox.getDimensions()
544 dims =
geom.Extent2I(int(numpy.ceil(width/config.xSize)) + 2,
545 int(numpy.ceil(height/config.ySize)) + 2)
547 transform = (geom.AffineTransform.makeTranslation(
geom.Extent2D(1, 1))
548 * geom.AffineTransform.makeScaling(1.0/config.xSize, 1.0/config.ySize)
549 * geom.AffineTransform.makeTranslation(offset))
555 """Construct from an object that has the same interface.
559 other : `FocalPlaneBackground`-like
560 An object that matches the interface of `FocalPlaneBackground`
561 but which may be different.
565 background : `FocalPlaneBackground`
566 Something guaranteed to be a `FocalPlaneBackground`.
568 return cls(other.config, other.dims, other.transform, other._values, other._numbers)
570 def __init__(self, config, dims, transform, values=None, numbers=None):
573 Developers should note that changes to the signature of this method
574 require coordinated changes to the `__reduce__` and `clone` methods.
578 config : `FocalPlaneBackgroundConfig`
579 Configuration for measuring backgrounds.
580 dims : `lsst.geom.Extent2I`
581 Dimensions for background samples.
582 transform : `lsst.afw.geom.TransformPoint2ToPoint2`
583 Transformation from focal plane coordinates to sample coordinates.
584 values : `lsst.afw.image.ImageF`
585 Measured background values.
586 numbers : `lsst.afw.image.ImageF`
587 Number of pixels in each background measurement.
594 values = afwImage.ImageF(self.
dims)
597 values = values.clone()
598 assert values.getDimensions() == self.
dims
601 numbers = afwImage.ImageF(self.
dims)
604 numbers = numbers.clone()
605 assert numbers.getDimensions() == self.
dims
570 def __init__(self, config, dims, transform, values=None, numbers=None):
…
617 We measure the background on the CCD (clipped mean), and record
618 the results in the model. For simplicity, measurements are made
619 in a box on the CCD corresponding to the warped coordinates of the
620 superpixel rather than accounting for little rotations, etc.
621 We also record the number of pixels used in the measurement so we
622 can have a measure of confidence in each bin's value.
626 exposure : `lsst.afw.image.Exposure`
627 CCD exposure to measure
629 detector = exposure.getDetector()
630 transform = detector.getTransformMap().getTransform(detector.makeCameraSys(afwCameraGeom.PIXELS),
631 detector.makeCameraSys(afwCameraGeom.FOCAL_PLANE))
632 image = exposure.getMaskedImage()
633 maskVal = image.getMask().getPlaneBitMask(self.
config.mask)
636 toSample = transform.then(self.
transform)
638 warped = afwImage.ImageF(self.
_values.getBBox())
639 warpedCounts = afwImage.ImageF(self.
_numbers.getBBox())
640 width, height = warped.getDimensions()
643 stats.setAndMask(maskVal)
644 stats.setNanSafe(
True)
646 pixels = itertools.product(range(width), range(height))
647 for xx, yy
in pixels:
648 llc = toSample.applyInverse(
geom.Point2D(xx - 0.5, yy - 0.5))
649 urc = toSample.applyInverse(
geom.Point2D(xx + 0.5, yy + 0.5))
651 bbox.clip(image.getBBox())
654 subImage = image.Factory(image, bbox)
656 mean = result.getValue(afwMath.MEANCLIP)
657 num = result.getValue(afwMath.NPOINT)
658 if not numpy.isfinite(mean)
or not numpy.isfinite(num):
660 warped[xx, yy, afwImage.LOCAL] = mean*num
661 warpedCounts[xx, yy, afwImage.LOCAL] = num
667 """Produce a background model for a CCD
669 The superpixel background model is warped back to the
670 CCD frame, for application to the individual CCD.
674 detector : `lsst.afw.cameraGeom.Detector`
675 CCD for which to produce background model.
676 bbox : `lsst.geom.Box2I`
677 Bounding box of CCD exposure.
681 bg : `lsst.afw.math.BackgroundList`
682 Background model for CCD.
684 transform = detector.getTransformMap().getTransform(detector.makeCameraSys(afwCameraGeom.PIXELS),
685 detector.makeCameraSys(afwCameraGeom.FOCAL_PLANE))
686 binTransform = (geom.AffineTransform.makeScaling(self.
config.binning)
687 * geom.AffineTransform.makeTranslation(
geom.Extent2D(0.5, 0.5)))
693 fpNorm = afwImage.ImageF(focalPlane.getBBox())
696 image = afwImage.ImageF(bbox.getDimensions()//self.
config.binning)
697 norm = afwImage.ImageF(image.getBBox())
704 isBad = numpy.isnan(image.getArray())
705 mask.getArray()[isBad] = mask.getPlaneBitMask(
"BAD")
706 image.getArray()[isBad] = image.getArray()[~isBad].mean()
712 afwMath.ApproximateControl.UNKNOWN,
717 """Merge with another FocalPlaneBackground
719 This allows multiple background models to be constructed from
720 different CCDs, and then merged to form a single consistent
721 background model for the entire focal plane.
725 other : `FocalPlaneBackground`
726 Another background model to merge.
730 self : `FocalPlaneBackground`
731 The merged background model.
733 if (self.
config.xSize, self.
config.ySize) != (other.config.xSize, other.config.ySize):
734 raise RuntimeError(
"Size mismatch: %s vs %s" % ((self.
config.xSize, self.
config.ySize),
735 (other.config.xSize, other.config.ySize)))
736 if self.
dims != other.dims:
737 raise RuntimeError(
"Dimensions mismatch: %s vs %s" % (self.
dims, other.dims))
743 """Merge with another FocalPlaneBackground
747 other : `FocalPlaneBackground`
748 Another background model to merge.
752 self : `FocalPlaneBackground`
753 The merged background model.
755 return self.
merge(other)
758 """Return the background model data
760 This is the measurement of the background for each of the superpixels.
764 thresh = (self.
config.minFrac
766 isBad = self.
_numbers.getArray() < thresh
768 array = values.getArray()
770 isBad = numpy.isnan(values.array)
777 """Configuration for MaskObjectsTask"""
778 nIter =
Field(dtype=int, default=3, doc=
"Number of iterations")
780 doc=
"Background subtraction")
782 detectSigma =
Field(dtype=float, default=5.0, doc=
"Detection threshold (standard deviations)")
783 doInterpolate =
Field(dtype=bool, default=
True, doc=
"Interpolate when removing objects?")
787 self.
detection.reEstimateBackground =
False
788 self.
detection.doTempLocalBackground =
False
789 self.
detection.doTempWideBackground =
False
800 raise RuntimeError(
"Incorrect settings for object masking: reEstimateBackground, "
801 "doTempLocalBackground and doTempWideBackground must be False")
805 """Iterative masking of objects on an Exposure
807 This task makes more exhaustive object mask by iteratively doing detection
808 and background-subtraction. The purpose of this task is to get true
809 background removing faint tails of large objects. This is useful to get a
810 clean sky estimate from relatively small number of visits.
812 We deliberately use the specified ``detectSigma`` instead of the PSF,
813 in order to better pick up the faint wings of objects.
815 ConfigClass = MaskObjectsConfig
821 self.makeSubtask(
"interpolate")
822 self.makeSubtask(
"subtractBackground")
824 def run(self, exposure, maskPlanes=None):
825 """Mask objects on Exposure
827 Objects are found and removed.
831 exposure : `lsst.afw.image.Exposure`
832 Exposure on which to mask objects.
833 maskPlanes : iterable of `str`, optional
834 List of mask planes to remove.
824 def run(self, exposure, maskPlanes=None):
…
840 """Iteratively find objects on an exposure
842 Objects are masked with the ``DETECTED`` mask plane.
846 exposure : `lsst.afw.image.Exposure`
847 Exposure on which to mask objects.
849 for _
in range(self.config.nIter):
850 bg = self.subtractBackground.run(exposure).background
851 self.detection.detectFootprints(exposure, sigma=self.config.detectSigma, clearMask=
True)
852 exposure.maskedImage += bg.getImage()
855 """Remove objects from exposure
857 We interpolate over using a background model if ``doInterpolate`` is
858 set; otherwise we simply replace everything with the median.
862 exposure : `lsst.afw.image.Exposure`
863 Exposure on which to mask objects.
864 maskPlanes : iterable of `str`, optional
865 List of mask planes to remove. ``DETECTED`` will be added as well.
867 image = exposure.image
869 maskVal = mask.getPlaneBitMask(
"DETECTED")
870 if maskPlanes
is not None:
871 maskVal |= mask.getPlaneBitMask(maskPlanes)
872 isBad = mask.array & maskVal > 0
874 if self.config.doInterpolate:
875 smooth = self.interpolate.fitBackground(exposure.maskedImage)
876 replace = smooth.getImageF().array[isBad]
877 mask.array &= ~mask.getPlaneBitMask([
"DETECTED"])
879 replace = numpy.median(image.array[~isBad])
880 image.array[isBad] = replace
884 """Gaussian-smooth an array while ignoring bad pixels
886 It's not sufficient to set the bad pixels to zero, as then they're treated
887 as if they are zero, rather than being ignored altogether. We need to apply
888 a correction to that image that removes the effect of the bad pixels.
892 array : `numpy.ndarray` of floating-point
894 bad : `numpy.ndarray` of `bool`
895 Flag array indicating bad pixels.
901 convolved : `numpy.ndarray`
904 convolved = gaussian_filter(numpy.where(bad, 0.0, array), sigma, mode=
"constant", cval=0.0)
905 denominator = gaussian_filter(numpy.where(bad, 0.0, 1.0), sigma, mode=
"constant", cval=0.0)
906 return convolved/denominator
910 """Create an empty module attached to the relevant parent."""
911 parent, child = name.rsplit(
".", 1)
912 spec = importlib.machinery.ModuleSpec(name,
None)
913 newmod = importlib.util.module_from_spec(spec)
914 setattr(sys.modules[parent], child, newmod)
915 sys.modules[name] = newmod
924 import lsst.pipe.drivers.background
933 setattr(pipe_drivers_background, FocalPlaneBackground.__name__, FocalPlaneBackground)
934 setattr(pipe_drivers_background, FocalPlaneBackgroundConfig.__name__, FocalPlaneBackgroundConfig)
A class to contain the data, WCS, and other information needed to describe an image of the sky.
Represent a 2-dimensional array of bitmask pixels.
A class to manipulate images, masks, and variance as a single object.
Pass parameters to a Background object.
A class to evaluate image background levels.
Pass parameters to a Statistics object.
Parameters to control convolution.
Defines the fields and offsets for a table.
A floating-point coordinate rectangle geometry.
An integer coordinate rectangle.
fromCamera(cls, config, camera)
__init__(self, config, dims, transform, values=None, numbers=None)
toCcdBackground(self, detector, bbox)
__init__(self, *args, **kwargs)
run(self, exposure, maskPlanes=None)
findObjects(self, exposure)
removeObjects(self, exposure, maskPlanes=None)
subtractSkyFrame(self, image, skyBackground, scale, bgList=None)
measureScale(self, image, skyBackground)
averageBackgrounds(self, bgList)
solveScales(self, scales)
exposureToBackground(bgExp)
backgroundToExposure(self, statsImage, bbox)
measureBackground(self, image)
std::shared_ptr< TransformPoint2ToPoint2 > makeTransform(lsst::geom::AffineTransform const &affine)
Wrap an lsst::geom::AffineTransform as a Transform.
MaskedImage< ImagePixelT, MaskPixelT, VariancePixelT > * makeMaskedImage(typename std::shared_ptr< Image< ImagePixelT > > image, typename std::shared_ptr< Mask< MaskPixelT > > mask=Mask< MaskPixelT >(), typename std::shared_ptr< Image< VariancePixelT > > variance=Image< VariancePixelT >())
A function to return a MaskedImage of the correct type (cf.
std::shared_ptr< Exposure< ImagePixelT, MaskPixelT, VariancePixelT > > makeExposure(MaskedImage< ImagePixelT, MaskPixelT, VariancePixelT > &mimage, std::shared_ptr< geom::SkyWcs const > wcs=std::shared_ptr< geom::SkyWcs const >())
A function to return an Exposure of the correct type (cf.
std::shared_ptr< lsst::afw::image::Image< PixelT > > statisticsStack(std::vector< std::shared_ptr< lsst::afw::image::Image< PixelT > > > &images, Property flags, StatisticsControl const &sctrl=StatisticsControl(), std::vector< lsst::afw::image::VariancePixel > const &wvector=std::vector< lsst::afw::image::VariancePixel >(0))
A function to compute some statistics of a stack of Images.
Interpolate::Style lookupMaxInterpStyle(int const n)
Get the highest order Interpolation::Style available for 'n' points.
std::shared_ptr< Background > makeBackground(ImageT const &img, BackgroundControl const &bgCtrl)
A convenience function that uses function overloading to make the correct type of Background.
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)
Property stringToStatisticsProperty(std::string const property)
Conversion function to switch a string to a Property (see Statistics.h)
Interpolate::Style stringToInterpStyle(std::string const &style)
Conversion function to switch a string to an Interpolate::Style.
int warpImage(DestImageT &destImage, geom::SkyWcs const &destWcs, SrcImageT const &srcImage, geom::SkyWcs const &srcWcs, WarpingControl const &control, typename DestImageT::SinglePixel padValue=lsst::afw::math::edgePixel< DestImageT >(typename lsst::afw::image::detail::image_traits< DestImageT >::image_category()))
Warp an Image or MaskedImage to a new Wcs.
UndersampleStyle stringToUndersampleStyle(std::string const &style)
Conversion function to switch a string to an UndersampleStyle.
std::shared_ptr< Interpolate > makeInterpolate(std::vector< double > const &x, std::vector< double > const &y, Interpolate::Style const style=Interpolate::AKIMA_SPLINE)
A factory function to make Interpolate objects.
_create_module_child(name)
smoothArray(array, bad, sigma)
robustMean(array, rej=3.0)
interpolate1D(method, xSample, ySample, xInterp)
interpolateBadPixels(array, isBad, interpolationStyle)