def testMakeMinimalSchema(self): """Make a schema and check it.""" for filterNameList in (["r"], ["foo", "_bar"]): for (addIsPhotometric, addIsResolved, addIsVariable, coordErrDim, addProperMotion, properMotionErrDim, addParallax, addParallaxErr) in itertools.product( (False, True), (False, True), (False, True), (-1, 0, 1, 2, 3, 4), (False, True), (-1, 0, 1, 2, 3, 4), (False, True), (False, True)): argDict = dict( filterNameList=filterNameList, addIsPhotometric=addIsPhotometric, addIsResolved=addIsResolved, addIsVariable=addIsVariable, coordErrDim=coordErrDim, addProperMotion=addProperMotion, properMotionErrDim=properMotionErrDim, addParallax=addParallax, addParallaxErr=addParallaxErr, ) if coordErrDim not in (0, 2, 3) or \ (addProperMotion and properMotionErrDim not in (0, 2, 3)): with self.assertRaises(ValueError): LoadReferenceObjectsTask.makeMinimalSchema(**argDict) else: refSchema = LoadReferenceObjectsTask.makeMinimalSchema(**argDict) self.assertTrue("coord_ra" in refSchema) self.assertTrue("coord_dec" in refSchema) self.assertTrue("centroid_x" in refSchema) self.assertTrue("centroid_y" in refSchema) self.assertTrue("hasCentroid" in refSchema) for filterName in filterNameList: fluxField = filterName + "_flux" self.assertIn(fluxField, refSchema) self.assertNotIn("x" + fluxField, refSchema) fluxErrField = fluxField + "Err" self.assertIn(fluxErrField, refSchema) self.assertEqual(getRefFluxField(refSchema, filterName), filterName + "_flux") self.assertEqual("resolved" in refSchema, addIsResolved) self.assertEqual("variable" in refSchema, addIsVariable) self.assertEqual("photometric" in refSchema, addIsPhotometric) self.assertEqual("photometric" in refSchema, addIsPhotometric) self.assertEqual("epoch" in refSchema, addProperMotion or addParallax) self.assertEqual("coord_raErr" in refSchema, coordErrDim > 0) self.assertEqual("coord_decErr" in refSchema, coordErrDim > 0) self.assertEqual("coord_ra_dec_Cov" in refSchema, coordErrDim == 3) self.assertEqual("pm_ra" in refSchema, addProperMotion) self.assertEqual("pm_dec" in refSchema, addProperMotion) self.assertEqual("pm_raErr" in refSchema, addProperMotion and properMotionErrDim > 0) self.assertEqual("pm_decErr" in refSchema, addProperMotion and properMotionErrDim > 0) self.assertEqual("pm_flag" in refSchema, addProperMotion) self.assertEqual("pm_ra_dec_Cov" in refSchema, addProperMotion and properMotionErrDim == 3) self.assertEqual("parallax" in refSchema, addParallax) self.assertEqual("parallaxErr" in refSchema, addParallax and addParallaxErr) self.assertEqual("parallax_flag" in refSchema, addParallax)
def testMakeMinimalSchema(self): """Make a schema and check it.""" for filterNameList in (["r"], ["foo", "_bar"]): for (addIsPhotometric, addIsResolved, addIsVariable, coordErrDim, addProperMotion, properMotionErrDim, addParallax) in itertools.product( (False, True), (False, True), (False, True), (-1, 0, 1, 2, 3, 4), (False, True), (-1, 0, 1, 2, 3, 4), (False, True)): argDict = dict( filterNameList=filterNameList, addIsPhotometric=addIsPhotometric, addIsResolved=addIsResolved, addIsVariable=addIsVariable, coordErrDim=coordErrDim, addProperMotion=addProperMotion, properMotionErrDim=properMotionErrDim, addParallax=addParallax, ) if coordErrDim not in (0, 2, 3) or \ (addProperMotion and properMotionErrDim not in (0, 2, 3)): with self.assertRaises(ValueError): LoadReferenceObjectsTask.makeMinimalSchema(**argDict) else: refSchema = LoadReferenceObjectsTask.makeMinimalSchema(**argDict) self.assertTrue("coord_ra" in refSchema) self.assertTrue("coord_dec" in refSchema) for filterName in filterNameList: fluxField = filterName + "_flux" self.assertIn(fluxField, refSchema) self.assertNotIn("x" + fluxField, refSchema) fluxErrField = fluxField + "Err" self.assertIn(fluxErrField, refSchema) self.assertEqual(getRefFluxField(refSchema, filterName), filterName + "_flux") self.assertEqual("resolved" in refSchema, addIsResolved) self.assertEqual("variable" in refSchema, addIsVariable) self.assertEqual("photometric" in refSchema, addIsPhotometric) self.assertEqual("photometric" in refSchema, addIsPhotometric) self.assertEqual("epoch" in refSchema, addProperMotion or addParallax) self.assertEqual("coord_raErr" in refSchema, coordErrDim > 0) self.assertEqual("coord_decErr" in refSchema, coordErrDim > 0) self.assertEqual("coord_ra_dec_Cov" in refSchema, coordErrDim == 3) self.assertEqual("pm_ra" in refSchema, addProperMotion) self.assertEqual("pm_dec" in refSchema, addProperMotion) self.assertEqual("pm_raErr" in refSchema, addProperMotion and properMotionErrDim > 0) self.assertEqual("pm_decErr" in refSchema, addProperMotion and properMotionErrDim > 0) self.assertEqual("pm_flag" in refSchema, addProperMotion) self.assertEqual("pm_ra_dec_Cov" in refSchema, addProperMotion and properMotionErrDim == 3) self.assertEqual("parallax" in refSchema, addParallax) self.assertEqual("parallaxErr" in refSchema, addParallax) self.assertEqual("parallax_flag" in refSchema, addParallax)
def loadAndMatch(self, exposure, sourceCat): """!Fake loading and matching Copy the source catalog to a reference catalog and producing a match list """ wcs = exposure.getWcs() refSchema = LoadReferenceObjectsTask.makeMinimalSchema( filterNameList = [FilterName], addIsPhotometric = True, ) refCat = afwTable.SimpleCatalog(refSchema) refFluxKey = refSchema[FilterName + "_flux"].asKey() refIsPhotoKey = refSchema["photometric"].asKey() matches = lsst.afw.table.ReferenceMatchVector() for src in sourceCat: flux = 1e-3*src.getPsfFlux()*np.random.normal(1.0, 2e-2) refObj = refCat.addNew() refObj.set(refFluxKey, flux) refObj.setCoord(wcs.pixelToSky(src.getCentroid())) refObj.set(refIsPhotoKey, True) match = lsst.afw.table.ReferenceMatch(refObj, src, 0) matches.append(match) return pipeBase.Struct( refCat = refCat, matches = matches, matchMeta = createMatchMetadata(exposure), )
def loadAndMatch(self, exposure, sourceCat): """!Fake loading and matching Copy the source catalog to a reference catalog and producing a match list """ wcs = exposure.getWcs() refSchema = LoadReferenceObjectsTask.makeMinimalSchema( filterNameList=[FilterName], addIsPhotometric=True, ) refCat = afwTable.SimpleCatalog(refSchema) refFluxKey = refSchema[FilterName + "_flux"].asKey() refIsPhotoKey = refSchema["photometric"].asKey() matches = lsst.afw.table.ReferenceMatchVector() for src in sourceCat: flux = 1e-3 * src.getPsfFlux() * np.random.normal(1.0, 2e-2) refObj = refCat.addNew() refObj.set(refFluxKey, flux) refObj.setCoord(wcs.pixelToSky(src.getCentroid())) refObj.set(refIsPhotoKey, True) match = lsst.afw.table.ReferenceMatch(refObj, src, 0) matches.append(match) return pipeBase.Struct( refCat=refCat, matches=matches, matchMeta=createMatchMetadata(exposure), )
def makeRefCatalog(self): schema = LoadReferenceObjectsTask.makeMinimalSchema( filterNameList=["g", "r"], addIsPhotometric=True, addIsResolved=True) catalog = afwTable.SimpleCatalog(schema) return catalog
def loadData(self, rangePix=3000, numPoints=25): """Load catalogs and make the match list This is a separate function so data can be reloaded if fitting more than once (each time a WCS is fit it may update the source catalog, reference catalog and match list) """ refSchema = LoadReferenceObjectsTask.makeMinimalSchema( filterNameList=["r"], addIsPhotometric=True, addCentroid=True) self.refCat = afwTable.SimpleCatalog(refSchema) srcSchema = afwTable.SourceTable.makeMinimalSchema() SingleFrameMeasurementTask(schema=srcSchema) self.srcCoordKey = afwTable.CoordKey(srcSchema["coord"]) self.srcCentroidKey = afwTable.Point2DKey(srcSchema["slot_Centroid"]) self.srcCentroidKey_xErr = srcSchema["slot_Centroid_xErr"].asKey() self.srcCentroidKey_yErr = srcSchema["slot_Centroid_yErr"].asKey() self.sourceCat = afwTable.SourceCatalog(srcSchema) self.matches = [] for i in np.linspace(0., rangePix, numPoints): for j in np.linspace(0., rangePix, numPoints): src = self.sourceCat.addNew() refObj = self.refCat.addNew() src.set(self.srcCentroidKey, lsst.geom.Point2D(i, j)) src.set(self.srcCentroidKey_xErr, 0.1) src.set(self.srcCentroidKey_yErr, 0.1) c = self.tanWcs.pixelToSky(i, j) refObj.setCoord(c) self.matches.append(self.MatchClass(refObj, src, 0.0))
def make_catalog(): schema = LoadReferenceObjectsTask.makeMinimalSchema(['r', 'z']) schema.addField('bad_flux', doc='old flux units', type=float, units='') schema.addField('bad_fluxErr', doc='old flux units', type=float, units='Jy') refCat = afwTable.SimpleCatalog(schema) refObj = refCat.addNew() refObj["bad_flux"] = flux refObj["bad_fluxErr"] = fluxErr return refCat
def make_fake_refcat(center, flux): """Make a fake reference catalog.""" filters = ['f1', 'f2'] schema = LoadReferenceObjectsTask.makeMinimalSchema(filters) catalog = lsst.afw.table.SimpleCatalog(schema) record = catalog.addNew() record.setCoord(center) record[filters[0] + '_flux'] = flux record[filters[0] + '_fluxErr'] = flux*0.1 record[filters[1] + '_flux'] = flux*10 record[filters[1] + '_fluxErr'] = flux*10*0.1 return catalog
def testCheckFluxUnits(self): """Test that we can identify old style fluxes in a schema.""" schema = LoadReferenceObjectsTask.makeMinimalSchema(['r', 'z']) # the default schema should pass self.assertTrue(hasNanojanskyFluxUnits(schema)) schema.addField('bad_fluxSigma', doc='old flux units', type=float, units='') self.assertFalse(hasNanojanskyFluxUnits(schema)) schema = LoadReferenceObjectsTask.makeMinimalSchema(['r', 'z']) schema.addField('bad_flux', doc='old flux units', type=float, units='') self.assertFalse(hasNanojanskyFluxUnits(schema)) schema = LoadReferenceObjectsTask.makeMinimalSchema(['r', 'z']) schema.addField('bad_flux', doc='old flux units', type=float, units='Jy') self.assertFalse(hasNanojanskyFluxUnits(schema)) schema = LoadReferenceObjectsTask.makeMinimalSchema(['r', 'z']) schema.addField('bad_fluxErr', doc='old flux units', type=float, units='') self.assertFalse(hasNanojanskyFluxUnits(schema)) schema = LoadReferenceObjectsTask.makeMinimalSchema(['r', 'z']) schema.addField('bad_fluxErr', doc='old flux units', type=float, units='Jy') self.assertFalse(hasNanojanskyFluxUnits(schema)) schema = LoadReferenceObjectsTask.makeMinimalSchema(['r', 'z']) schema.addField('bad_fluxSigma', doc='old flux units', type=float, units='') self.assertFalse(hasNanojanskyFluxUnits(schema))
def computePosRefCatalog(self, sourceCat): """Generate a position reference catalog from a source catalog """ minimalPosRefSchema = LoadReferenceObjectsTask.makeMinimalSchema(filterNameList=["r"]) refCat = afwTable.SimpleCatalog(minimalPosRefSchema) for source in sourceCat: refObj = refCat.addNew() refObj.setCoord(source.getCoord()) refObj.set("centroid_x", source.getX()) refObj.set("centroid_y", source.getY()) refObj.set("hasCentroid", True) refObj.set("r_flux", source.get("slot_ApFlux_instFlux")) refObj.set("r_fluxErr", source.get("slot_ApFlux_instFluxErr")) refObj.setId(source.getId()) return refCat
def computePosRefCatalog(self, sourceCat): """Generate a position reference catalog from a source catalog """ minimalPosRefSchema = LoadReferenceObjectsTask.makeMinimalSchema( filterNameList=["r"], addCentroid=True) refCat = afwTable.SimpleCatalog(minimalPosRefSchema) for source in sourceCat: refObj = refCat.addNew() refObj.setCoord(source.getCoord()) refObj.set("centroid_x", source.getX()) refObj.set("centroid_y", source.getY()) refObj.set("hasCentroid", True) refObj.set("r_flux", source.get("slot_ApFlux_instFlux")) refObj.set("r_fluxErr", source.get("slot_ApFlux_instFluxErr")) refObj.setId(source.getId()) return refCat
def setUp(self): crval = IcrsCoord(afwGeom.PointD(44., 45.)) crpix = afwGeom.PointD(0, 0) arcsecPerPixel = 1 / 3600.0 CD11 = arcsecPerPixel CD12 = 0 CD21 = 0 CD22 = arcsecPerPixel self.tanWcs = makeWcs(crval, crpix, CD11, CD12, CD21, CD22) S = 300 N = 5 if self.MatchClass == afwTable.ReferenceMatch: refSchema = LoadReferenceObjectsTask.makeMinimalSchema( filterNameList=["r"], addFluxSigma=True, addIsPhotometric=True) self.refCat = afwTable.SimpleCatalog(refSchema) elif self.MatchClass == afwTable.SourceMatch: refSchema = afwTable.SourceTable.makeMinimalSchema() self.refCat = afwTable.SourceCatalog(refSchema) else: raise RuntimeError("Unsupported MatchClass=%r" % (self.MatchClass, )) srcSchema = afwTable.SourceTable.makeMinimalSchema() SingleFrameMeasurementTask(schema=srcSchema) self.refCoordKey = afwTable.CoordKey(refSchema["coord"]) self.srcCoordKey = afwTable.CoordKey(srcSchema["coord"]) self.srcCentroidKey = afwTable.Point2DKey(srcSchema["slot_Centroid"]) self.sourceCat = afwTable.SourceCatalog(srcSchema) self.origSourceCat = afwTable.SourceCatalog( srcSchema) # undistorted copy self.matches = [] for i in np.linspace(0., S, N): for j in np.linspace(0., S, N): src = self.sourceCat.addNew() refObj = self.refCat.addNew() src.set(self.srcCentroidKey, afwGeom.Point2D(i, j)) c = self.tanWcs.pixelToSky(afwGeom.Point2D(i, j)) refObj.setCoord(c) self.matches.append(self.MatchClass(refObj, src, 0.0))
def loadData(self, rangePix=3000, numPoints=25): """Load catalogs and make the match list This is a separate function so data can be reloaded if fitting more than once (each time a WCS is fit it may update the source catalog, reference catalog and match list) """ if self.MatchClass == afwTable.ReferenceMatch: refSchema = LoadReferenceObjectsTask.makeMinimalSchema( filterNameList=["r"], addIsPhotometric=True, addCentroid=True) self.refCat = afwTable.SimpleCatalog(refSchema) elif self.MatchClass == afwTable.SourceMatch: refSchema = afwTable.SourceTable.makeMinimalSchema() self.refCat = afwTable.SourceCatalog(refSchema) else: raise RuntimeError("Unsupported MatchClass=%r" % (self.MatchClass, )) srcSchema = afwTable.SourceTable.makeMinimalSchema() SingleFrameMeasurementTask(schema=srcSchema) self.srcCoordKey = afwTable.CoordKey(srcSchema["coord"]) self.srcCentroidKey = afwTable.Point2DKey(srcSchema["slot_Centroid"]) self.srcCentroidKey_xErr = srcSchema["slot_Centroid_xErr"].asKey() self.srcCentroidKey_yErr = srcSchema["slot_Centroid_yErr"].asKey() self.sourceCat = afwTable.SourceCatalog(srcSchema) self.matches = [] for i in np.linspace(0., rangePix, numPoints): for j in np.linspace(0., rangePix, numPoints): src = self.sourceCat.addNew() refObj = self.refCat.addNew() src.set(self.srcCentroidKey, lsst.geom.Point2D(i, j)) src.set(self.srcCentroidKey_xErr, 0.1) src.set(self.srcCentroidKey_yErr, 0.1) c = self.tanWcs.pixelToSky(i, j) refObj.setCoord(c) if False: print( "x,y = (%.1f, %.1f) pixels -- RA,Dec = (%.3f, %.3f) deg" % (i, j, c.toFk5().getRa().asDegrees(), c.toFk5().getDec().asDegrees())) self.matches.append(self.MatchClass(refObj, src, 0.0))
def setUp(self): crval = afwGeom.SpherePoint(44, 45, afwGeom.degrees) crpix = afwGeom.PointD(0, 0) scale = 1 * afwGeom.arcseconds self.tanWcs = afwGeom.makeSkyWcs( crpix=crpix, crval=crval, cdMatrix=afwGeom.makeCdMatrix(scale=scale)) S = 300 N = 5 if self.MatchClass == afwTable.ReferenceMatch: refSchema = LoadReferenceObjectsTask.makeMinimalSchema( filterNameList=["r"], addFluxSigma=True, addIsPhotometric=True) self.refCat = afwTable.SimpleCatalog(refSchema) elif self.MatchClass == afwTable.SourceMatch: refSchema = afwTable.SourceTable.makeMinimalSchema() self.refCat = afwTable.SourceCatalog(refSchema) else: raise RuntimeError("Unsupported MatchClass=%r" % (self.MatchClass, )) srcSchema = afwTable.SourceTable.makeMinimalSchema() SingleFrameMeasurementTask(schema=srcSchema) self.refCoordKey = afwTable.CoordKey(refSchema["coord"]) self.srcCoordKey = afwTable.CoordKey(srcSchema["coord"]) self.srcCentroidKey = afwTable.Point2DKey(srcSchema["slot_Centroid"]) self.sourceCat = afwTable.SourceCatalog(srcSchema) self.origSourceCat = afwTable.SourceCatalog( srcSchema) # undistorted copy self.matches = [] for i in np.linspace(0., S, N): for j in np.linspace(0., S, N): src = self.sourceCat.addNew() refObj = self.refCat.addNew() src.set(self.srcCentroidKey, afwGeom.Point2D(i, j)) c = self.tanWcs.pixelToSky(afwGeom.Point2D(i, j)) refObj.setCoord(c) self.matches.append(self.MatchClass(refObj, src, 0.0))
def setUp(self): crval = afwCoord.IcrsCoord(afwGeom.PointD(44., 45.)) crpix = afwGeom.PointD(0, 0) arcsecPerPixel = 1/3600.0 CD11 = arcsecPerPixel CD12 = 0 CD21 = 0 CD22 = arcsecPerPixel self.tanWcs = afwImage.makeWcs(crval, crpix, CD11, CD12, CD21, CD22) S = 300 N = 5 if self.MatchClass == afwTable.ReferenceMatch: refSchema = LoadReferenceObjectsTask.makeMinimalSchema( filterNameList = ["r"], addFluxSigma=True, addIsPhotometric=True) self.refCat = afwTable.SimpleCatalog(refSchema) elif self.MatchClass == afwTable.SourceMatch: refSchema = afwTable.SourceTable.makeMinimalSchema() self.refCat = afwTable.SourceCatalog(refSchema) else: raise RuntimeError("Unsupported MatchClass=%r" % (self.MatchClass,)) srcSchema = afwTable.SourceTable.makeMinimalSchema() SingleFrameMeasurementTask(schema=srcSchema) self.refCoordKey = afwTable.CoordKey(refSchema["coord"]) self.srcCoordKey = afwTable.CoordKey(srcSchema["coord"]) self.srcCentroidKey = afwTable.Point2DKey(srcSchema["slot_Centroid"]) self.sourceCat = afwTable.SourceCatalog(srcSchema) self.origSourceCat = afwTable.SourceCatalog(srcSchema) # undistorted copy self.matches = [] for i in numpy.linspace(0., S, N): for j in numpy.linspace(0., S, N): src = self.sourceCat.addNew() refObj = self.refCat.addNew() src.set(self.srcCentroidKey, afwGeom.Point2D(i, j)) c = self.tanWcs.pixelToSky(afwGeom.Point2D(i, j)) refObj.setCoord(c) self.matches.append(self.MatchClass(refObj, src, 0.0))
def loadData(self, rangePix=3000, numPoints=25): """Load catalogs and make the match list This is a separate function so data can be reloaded if fitting more than once (each time a WCS is fit it may update the source catalog, reference catalog and match list) """ if self.MatchClass == afwTable.ReferenceMatch: refSchema = LoadReferenceObjectsTask.makeMinimalSchema( filterNameList = ["r"], addFluxSigma=True, addIsPhotometric=True) self.refCat = afwTable.SimpleCatalog(refSchema) elif self.MatchClass == afwTable.SourceMatch: refSchema = afwTable.SourceTable.makeMinimalSchema() self.refCat = afwTable.SourceCatalog(refSchema) else: raise RuntimeError("Unsupported MatchClass=%r" % (self.MatchClass,)) srcSchema = afwTable.SourceTable.makeMinimalSchema() SingleFrameMeasurementTask(schema=srcSchema) self.srcCoordKey = afwTable.CoordKey(srcSchema["coord"]) self.srcCentroidKey = afwTable.Point2DKey(srcSchema["slot_Centroid"]) self.srcCentroidKey_xSigma = srcSchema["slot_Centroid_xSigma"].asKey() self.srcCentroidKey_ySigma = srcSchema["slot_Centroid_ySigma"].asKey() self.sourceCat = afwTable.SourceCatalog(srcSchema) self.matches = [] for i in numpy.linspace(0., rangePix, numPoints): for j in numpy.linspace(0., rangePix, numPoints): src = self.sourceCat.addNew() refObj = self.refCat.addNew() src.set(self.srcCentroidKey, afwGeom.Point2D(i, j)) src.set(self.srcCentroidKey_xSigma, 0.1) src.set(self.srcCentroidKey_ySigma, 0.1) c = self.tanWcs.pixelToSky(afwGeom.Point2D(i, j)) refObj.setCoord(c) if False: print("x,y = (%.1f, %.1f) pixels -- RA,Dec = (%.3f, %.3f) deg" % \ (i, j, c.toFk5().getRa().asDegrees(), c.toFk5().getDec().asDegrees())) self.matches.append(self.MatchClass(refObj, src, 0.0))
def make_synthetic_refcat(self, center, flux): """Make a synthetic reference catalog.""" filters = ["ref1", "ref2", "ref3"] schema = LoadReferenceObjectsTask.makeMinimalSchema(filters) schema.addField('pm_ra', 'D') schema.addField('pm_dec', 'D') catalog = lsst.afw.table.SimpleCatalog(schema) record = catalog.addNew() record.setCoord(center) record[filters[0] + '_flux'] = flux record[filters[0] + '_fluxErr'] = flux * 0.1 record[filters[1] + '_flux'] = flux * 10 record[filters[1] + '_fluxErr'] = flux * 10 * 0.1 record[filters[2] + '_flux'] = flux * 100 record[filters[2] + '_fluxErr'] = flux * 100 * 0.1 record['pm_ra'] = 0.0 record['pm_dec'] = 0.0 return catalog
def setUp(self): crval = lsst.geom.SpherePoint(44, 45, lsst.geom.degrees) crpix = lsst.geom.PointD(0, 0) scale = 1 * lsst.geom.arcseconds self.tanWcs = afwGeom.makeSkyWcs(crpix=crpix, crval=crval, cdMatrix=afwGeom.makeCdMatrix(scale=scale)) S = 300 N = 5 if self.MatchClass == afwTable.ReferenceMatch: refSchema = LoadReferenceObjectsTask.makeMinimalSchema( filterNameList=["r"], addIsPhotometric=True) self.refCat = afwTable.SimpleCatalog(refSchema) elif self.MatchClass == afwTable.SourceMatch: refSchema = afwTable.SourceTable.makeMinimalSchema() self.refCat = afwTable.SourceCatalog(refSchema) else: raise RuntimeError("Unsupported MatchClass=%r" % (self.MatchClass,)) srcSchema = afwTable.SourceTable.makeMinimalSchema() SingleFrameMeasurementTask(schema=srcSchema) self.refCoordKey = afwTable.CoordKey(refSchema["coord"]) self.srcCoordKey = afwTable.CoordKey(srcSchema["coord"]) self.srcCentroidKey = afwTable.Point2DKey(srcSchema["slot_Centroid"]) self.sourceCat = afwTable.SourceCatalog(srcSchema) self.origSourceCat = afwTable.SourceCatalog(srcSchema) # undistorted copy self.matches = [] for i in np.linspace(0., S, N): for j in np.linspace(0., S, N): src = self.sourceCat.addNew() refObj = self.refCat.addNew() src.set(self.srcCentroidKey, lsst.geom.Point2D(i, j)) c = self.tanWcs.pixelToSky(lsst.geom.Point2D(i, j)) refObj.setCoord(c) self.matches.append(self.MatchClass(refObj, src, 0.0))
def testMakeMinimalSchema(self): """Make a schema and check it """ for filterNameList in (["r"], ["foo", "_bar"]): for addFluxSigma, addIsPhotometric, addIsResolved, addIsVariable in itertools.product( (False, True), (False, True), (False, True), (False, True)): refSchema = LoadReferenceObjectsTask.makeMinimalSchema( filterNameList = filterNameList, addFluxSigma = addFluxSigma, addIsPhotometric = addIsPhotometric, addIsResolved = addIsResolved, addIsVariable = addIsVariable, ) self.assertEqual("resolved" in refSchema, addIsResolved) self.assertEqual("variable" in refSchema, addIsVariable) self.assertEqual("photometric" in refSchema, addIsPhotometric) for filterName in filterNameList: fluxField = filterName + "_flux" self.assertIn(fluxField, refSchema) self.assertNotIn("x" + fluxField, refSchema) fluxSigmaField = fluxField + "Sigma" self.assertEqual(fluxSigmaField in refSchema, addFluxSigma) self.assertEqual(getRefFluxField(refSchema, filterName), filterName + "_flux")
def testMakeMinimalSchema(self): """Make a schema and check it.""" for filterNameList in (["r"], ["foo", "_bar"]): for addFluxSigma, addIsPhotometric, addIsResolved, addIsVariable in itertools.product( (False, True), (False, True), (False, True), (False, True)): refSchema = LoadReferenceObjectsTask.makeMinimalSchema( filterNameList=filterNameList, addFluxSigma=addFluxSigma, addIsPhotometric=addIsPhotometric, addIsResolved=addIsResolved, addIsVariable=addIsVariable, ) self.assertEqual("resolved" in refSchema, addIsResolved) self.assertEqual("variable" in refSchema, addIsVariable) self.assertEqual("photometric" in refSchema, addIsPhotometric) for filterName in filterNameList: fluxField = filterName + "_flux" self.assertIn(fluxField, refSchema) self.assertNotIn("x" + fluxField, refSchema) fluxSigmaField = fluxField + "Sigma" self.assertEqual(fluxSigmaField in refSchema, addFluxSigma) self.assertEqual(getRefFluxField(refSchema, filterName), filterName + "_flux")
def makeRefCatalog(self): schema = LoadReferenceObjectsTask.makeMinimalSchema(filterNameList=["g", "r"], addIsPhotometric=True, addIsResolved=True) catalog = afwTable.SimpleCatalog(schema) return catalog