def testZogyNewImplementation(self): """DM-25115 implementation test. Notes ----- See diffimTests: tickets/DM-25115_zogy_implementation/DM-25115_zogy_unit_test_development.ipynb """ # self.svar = svar # variance of noise in science image # self.tvar = tvar # variance of noise in template image # Sourceless case self.im1ex, self.im2ex \ = makeFakeImages(size=(256, 256), svar=100., tvar=100., psf1=self.psf1_sigma, psf2=self.psf2_sigma, n_sources=0, psf_yvary_factor=0, varSourceChange=0.1, seed=1, verbose=False) config = ZogyConfig() config.scaleByCalibration = False task = ZogyTask(config=config) res = task.run(self.im1ex, self.im2ex) bbox = res.diffExp.getBBox() subBbox = bbox.erodedBy(lsst.geom.Extent2I(25, 25)) subExp = res.diffExp[subBbox] pixvar = self._computePixelVariance(subExp.maskedImage) varmean = self._computeVarianceMean(subExp.maskedImage) # Due to 3 sigma clipping, this is not so precise self.assertFloatsAlmostEqual(pixvar, 200, rtol=0.1, atol=None) self.assertFloatsAlmostEqual(varmean, 200, rtol=0.05, atol=None) S = res.scoreExp.image.array / np.sqrt(res.scoreExp.variance.array) self.assertLess(np.amax(S), 5.) # Source not detected # ========== self.im1ex, self.im2ex \ = makeFakeImages(size=(256, 256), svar=10., tvar=10., psf1=self.psf1_sigma, psf2=self.psf2_sigma, n_sources=10, psf_yvary_factor=0, varSourceChange=0.1, seed=1, verbose=False) task = ZogyTask(config=config) res = task.run(self.im1ex, self.im2ex) S = res.scoreExp.image.array / np.sqrt(res.scoreExp.variance.array) self.assertGreater(np.amax(S), 5.) # Source detected
def testPixelOffset(self): """ Test whether the peak position is at [300][300]. """ self._setUpImages() config = ZogyConfig(scaleByCalibration=False) task = ZogyTask(config=config) D_F = task.run(self.imnex, self.imrex, calculateScore=False) max_loc = PixelOffsetTest._find_max(D_F.diffExp.image.array) self.assertEqual(max_loc, (300, 300))
def wrapZogyDiffim(config, templateExposure, scienceExposure): """Prepare and run ZOGY-style image differencing. Parameters ---------- config : `lsst.pex.config.Config` The image differencing Task configuration settings. templateExposure : `lsst.afw.image.ExposureF` The reference image to subtract from the science image. scienceExposure : `lsst.afw.image.ExposureF` The science image. Returns ------- `lsst.afw.image.ExposureF` The image difference. """ config.scaleByCalibration = False zogyTask = ZogyTask(config=config) result = zogyTask.run(scienceExposure, templateExposure) return result.diffExp