Coverage for tests/test_diaCatalogSourceSelector.py : 21%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# # LSST Data Management System # Copyright 2008-2016 LSST Corporation. # # This product includes software developed by the # LSST Project (http://www.lsst.org/). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the LSST License Statement and # the GNU General Public License along with this program. If not, # see <http://www.lsstcorp.org/LegalNotices/>. #
schema = afwTable.SourceTable.makeMinimalSchema() schema.addField("test_instFlux", type=float) schema.addField("test_instFluxErr", type=float) self.sourceSelector = ipDiffim.DiaCatalogSourceSelectorTask() for flag in self.sourceSelector.config.badFlags: schema.addField(flag, type="Flag") table = afwTable.SourceTable.make(schema) table.definePsfFlux("test") self.srcCat = afwTable.SourceCatalog(table) self.exposure = afwImage.ExposureF()
del self.sourceSelector del self.exposure del self.srcCat
schema = LoadReferenceObjectsTask.makeMinimalSchema(filterNameList=["g", "r"], addFluxErr=False, addIsPhotometric=True, addIsResolved=True) catalog = afwTable.SimpleCatalog(schema) return catalog
for i in range(nSrc):
refSrc = refCat.addNew() srcSrc = srcCat.addNew()
raDeg, decDeg = np.random.randn(2) coord = afwGeom.SpherePoint(raDeg, decDeg, afwGeom.degrees)
refSrc.set("g_flux", 10**(-0.4*18)) refSrc.set("r_flux", 10**(-0.4*18)) refSrc.set("resolved", False) refSrc.set("photometric", True) refSrc.setCoord(coord)
srcSrc.setCoord(coord) srcSrc.set("slot_PsfFlux_instFlux", 10.) srcSrc.set("slot_PsfFlux_instFluxErr", 1.) for flag in self.sourceSelector.config.badFlags: srcSrc.set(flag, False)
mc = afwTable.MatchControl() mc.symmetricMatch = False mat = afwTable.matchRaDec(refCat, srcCat, 1.0 * afwGeom.arcseconds, mc) self.assertEqual(len(mat), nSrc) return mat
nSrc = 5
refCat = self.makeRefCatalog()
matches = self.makeMatches(refCat, self.srcCat, nSrc) sources = self.sourceSelector.run(self.srcCat, matches=matches, exposure=self.exposure).sourceCat self.assertEqual(len(sources), nSrc)
# Set one of the source flags to be bad matches[0].second.set(self.sourceSelector.config.badFlags[0], True) sources = self.sourceSelector.run(self.srcCat, matches=matches, exposure=self.exposure).sourceCat self.assertEqual(len(sources), nSrc-1)
# Set one of the ref flags to be bad matches[1].first.set("photometric", False) sources = self.sourceSelector.run(self.srcCat, matches=matches, exposure=self.exposure).sourceCat self.assertEqual(len(sources), nSrc-2)
# Set one of the colors to be bad grMin = self.sourceSelector.config.grMin rFluxField = getRefFluxField(refCat.schema, "r") gFluxField = getRefFluxField(refCat.schema, "g") gFlux = 10**(-0.4 * (grMin - 0.1)) * matches[2].first.get(rFluxField) matches[2].first.set(gFluxField, gFlux) sources = self.sourceSelector.run(self.srcCat, matches=matches, exposure=self.exposure).sourceCat self.assertEqual(len(sources), nSrc-3)
# Set one of the types to be bad if self.sourceSelector.config.selectStar and not self.sourceSelector.config.selectGalaxy: matches[3].first.set("resolved", True) sources = self.sourceSelector.run(self.srcCat, matches=matches, exposure=self.exposure).sourceCat self.assertEqual(len(sources), nSrc-4)
lsst.utils.tests.init()
lsst.utils.tests.init() unittest.main() |