def testPersisted(self): self.table.definePsfFlux("a") self.table.defineCentroid("b") self.table.defineShape("c") with lsst.utils.tests.getTempFilePath(".fits") as filename: self.catalog.writeFits(filename) catalog = lsst.afw.table.SourceCatalog.readFits(filename) table = catalog.getTable() record = catalog[0] # I'm using the keys from the non-persisted table. They should work at least in the # current implementation self.assertEqual(table.getPsfFluxDefinition(), "a") self.assertEqual(record.get(self.fluxKey), record.getPsfFlux()) self.assertEqual(record.get(self.fluxFlagKey), record.getPsfFluxFlag()) self.assertEqual(table.getCentroidDefinition(), "b") centroid = self.centroidKey.get(self.record) self.assertEqual(centroid, record.getCentroid()) self.assertClose(math.fabs(self.record.get(self.xErrKey)), math.sqrt(self.record.getCentroidErr()[0,0]), rtol=1e-6) self.assertClose(math.fabs(self.record.get(self.yErrKey)), math.sqrt(self.record.getCentroidErr()[1,1]), rtol=1e-6) shape = self.shapeKey.get(self.record) self.assertEqual(table.getShapeDefinition(), "c") self.assertEqual(shape, record.getShape()) self.assertClose(math.fabs(self.record.get(self.xxErrKey)), math.sqrt(self.record.getShapeErr()[0,0]), rtol=1e-6) self.assertClose(math.fabs(self.record.get(self.yyErrKey)), math.sqrt(self.record.getShapeErr()[1,1]), rtol=1e-6) self.assertClose(math.fabs(self.record.get(self.xyErrKey)), math.sqrt(self.record.getShapeErr()[2,2]), rtol=1e-6)
def testPersisted(self): self.table.definePsfFlux("a") self.table.defineCentroid("b") self.table.defineShape("c") with lsst.utils.tests.getTempFilePath(".fits") as filename: self.catalog.writeFits(filename) catalog = lsst.afw.table.SourceCatalog.readFits(filename) table = catalog.getTable() record = catalog[0] # I'm using the keys from the non-persisted table. They should work at least in the # current implementation self.assertEqual(record.get(self.instFluxKey), record.getPsfInstFlux()) self.assertEqual(record.get(self.fluxFlagKey), record.getPsfFluxFlag()) self.assertEqual(table.getCentroidDefinition(), "b") self.assertEqual(record.get(self.centroidKey), record.getCentroid()) self.assertFloatsAlmostEqual( record.get(self.centroidErrKey), record.getCentroidErr()) self.assertEqual(table.getShapeDefinition(), "c") self.assertEqual(record.get(self.shapeKey), record.getShape()) self.assertFloatsAlmostEqual( record.get(self.shapeErrKey), record.getShapeErr())
def testPersisted(self): self.table.definePsfFlux("a") self.table.defineCentroid("b") self.table.defineShape("c") with lsst.utils.tests.getTempFilePath(".fits") as filename: self.catalog.writeFits(filename) catalog = lsst.afw.table.SourceCatalog.readFits(filename) table = catalog.getTable() record = catalog[0] # I'm using the keys from the non-persisted table. They should work at least in the # current implementation self.assertEqual(record.get(self.instFluxKey), record.getPsfInstFlux()) self.assertEqual(record.get(self.fluxFlagKey), record.getPsfFluxFlag()) self.assertEqual(table.getCentroidDefinition(), "b") centroid = self.centroidKey.get(self.record) self.assertEqual(centroid, record.getCentroid()) self.assertFloatsAlmostEqual( math.fabs(self.record.get(self.xErrKey)), math.sqrt(self.record.getCentroidErr()[0, 0]), rtol=1e-6) self.assertFloatsAlmostEqual( math.fabs(self.record.get(self.yErrKey)), math.sqrt(self.record.getCentroidErr()[1, 1]), rtol=1e-6) shape = self.shapeKey.get(self.record) self.assertEqual(table.getShapeDefinition(), "c") self.assertEqual(shape, record.getShape()) self.assertFloatsAlmostEqual( math.fabs(self.record.get(self.xxErrKey)), math.sqrt(self.record.getShapeErr()[0, 0]), rtol=1e-6) self.assertFloatsAlmostEqual( math.fabs(self.record.get(self.yyErrKey)), math.sqrt(self.record.getShapeErr()[1, 1]), rtol=1e-6) self.assertFloatsAlmostEqual( math.fabs(self.record.get(self.xyErrKey)), math.sqrt(self.record.getShapeErr()[2, 2]), rtol=1e-6)
def testPersisted(self): self.table.definePsfFlux("a") self.table.defineCentroid("b") self.table.defineShape("c") with lsst.utils.tests.getTempFilePath(".fits") as filename: self.catalog.writeFits(filename) catalog = lsst.afw.table.SourceCatalog.readFits(filename) table = catalog.getTable() record = catalog[0] # I'm using the keys from the non-persisted table. They should work at least in the # current implementation self.assertEqual(table.getPsfFluxDefinition(), "a") self.assertEqual(record.get(self.fluxKey), record.getPsfFlux()) self.assertEqual(record.get(self.fluxFlagKey), record.getPsfFluxFlag()) self.assertEqual(table.getCentroidDefinition(), "b") self.assertEqual(record.get(self.centroidKey), record.getCentroid()) self.assertClose(record.get(self.centroidErrKey), record.getCentroidErr()) self.assertEqual(table.getShapeDefinition(), "c") self.assertEqual(record.get(self.shapeKey), record.getShape()) self.assertClose(record.get(self.shapeErrKey), record.getShapeErr())