def cmpExposure(self, e1, e2): self.assertEqual(e1.getDetector().getName(), e2.getDetector().getName()) self.assertEqual(e1.getDetector().getSerial(), e2.getDetector().getSerial()) self.assertEqual(e1.getFilter().getName(), e2.getFilter().getName()) xy = afwGeom.Point2D(0, 0) self.assertEqual(e1.getWcs().pixelToSky(xy)[0], e2.getWcs().pixelToSky(xy)[0]) self.assertEqual(e1.getCalib(), e2.getCalib()) # check PSF identity if not e1.getPsf(): self.assertFalse(e2.getPsf()) else: psf1 = DummyPsf.swigConvert(e1.getPsf()) psf2 = DummyPsf.swigConvert(e2.getPsf()) self.assertEqual(psf1.getValue(), psf2.getValue())
def cmpExposure(self, e1, e2): self.assertEqual(e1.getDetector().getName(), e2.getDetector().getName()) self.assertEqual(e1.getDetector().getSerial(), e2.getDetector().getSerial()) self.assertEqual(e1.getFilter().getName(), e2.getFilter().getName()) xy = afwGeom.Point2D(0, 0) self.assertEqual(e1.getWcs().pixelToSky(xy)[0], e2.getWcs().pixelToSky(xy)[0]) self.assertEqual(e1.getCalib().getExptime(), e2.getCalib().getExptime()) # check PSF identity if not e1.getPsf(): self.assertFalse(e2.getPsf()) else: psf1 = DummyPsf.swigConvert(e1.getPsf()) psf2 = DummyPsf.swigConvert(e2.getPsf()) self.assertEqual(psf1.getValue(), psf2.getValue())
def testReadWriteFits(self): """Test readFits and writeFits. """ # This should pass without an exception mainExposure = afwImage.ExposureF(inFilePathSmall) mainExposure.setDetector(self.detector) subBBox = afwGeom.Box2I(afwGeom.Point2I(10, 10), afwGeom.Extent2I(40, 50)) subExposure = mainExposure.Factory(mainExposure, subBBox, afwImage.LOCAL) self.checkWcs(mainExposure, subExposure) det = subExposure.getDetector() self.assertTrue(det) subExposure = afwImage.ExposureF(inFilePathSmall, subBBox, afwImage.LOCAL) self.checkWcs(mainExposure, subExposure) # This should throw an exception def getExposure(): afwImage.ExposureF(inFilePathSmallImage) self.assertRaises(lsst.afw.fits.FitsError, getExposure) mainExposure.setPsf(self.psf) # Make sure we can write without an exception mainExposure.getCalib().setExptime(10) mainExposure.getCalib().setMidTime(dafBase.DateTime()) midMjd = mainExposure.getCalib().getMidTime().get() fluxMag0, fluxMag0Err = 1e12, 1e10 mainExposure.getCalib().setFluxMag0(fluxMag0, fluxMag0Err) with utilsTests.getTempFilePath(".fits") as tmpFile: mainExposure.writeFits(tmpFile) readExposure = type(mainExposure)(tmpFile) # # Check the round-tripping # self.assertEqual(mainExposure.getFilter().getName(), readExposure.getFilter().getName()) self.assertEqual(mainExposure.getCalib().getExptime(), readExposure.getCalib().getExptime()) self.assertEqual(midMjd, readExposure.getCalib().getMidTime().get()) self.assertEqual((fluxMag0, fluxMag0Err), readExposure.getCalib().getFluxMag0()) psf = readExposure.getPsf() self.assert_(psf is not None) dummyPsf = DummyPsf.swigConvert(psf) self.assert_(dummyPsf is not None) self.assertEqual(dummyPsf.getValue(), self.psf.getValue())
def comparePsfs(self, psf1, psf2): psf1 = DummyPsf.swigConvert(psf1) psf2 = DummyPsf.swigConvert(psf2) self.assertIsNotNone(psf1) self.assertIsNotNone(psf2) self.assertEqual(psf1.getValue(), psf2.getValue())
def testReadWriteFits(self): """Test readFits and writeFits. """ # This should pass without an exception mainExposure = afwImage.ExposureF(inFilePathSmall) mainExposure.setDetector(cameraGeom.Detector(cameraGeom.Id(666))) subBBox = afwGeom.Box2I(afwGeom.Point2I(10, 10), afwGeom.Extent2I(40, 50)) subExposure = mainExposure.Factory(mainExposure, subBBox, afwImage.LOCAL) self.checkWcs(mainExposure, subExposure) det = subExposure.getDetector() self.assertTrue(det) subExposure = afwImage.ExposureF(inFilePathSmall, subBBox) self.checkWcs(mainExposure, subExposure) # This should throw an exception def getExposure(): afwImage.ExposureF(inFilePathSmallImage) utilsTests.assertRaisesLsstCpp(self, lsst.afw.fits.FitsError, getExposure) mainExposure.setPsf(self.psf) # Make sure we can write without an exception mainExposure.getCalib().setExptime(10) mainExposure.getCalib().setMidTime(dafBase.DateTime()) midMjd = mainExposure.getCalib().getMidTime().get() fluxMag0, fluxMag0Err = 1e12, 1e10 mainExposure.getCalib().setFluxMag0(fluxMag0, fluxMag0Err) mainExposure.writeFits(outFile) # Check scaling of Calib scale = 2.0 calib = mainExposure.getCalib() calib *= scale self.assertEqual((fluxMag0 * scale, fluxMag0Err * scale), calib.getFluxMag0()) calib /= scale self.assertEqual((fluxMag0, fluxMag0Err), calib.getFluxMag0()) readExposure = type(mainExposure)(outFile) os.remove(outFile) # # Check the round-tripping # self.assertEqual(mainExposure.getFilter().getName(), readExposure.getFilter().getName()) self.assertEqual(mainExposure.getCalib().getExptime(), readExposure.getCalib().getExptime()) self.assertEqual(midMjd, readExposure.getCalib().getMidTime().get()) self.assertEqual((fluxMag0, fluxMag0Err), readExposure.getCalib().getFluxMag0()) psf = readExposure.getPsf() self.assert_(psf is not None) dummyPsf = DummyPsf.swigConvert(psf) self.assert_(dummyPsf is not None) self.assertEqual(dummyPsf.getValue(), self.psf.getValue())
def comparePsfs(self, psf1, psf2): psf1 = DummyPsf.swigConvert(psf1) psf2 = DummyPsf.swigConvert(psf2) self.assert_(psf1 is not None) self.assert_(psf2 is not None) self.assertEqual(psf1.getValue(), psf2.getValue())