1 from __future__
import absolute_import, division, print_function
5 from scipy.ndimage
import gaussian_filter
15 from lsst.pex.config
import Config, Field, ListField, ChoiceField, ConfigField, RangeField, ConfigurableField
20 """Measure a robust mean of an array 24 array : `numpy.ndarray` 25 Array for which to measure the mean. 27 k-sigma rejection threshold. 32 Robust mean of `array`. 34 q1, median, q3 = numpy.percentile(array, [25.0, 50.0, 100.0])
35 good = numpy.abs(array - median) < rej*0.74*(q3 - q1)
36 return array[good].mean()
40 """Configuration for background measurement""" 41 statistic = ChoiceField(dtype=str, default=
"MEANCLIP", doc=
"type of statistic to use for grid points",
42 allowed={
"MEANCLIP":
"clipped mean",
43 "MEAN":
"unclipped mean",
45 xBinSize = RangeField(dtype=int, default=32, min=1, doc=
"Superpixel size in x")
46 yBinSize = RangeField(dtype=int, default=32, min=1, doc=
"Superpixel size in y")
47 algorithm = ChoiceField(dtype=str, default=
"NATURAL_SPLINE", optional=
True,
48 doc=
"How to interpolate the background values. " 49 "This maps to an enum; see afw::math::Background",
51 "CONSTANT":
"Use a single constant value",
52 "LINEAR":
"Use linear interpolation",
53 "NATURAL_SPLINE":
"cubic spline with zero second derivative at endpoints",
54 "AKIMA_SPLINE":
"higher-level nonlinear spline that is more robust" 56 "NONE":
"No background estimation is to be attempted",
58 mask = ListField(dtype=str, default=[
"SAT",
"BAD",
"EDGE",
"DETECTED",
"DETECTED_NEGATIVE",
"NO_DATA"],
59 doc=
"Names of mask planes to ignore while estimating the background")
63 """Parameters controlling the measurement of sky statistics""" 64 statistic = ChoiceField(dtype=str, default=
"MEANCLIP", doc=
"type of statistic to use for grid points",
65 allowed={
"MEANCLIP":
"clipped mean",
66 "MEAN":
"unclipped mean",
68 clip = Field(doc=
"Clipping threshold for background", dtype=float, default=3.0)
69 nIter = Field(doc=
"Clipping iterations for background", dtype=int, default=3)
70 mask = ListField(doc=
"Mask planes to reject", dtype=str,
71 default=[
"SAT",
"DETECTED",
"DETECTED_NEGATIVE",
"BAD",
"NO_DATA"])
75 """Configuration for SkyMeasurementTask""" 76 skyIter = Field(dtype=int, default=3, doc=
"k-sigma rejection iterations for sky scale")
77 skyRej = Field(dtype=float, default=3.0, doc=
"k-sigma rejection threshold for sky scale")
78 background = ConfigField(dtype=BackgroundConfig, doc=
"Background measurement")
79 xNumSamples = Field(dtype=int, default=4, doc=
"Number of samples in x for scaling sky frame")
80 yNumSamples = Field(dtype=int, default=4, doc=
"Number of samples in y for scaling sky frame")
81 stats = ConfigField(dtype=SkyStatsConfig, doc=
"Measurement of sky statistics in the samples")
85 """Task for creating, persisting and using sky frames 87 A sky frame is like a fringe frame (the sum of many exposures of the night sky, 88 combined with rejection to remove astrophysical objects) except the structure 89 is on larger scales, and hence we bin the images and represent them as a 90 background model (a `lsst.afw.math.BackgroundMI`). The sky frame represents 91 the dominant response of the camera to the sky background. 93 ConfigClass = SkyMeasurementConfig
96 """Retrieve sky frame from the butler 100 butler : `lsst.daf.persistence.Butler` 103 Data identifier for calib 107 sky : `lsst.afw.math.BackgroundList` 110 exp = butler.get(
"sky", calibId)
115 """Convert an exposure to background model 117 Calibs need to be persisted as an Exposure, so we need to convert 118 the persisted Exposure to a background model. 122 bgExp : `lsst.afw.image.Exposure` 123 Background model in Exposure format. 127 bg : `lsst.afw.math.BackgroundList` 130 header = bgExp.getMetadata()
131 xMin = header.getScalar(
"BOX.MINX")
132 yMin = header.getScalar(
"BOX.MINY")
133 xMax = header.getScalar(
"BOX.MAXX")
134 yMax = header.getScalar(
"BOX.MAXY")
135 algorithm = header.getScalar(
"ALGORITHM")
141 afwMath.ApproximateControl.UNKNOWN,
145 """Convert a background model to an exposure 147 Calibs need to be persisted as an Exposure, so we need to convert 148 the background model to an Exposure. 152 statsImage : `lsst.afw.image.MaskedImageF` 153 Background model's statistics image. 154 bbox : `lsst.geom.Box2I` 155 Bounding box for image. 159 exp : `lsst.afw.image.Exposure` 160 Background model in Exposure format. 163 header = exp.getMetadata()
164 header.set(
"BOX.MINX", bbox.getMinX())
165 header.set(
"BOX.MINY", bbox.getMinY())
166 header.set(
"BOX.MAXX", bbox.getMaxX())
167 header.set(
"BOX.MAXY", bbox.getMaxY())
168 header.set(
"ALGORITHM", self.
config.background.algorithm)
172 """Measure a background model for image 174 This doesn't use a full-featured background model (e.g., no Chebyshev 175 approximation) because we just want the binning behaviour. This will 176 allow us to average the bins later (`averageBackgrounds`). 178 The `BackgroundMI` is wrapped in a `BackgroundList` so it can be 179 pickled and persisted. 183 image : `lsst.afw.image.MaskedImage` 184 Image for which to measure background. 188 bgModel : `lsst.afw.math.BackgroundList` 192 stats.setAndMask(image.getMask().getPlaneBitMask(self.
config.background.mask))
193 stats.setNanSafe(
True)
195 self.
config.background.algorithm,
196 max(int(image.getWidth()/self.
config.background.xBinSize + 0.5), 1),
197 max(int(image.getHeight()/self.
config.background.yBinSize + 0.5), 1),
198 "REDUCE_INTERP_ORDER",
200 self.
config.background.statistic
209 afwMath.ApproximateControl.UNKNOWN,
214 """Average multiple background models 216 The input background models should be a `BackgroundList` consisting 217 of a single `BackgroundMI`. 221 bgList : `list` of `lsst.afw.math.BackgroundList` 222 Background models to average. 226 bgExp : `lsst.afw.image.Exposure` 227 Background model in Exposure format. 229 assert all(len(bg) == 1
for bg
in bgList),
"Mixed bgList: %s" % ([len(bg)
for bg
in bgList],)
230 images = [bg[0][0].getStatsImage()
for bg
in bgList]
231 boxes = [bg[0][0].getImageBBox()
for bg
in bgList]
232 assert len(
set((box.getMinX(), box.getMinY(), box.getMaxX(), box.getMaxY())
for box
in boxes)) == 1, \
233 "Bounding boxes not all equal" 237 maskVal = afwImage.Mask.getPlaneBitMask(
"BAD")
239 bad = numpy.isnan(img.getImage().getArray())
240 img.getMask().getArray()[bad] = maskVal
243 stats.setAndMask(maskVal)
244 stats.setNanSafe(
True)
251 array = combined.getImage().getArray()
252 bad = numpy.isnan(array)
253 median = numpy.median(array[~bad])
260 """Measure scale of background model in image 262 We treat the sky frame much as we would a fringe frame 263 (except the length scale of the variations is different): 264 we measure samples on the input image and the sky frame, 265 which we will use to determine the scaling factor in the 266 'solveScales` method. 270 image : `lsst.afw.image.Exposure` or `lsst.afw.image.MaskedImage` 271 Science image for which to measure scale. 272 skyBackground : `lsst.afw.math.BackgroundList` 273 Sky background model. 277 imageSamples : `numpy.ndarray` 278 Sample measurements on image. 279 skySamples : `numpy.ndarray` 280 Sample measurements on sky frame. 283 image = image.getMaskedImage()
285 xNumSamples =
min(self.
config.xNumSamples, image.getWidth())
286 yNumSamples =
min(self.
config.yNumSamples, image.getHeight())
287 xLimits = numpy.linspace(0, image.getWidth(), xNumSamples + 1, dtype=int)
288 yLimits = numpy.linspace(0, image.getHeight(), yNumSamples + 1, dtype=int)
289 sky = skyBackground.getImage()
290 maskVal = image.getMask().getPlaneBitMask(self.
config.stats.mask)
295 for xIndex, yIndex
in itertools.product(range(xNumSamples), range(yNumSamples)):
297 xStart, xStop = xLimits[xIndex], xLimits[xIndex + 1] - 1
298 yStart, yStop = yLimits[yIndex], yLimits[yIndex + 1] - 1
300 subImage = image.Factory(image, box)
301 subSky = sky.Factory(sky, box)
304 return imageSamples, skySamples
307 """Solve multiple scales for a single scale factor 309 Having measured samples from the image and sky frame, we 310 fit for the scaling factor. 314 scales : `list` of a `tuple` of two `numpy.ndarray` arrays 315 A `list` of the results from `measureScale` method. 324 for ii, ss
in scales:
325 imageSamples.extend(ii)
326 skySamples.extend(ss)
327 assert len(imageSamples) == len(skySamples)
328 imageSamples = numpy.array(imageSamples)
329 skySamples = numpy.array(skySamples)
332 return afwMath.LeastSquares.fromDesignMatrix(skySamples[mask].reshape(mask.sum(), 1),
334 afwMath.LeastSquares.DIRECT_SVD).getSolution()
336 mask = numpy.isfinite(imageSamples) & numpy.isfinite(skySamples)
337 for ii
in range(self.
config.skyIter):
338 solution = solve(mask)
339 residuals = imageSamples - solution*skySamples
340 lq, uq = numpy.percentile(residuals[mask], [25, 75])
341 stdev = 0.741*(uq - lq)
342 with numpy.errstate(invalid=
"ignore"):
343 bad = numpy.abs(residuals) > self.
config.skyRej*stdev
349 """Subtract sky frame from science image 353 image : `lsst.afw.image.Exposure` or `lsst.afw.image.MaskedImage` 355 skyBackground : `lsst.afw.math.BackgroundList` 356 Sky background model. 358 Scale to apply to background model. 359 bgList : `lsst.afw.math.BackgroundList` 360 List of backgrounds applied to image 363 image = image.getMaskedImage()
365 image = image.getImage()
366 image.scaledMinus(scale, skyBackground.getImage())
367 if bgList
is not None:
369 bgData =
list(skyBackground[0])
371 statsImage = bg.getStatsImage().
clone()
374 newBgData = [newBg] + bgData[1:]
375 bgList.append(newBgData)
379 """Interpolate in one dimension 381 Interpolates the curve provided by `xSample` and `ySample` at 382 the positions of `xInterp`. Automatically backs off the 383 interpolation method to achieve successful interpolation. 387 method : `lsst.afw.math.Interpolate.Style` 388 Interpolation method to use. 389 xSample : `numpy.ndarray` 391 ySample : `numpy.ndarray` 392 Vector of coordinates. 393 xInterp : `numpy.ndarray` 394 Vector of ordinates to which to interpolate. 398 yInterp : `numpy.ndarray` 399 Vector of interpolated coordinates. 402 if len(xSample) == 0:
403 return numpy.ones_like(xInterp)*numpy.nan
408 if method == afwMath.Interpolate.CONSTANT:
410 return numpy.ones_like(xInterp)*numpy.nan
412 if newMethod == method:
413 newMethod = afwMath.Interpolate.CONSTANT
418 """Interpolate bad pixels in an image array 420 The bad pixels are modified in the array. 424 array : `numpy.ndarray` 425 Image array with bad pixels. 426 isBad : `numpy.ndarray` of type `bool` 427 Boolean array indicating which pixels are bad. 428 interpolationStyle : `str` 429 Style for interpolation (see `lsst.afw.math.Background`); 430 supported values are CONSTANT, LINEAR, NATURAL_SPLINE, 434 raise RuntimeError(
"No good pixels in image array")
435 height, width = array.shape
436 xIndices = numpy.arange(width, dtype=float)
437 yIndices = numpy.arange(height, dtype=float)
440 for y
in range(height):
441 if numpy.any(isBad[y, :])
and numpy.any(isGood[y, :]):
442 array[y][isBad[y]] =
interpolate1D(method, xIndices[isGood[y]], array[y][isGood[y]],
445 isBad = numpy.isnan(array)
447 for x
in range(width):
448 if numpy.any(isBad[:, x])
and numpy.any(isGood[:, x]):
449 array[:, x][isBad[:, x]] =
interpolate1D(method, yIndices[isGood[:, x]],
450 array[:, x][isGood[:, x]], yIndices[isBad[:, x]])
454 """Configuration for FocalPlaneBackground 456 Note that `xSize` and `ySize` are floating-point values, as 457 the focal plane frame is usually defined in units of microns 458 or millimetres rather than pixels. As such, their values will 459 need to be revised according to each particular camera. For 460 this reason, no defaults are set for those. 462 xSize = Field(dtype=float, doc=
"Bin size in x")
463 ySize = Field(dtype=float, doc=
"Bin size in y")
464 pixelSize = Field(dtype=float, default=1.0, doc=
"Pixel size in same units as xSize/ySize")
465 minFrac = Field(dtype=float, default=0.1, doc=
"Minimum fraction of bin size for good measurement")
466 mask = ListField(dtype=str, doc=
"Mask planes to treat as bad",
467 default=[
"BAD",
"SAT",
"INTRP",
"DETECTED",
"DETECTED_NEGATIVE",
"EDGE",
"NO_DATA"])
468 interpolation = ChoiceField(
469 doc=
"how to interpolate the background values. This maps to an enum; see afw::math::Background",
470 dtype=str, default=
"AKIMA_SPLINE", optional=
True,
472 "CONSTANT":
"Use a single constant value",
473 "LINEAR":
"Use linear interpolation",
474 "NATURAL_SPLINE":
"cubic spline with zero second derivative at endpoints",
475 "AKIMA_SPLINE":
"higher-level nonlinear spline that is more robust to outliers",
476 "NONE":
"No background estimation is to be attempted",
479 doSmooth = Field(dtype=bool, default=
False, doc=
"Do smoothing?")
480 smoothScale = Field(dtype=float, default=2.0, doc=
"Smoothing scale, as a multiple of the bin size")
481 binning = Field(dtype=int, default=64, doc=
"Binning to use for CCD background model (pixels)")
485 """Background model for a focal plane camera 487 We model the background empirically with the "superpixel" method: we 488 measure the background in each superpixel and interpolate between 489 superpixels to yield the model. 491 The principal difference between this and `lsst.afw.math.BackgroundMI` 492 is that here the superpixels are defined in the frame of the focal 493 plane of the camera which removes discontinuities across detectors. 495 The constructor you probably want to use is the `fromCamera` classmethod. 497 There are two use patterns for building a background model: 499 * Serial: create a `FocalPlaneBackground`, then `addCcd` for each of the 502 * Parallel: create a `FocalPlaneBackground`, then `clone` it for each 503 of the CCDs in an exposure and use those to `addCcd` their respective 504 CCD image. Finally, `merge` all the clones into the original. 506 Once you've built the background model, you can apply it to individual 507 CCDs with the `toCcdBackground` method. 511 """Construct from a camera object 515 config : `FocalPlaneBackgroundConfig` 516 Configuration for measuring backgrounds. 517 camera : `lsst.afw.cameraGeom.Camera` 518 Camera for which to measure backgrounds. 522 for point
in ccd.getCorners(afwCameraGeom.FOCAL_PLANE):
523 cameraBox.include(point)
525 width, height = cameraBox.getDimensions()
529 dims =
geom.Extent2I(int(numpy.ceil(width/config.xSize)) + 2,
530 int(numpy.ceil(height/config.ySize)) + 2)
532 transform = (geom.AffineTransform.makeTranslation(
geom.Extent2D(1, 1))*
533 geom.AffineTransform.makeScaling(1.0/config.xSize, 1.0/config.ySize)*
534 geom.AffineTransform.makeTranslation(offset))
538 def __init__(self, config, dims, transform, values=None, numbers=None):
541 Developers should note that changes to the signature of this method 542 require coordinated changes to the `__reduce__` and `clone` methods. 546 config : `FocalPlaneBackgroundConfig` 547 Configuration for measuring backgrounds. 548 dims : `lsst.geom.Extent2I` 549 Dimensions for background samples. 550 transform : `lsst.afw.geom.TransformPoint2ToPoint2` 551 Transformation from focal plane coordinates to sample coordinates. 552 values : `lsst.afw.image.ImageF` 553 Measured background values. 554 numbers : `lsst.afw.image.ImageF` 555 Number of pixels in each background measurement. 562 values = afwImage.ImageF(self.
dims)
565 values = values.clone()
566 assert(values.getDimensions() == self.
dims)
569 numbers = afwImage.ImageF(self.
dims)
572 numbers = numbers.clone()
573 assert(numbers.getDimensions() == self.
dims)
585 We measure the background on the CCD (clipped mean), and record 586 the results in the model. For simplicity, measurements are made 587 in a box on the CCD corresponding to the warped coordinates of the 588 superpixel rather than accounting for little rotations, etc. 589 We also record the number of pixels used in the measurement so we 590 can have a measure of confidence in each bin's value. 594 exposure : `lsst.afw.image.Exposure` 595 CCD exposure to measure 597 detector = exposure.getDetector()
598 transform = detector.getTransformMap().getTransform(detector.makeCameraSys(afwCameraGeom.PIXELS),
599 detector.makeCameraSys(afwCameraGeom.FOCAL_PLANE))
600 image = exposure.getMaskedImage()
601 maskVal = image.getMask().getPlaneBitMask(self.
config.mask)
604 toSample = transform.then(self.
transform)
606 warped = afwImage.ImageF(self.
_values.getBBox())
607 warpedCounts = afwImage.ImageF(self.
_numbers.getBBox())
608 width, height = warped.getDimensions()
611 stats.setAndMask(maskVal)
612 stats.setNanSafe(
True)
614 pixels = itertools.product(range(width), range(height))
615 for xx, yy
in pixels:
616 llc = toSample.applyInverse(
geom.Point2D(xx - 0.5, yy - 0.5))
617 urc = toSample.applyInverse(
geom.Point2D(xx + 0.5, yy + 0.5))
619 bbox.clip(image.getBBox())
622 subImage = image.Factory(image, bbox)
624 mean = result.getValue(afwMath.MEANCLIP)
625 num = result.getValue(afwMath.NPOINT)
626 if not numpy.isfinite(mean)
or not numpy.isfinite(num):
628 warped[xx, yy, afwImage.LOCAL] = mean*num
629 warpedCounts[xx, yy, afwImage.LOCAL] = num
635 """Produce a background model for a CCD 637 The superpixel background model is warped back to the 638 CCD frame, for application to the individual CCD. 642 detector : `lsst.afw.cameraGeom.Detector` 643 CCD for which to produce background model. 644 bbox : `lsst.geom.Box2I` 645 Bounding box of CCD exposure. 649 bg : `lsst.afw.math.BackgroundList` 650 Background model for CCD. 652 transform = detector.getTransformMap().getTransform(detector.makeCameraSys(afwCameraGeom.PIXELS),
653 detector.makeCameraSys(afwCameraGeom.FOCAL_PLANE))
654 binTransform = (geom.AffineTransform.makeScaling(self.
config.binning)*
655 geom.AffineTransform.makeTranslation(
geom.Extent2D(0.5, 0.5)))
661 fpNorm = afwImage.ImageF(focalPlane.getBBox())
664 image = afwImage.ImageF(bbox.getDimensions()//self.
config.binning)
665 norm = afwImage.ImageF(image.getBBox())
672 isBad = numpy.isnan(image.getArray())
673 mask.getArray()[isBad] = mask.getPlaneBitMask(
"BAD")
674 image.getArray()[isBad] = image.getArray()[~isBad].mean()
680 afwMath.ApproximateControl.UNKNOWN,
685 """Merge with another FocalPlaneBackground 687 This allows multiple background models to be constructed from 688 different CCDs, and then merged to form a single consistent 689 background model for the entire focal plane. 693 other : `FocalPlaneBackground` 694 Another background model to merge. 698 self : `FocalPlaneBackground` 699 The merged background model. 701 if (self.
config.xSize, self.
config.ySize) != (other.config.xSize, other.config.ySize):
702 raise RuntimeError(
"Size mismatch: %s vs %s" % ((self.
config.xSize, self.
config.ySize),
703 (other.config.xSize, other.config.ySize)))
704 if self.
dims != other.dims:
705 raise RuntimeError(
"Dimensions mismatch: %s vs %s" % (self.
dims, other.dims))
711 """Merge with another FocalPlaneBackground 715 other : `FocalPlaneBackground` 716 Another background model to merge. 720 self : `FocalPlaneBackground` 721 The merged background model. 723 return self.
merge(other)
726 """Return the background model data 728 This is the measurement of the background for each of the superpixels. 732 thresh = (self.
config.minFrac*
734 isBad = self.
_numbers.getArray() < thresh
736 array = values.getArray()
738 isBad = numpy.isnan(values.array)
745 """Configuration for MaskObjectsTask""" 746 nIter = Field(dtype=int, default=3, doc=
"Number of iterations")
747 subtractBackground = ConfigurableField(target=measAlg.SubtractBackgroundTask,
748 doc=
"Background subtraction")
749 detection = ConfigurableField(target=measAlg.SourceDetectionTask, doc=
"Source detection")
750 detectSigma = Field(dtype=float, default=5.0, doc=
"Detection threshold (standard deviations)")
751 doInterpolate = Field(dtype=bool, default=
True, doc=
"Interpolate when removing objects?")
752 interpolate = ConfigurableField(target=measAlg.SubtractBackgroundTask, doc=
"Interpolation")
755 self.
detection.reEstimateBackground =
False 756 self.
detection.doTempLocalBackground =
False 757 self.
detection.doTempWideBackground =
False 765 if (self.
detection.reEstimateBackground
or 768 raise RuntimeError(
"Incorrect settings for object masking: reEstimateBackground, " 769 "doTempLocalBackground and doTempWideBackground must be False")
773 """Iterative masking of objects on an Exposure 775 This task makes more exhaustive object mask by iteratively doing detection 776 and background-subtraction. The purpose of this task is to get true 777 background removing faint tails of large objects. This is useful to get a 778 clean sky estimate from relatively small number of visits. 780 We deliberately use the specified ``detectSigma`` instead of the PSF, 781 in order to better pick up the faint wings of objects. 783 ConfigClass = MaskObjectsConfig
792 def run(self, exposure, maskPlanes=None):
793 """Mask objects on Exposure 795 Objects are found and removed. 799 exposure : `lsst.afw.image.Exposure` 800 Exposure on which to mask objects. 801 maskPlanes : iterable of `str`, optional 802 List of mask planes to remove. 808 """Iteratively find objects on an exposure 810 Objects are masked with the ``DETECTED`` mask plane. 814 exposure : `lsst.afw.image.Exposure` 815 Exposure on which to mask objects. 817 for _
in range(self.
config.nIter):
818 bg = self.subtractBackground.
run(exposure).background
819 self.detection.detectFootprints(exposure, sigma=self.
config.detectSigma, clearMask=
True)
820 exposure.maskedImage += bg.getImage()
823 """Remove objects from exposure 825 We interpolate over using a background model if ``doInterpolate`` is 826 set; otherwise we simply replace everything with the median. 830 exposure : `lsst.afw.image.Exposure` 831 Exposure on which to mask objects. 832 maskPlanes : iterable of `str`, optional 833 List of mask planes to remove. ``DETECTED`` will be added as well. 835 image = exposure.image
837 maskVal = mask.getPlaneBitMask(
"DETECTED")
838 if maskPlanes
is not None:
839 maskVal |= mask.getPlaneBitMask(maskPlanes)
840 isBad = mask.array & maskVal > 0
842 if self.
config.doInterpolate:
843 smooth = self.interpolate.fitBackground(exposure.maskedImage)
844 replace = smooth.getImageF().array[isBad]
845 mask.array &= ~mask.getPlaneBitMask([
"DETECTED"])
847 replace = numpy.median(image.array[~isBad])
848 image.array[isBad] = replace
852 """Gaussian-smooth an array while ignoring bad pixels 854 It's not sufficient to set the bad pixels to zero, as then they're treated 855 as if they are zero, rather than being ignored altogether. We need to apply 856 a correction to that image that removes the effect of the bad pixels. 860 array : `numpy.ndarray` of floating-point 862 bad : `numpy.ndarray` of `bool` 863 Flag array indicating bad pixels. 869 convolved : `numpy.ndarray` 872 convolved = gaussian_filter(numpy.where(bad, 0.0, array), sigma, mode=
"constant", cval=0.0)
873 denominator = gaussian_filter(numpy.where(bad, 0.0, 1.0), sigma, mode=
"constant", cval=0.0)
874 return convolved/denominator
Defines the fields and offsets for a table.
UndersampleStyle stringToUndersampleStyle(std::string const &style)
Conversion function to switch a string to an UndersampleStyle.
Interpolate::Style stringToInterpStyle(std::string const &style)
Conversion function to switch a string to an Interpolate::Style.
def removeObjects(self, exposure, maskPlanes=None)
def makeSubtask(self, name, keyArgs)
def fromCamera(cls, config, camera)
A floating-point coordinate rectangle geometry.
def robustMean(array, rej=3.0)
int warpImage(DestImageT &destImage, SrcImageT const &srcImage, geom::TransformPoint2ToPoint2 const &srcToDest, WarpingControl const &control, typename DestImageT::SinglePixel padValue=lsst::afw::math::edgePixel< DestImageT >(typename lsst::afw::image::detail::image_traits< DestImageT >::image_category()))
A variant of warpImage that uses a Transform<Point2Endpoint, Point2Endpoint> instead of a pair of WCS...
A class to contain the data, WCS, and other information needed to describe an image of the sky...
def interpolateBadPixels(array, isBad, interpolationStyle)
def addCcd(self, exposure)
def subtractSkyFrame(self, image, skyBackground, scale, bgList=None)
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...
def run(self, exposure, maskPlanes=None)
Parameters to control convolution.
def smoothArray(array, bad, sigma)
Fit spatial kernel using approximate fluxes for candidates, and solving a linear system of equations...
daf::base::PropertySet * set
def toCcdBackground(self, detector, bbox)
Pass parameters to a Background object.
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.
Statistics makeStatistics(lsst::afw::math::MaskedVector< EntryT > const &mv, std::vector< WeightPixel > const &vweights, int const flags, StatisticsControl const &sctrl=StatisticsControl())
The makeStatistics() overload to handle lsst::afw::math::MaskedVector<>
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.
Property stringToStatisticsProperty(std::string const property)
Conversion function to switch a string to a Property (see Statistics.h)
bool all(CoordinateExpr< N > const &expr) noexcept
Return true if all elements are true.
Pass parameters to a Statistics object.
def interpolate1D(method, xSample, ySample, xInterp)
def measureBackground(self, image)
Represent a 2-dimensional array of bitmask pixels.
def averageBackgrounds(self, bgList)
def getSkyData(self, butler, calibId)
std::shared_ptr< Interpolate > makeInterpolate(ndarray::Array< double const, 1 > const &x, ndarray::Array< double const, 1 > const &y, Interpolate::Style const style=Interpolate::AKIMA_SPLINE)
A class to manipulate images, masks, and variance as a single object.
Interpolate::Style lookupMaxInterpStyle(int const n)
Get the highest order Interpolation::Style available for 'n' points.
def exposureToBackground(bgExp)
def __init__(self, args, kwargs)
std::shared_ptr< image::MaskedImage< PixelT > > statisticsStack(image::MaskedImage< PixelT > const &image, Property flags, char dimension, StatisticsControl const &sctrl)
A function to compute statistics on the rows or columns of an image.
def solveScales(self, scales)
def __init__(self, config, dims, transform, values=None, numbers=None)
A class to evaluate image background levels.
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects...
def findObjects(self, exposure)
def measureScale(self, image, skyBackground)
def __iadd__(self, other)
An integer coordinate rectangle.
daf::base::PropertyList * list
std::shared_ptr< TransformPoint2ToPoint2 > makeTransform(lsst::geom::AffineTransform const &affine)
Wrap an lsst::geom::AffineTransform as a Transform.
def backgroundToExposure(self, statsImage, bbox)