Skip to content

Commit

Permalink
Add fake object hooks to DetectCoaddSources
Browse files Browse the repository at this point in the history
Create the ability to run a fake object task from within the task
to detect sources on coadds. This is useful when starting from
single frames which have already been processed.
  • Loading branch information
natelust committed May 25, 2017
1 parent f1ee02b commit 4282bf6
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion python/lsst/pipe/tasks/multiBand.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#!/usr/bin/env python
#
# LSST Data Management System
Expand Down Expand Up @@ -34,6 +33,7 @@
from lsst.meas.deblender import SourceDeblendTask
from lsst.pipe.tasks.coaddBase import getSkyInfo, scaleVariance
from lsst.meas.astrom import DirectMatchTask, denormalizeMatches
from lsst.pipe.tasks.fakes import BaseFakeSourcesTask
from lsst.pipe.tasks.setPrimaryFlags import SetPrimaryFlagsTask
from lsst.pipe.tasks.propagateVisitFlags import PropagateVisitFlagsTask
import lsst.afw.image as afwImage
Expand Down Expand Up @@ -117,6 +117,11 @@ class DetectCoaddSourcesConfig(Config):
coaddName = Field(dtype=str, default="deep", doc="Name of coadd")
mask = ListField(dtype=str, default=["DETECTED", "BAD", "SAT", "NO_DATA", "INTRP"],
doc="Mask planes for pixels to ignore when scaling variance")
doInsertFakes = Field(dtype=bool, default=False,
doc="Run fake sources injection task")
insertFakes = ConfigurableField(target=BaseFakeSourcesTask,
doc="Injection of fake sources for testing "
"purposes (must be retargeted)")

def setDefaults(self):
Config.setDefaults(self)
Expand Down Expand Up @@ -250,6 +255,8 @@ def __init__(self, schema=None, **kwargs):
CmdLineTask.__init__(self, **kwargs)
if schema is None:
schema = afwTable.SourceTable.makeMinimalSchema()
if self.config.doInsertFakes:
self.makeSubtask("insertFakes")
self.schema = schema
self.makeSubtask("detection", schema=self.schema)

Expand Down Expand Up @@ -285,6 +292,8 @@ def runDetection(self, exposure, idFactory):
if self.config.doScaleVariance:
scaleVariance(exposure.getMaskedImage(), self.config.mask, log=self.log)
backgrounds = afwMath.BackgroundList()
if self.config.doInsertFakes:
self.insertFakes.run(exposure, background=backgrounds)
table = afwTable.SourceTable.make(self.schema, idFactory)
detections = self.detection.makeSourceCatalog(table, exposure)
sources = detections.sources
Expand Down

0 comments on commit 4282bf6

Please sign in to comment.