def _checkDoRefcats(self, doAstrometry, doPhotoCal, ids): """Test whether run is called with the correct arguments. In the case of `CalibrateTask`, the inputs should not depend on the task configuration. Parameters ---------- doAstrometry, doPhotoCal : `bool` Values of the config flags of the same name. ids : `dict` [`str`] A mapping from the input dataset type to the data ID of the dataset to process. """ config = CalibrateConfig() config.doWriteMatches = False # no real output to write config.doAstrometry = doAstrometry config.doPhotoCal = doPhotoCal config.connections.photoRefCat = "cal_ref_cat" config.connections.astromRefCat = "cal_ref_cat" task = CalibrateTask(config=config) quantumId = ids["exposure"] quantum = testUtils.makeQuantum(task, self.butler, quantumId, ids) run = testUtils.runTestQuantum(task, self.butler, quantum) run.assert_called_once() self.assertEqual(run.call_args[0], ()) # Some arguments unprintable because we don't have a full environment # So just check which ones were passed in self.assertEqual( run.call_args[1].keys(), {"exposure", "exposureIdInfo", "background", "icSourceCat"})
def testGood(self): conf = CalibrateConfig() conf.validate() conf.doPhotoCal = False conf.validate() conf.doAstrometry = False conf.validate()
def testIsSinglePrimaryFlag(self): """Tests detect_isPrimary column gets added when run, and that sources labelled as detect_isPrimary are not sky sources and have no children. """ calibConfig = CalibrateConfig() calibConfig.doAstrometry = False calibConfig.doPhotoCal = False calibTask = CalibrateTask(config=calibConfig) calibResults = calibTask.run(self.charImResults.exposure) outputCat = calibResults.outputCat self.assertTrue("detect_isPrimary" in outputCat.schema.getNames()) # make sure all sky sources are flagged as not primary self.assertEqual( sum((outputCat["detect_isPrimary"]) & (outputCat["sky_source"])), 0) # make sure all parent sources are flagged as not primary self.assertEqual( sum((outputCat["detect_isPrimary"]) & (outputCat["deblend_nChild"] > 0)), 0) with self.assertRaises(KeyError): outputCat.getSchema().find("detect_isDelendedModelPrimary")
def testIsPrimaryFlag(self): """Tests detect_isPrimary column gets added when run, and that sources labelled as detect_isPrimary are not sky sources and have no children. """ charImConfig = CharacterizeImageConfig() charImTask = CharacterizeImageTask(config=charImConfig) charImResults = charImTask.run(self.exposure) calibConfig = CalibrateConfig() calibConfig.doAstrometry = False calibConfig.doPhotoCal = False calibTask = CalibrateTask(config=calibConfig) calibResults = calibTask.run(charImResults.exposure) outputCat = calibResults.outputCat self.assertTrue("detect_isPrimary" in outputCat.schema.getNames()) # make sure all sky sources are flagged as not primary self.assertEqual( sum((outputCat["detect_isPrimary"]) & (outputCat["sky_source"])), 0) # make sure all parent sources are flagged as not primary self.assertEqual( sum((outputCat["detect_isPrimary"]) & (outputCat["deblend_nChild"] > 0)), 0)
def _checkSkySourceColumnExistence(self, doSkySources): """Implements sky_source column checking. Parameters ---------- doSkySource : `bool` Value of the config flag determining whether to insert sky sources. """ charImConfig = CharacterizeImageConfig() charImConfig.measurePsf.psfDeterminer = 'piff' charImConfig.measurePsf.psfDeterminer['piff'].spatialOrder = 0 charImTask = CharacterizeImageTask(config=charImConfig) charImResults = charImTask.run(self.exposure) calibConfig = CalibrateConfig() calibConfig.doAstrometry = False calibConfig.doPhotoCal = False calibConfig.doSkySources = doSkySources calibTask = CalibrateTask(config=calibConfig) calibResults = calibTask.run(charImResults.exposure) if doSkySources: self.assertTrue('sky_source' in calibResults.outputCat.schema.getNames()) else: self.assertFalse('sky_source' in calibResults.outputCat.schema.getNames())