def testIOsub(self): """ Test the class' write and readFits when passing on a bounding box. """ bbox = lsst.geom.Box2I(lsst.geom.Point2I(25, 25), lsst.geom.Extent2I(4, 4)) with tempfile.NamedTemporaryFile() as f: self.donutStamps.writeFits(f.name) options = {"bbox": bbox} subStamps = DonutStamps.readFitsWithOptions(f.name, options) for stamp1, stamp2 in zip(self.donutStamps, subStamps): self.assertEqual(bbox.getDimensions(), stamp2.stamp_im.getDimensions()) self.assertMaskedImagesAlmostEqual( stamp1.stamp_im[bbox], stamp2.stamp_im )
def _roundtrip(self, donutStamps): """Round trip a DonutStamps object to disk and check values""" with tempfile.NamedTemporaryFile() as f: donutStamps.writeFits(f.name) options = PropertyList() donutStamps2 = DonutStamps.readFitsWithOptions(f.name, options) self.assertEqual(len(donutStamps), len(donutStamps2)) for stamp1, stamp2 in zip(donutStamps, donutStamps2): self.assertMaskedImagesAlmostEqual(stamp1.stamp_im, stamp2.stamp_im) self.assertAlmostEqual( stamp1.sky_position.getRa().asDegrees(), stamp2.sky_position.getRa().asDegrees(), ) self.assertAlmostEqual( stamp1.sky_position.getDec().asDegrees(), stamp2.sky_position.getDec().asDegrees(), ) self.assertAlmostEqual( stamp1.centroid_position.getX(), stamp2.centroid_position.getX() ) self.assertAlmostEqual( stamp1.centroid_position.getY(), stamp2.centroid_position.getY() ) self.assertEqual(stamp1.detector_name, stamp2.detector_name)