40 "DC3a-Sim",
"sci",
"v5-e0",
"v5-e0-c011-a00.sci_img.fits")
41 return afwImage.MaskedImageF(imagePath)
43 def simpleBackground(image):
45 nx = int(image.getWidth()/binsize) + 1
46 ny = int(image.getHeight()/binsize) + 1
51 statsImage = afwMath.cast_BackgroundMI(bkgd).getStatsImage()
53 image -= bkgd.getImageF(afwMath.Interpolate.NATURAL_SPLINE)
57 def complexBackground(image):
59 nx = int(image.getWidth()/binsize) + 1
60 ny = int(image.getHeight()/binsize) + 1
63 sctrl.setNumSigmaClip(3)
65 sctrl.setAndMask(afwImage.MaskU.getPlaneBitMask([
"INTRP",
"EDGE"]))
66 sctrl.setNoGoodPixelsMask(afwImage.MaskU.getPlaneBitMask(
"BAD"))
67 sctrl.setNanSafe(
True)
69 sctrl.setWeighted(
True)
70 sctrl.setCalcErrorFromInputVariance(
True)
76 statsImage = afwMath.cast_BackgroundMI(bkgd).getStatsImage()
77 ds9.mtv(statsImage.getVariance())
79 bkdgImages = dict(SPLINE = bkgd.getImageF(afwMath.Interpolate.NATURAL_SPLINE),
80 LINEAR = bkgd.getImageF(afwMath.Interpolate.LINEAR))
88 ds9.mtv(image, frame=0)
90 bkgd = simpleBackground(image)
92 bkgd = complexBackground(image)
95 ds9.mtv(image, frame=1)
96 ds9.mtv(afwMath.cast_BackgroundMI(bkgd).getStatsImage(), frame=2)
100 approx = bkgd.getApproximate(actrl)
103 approx.getMaskedImage()
104 approx.getImage(order - 1)
107 if __name__ ==
'__main__':