Skip to content

Commit

Permalink
Add SkySources to ImageDifferenceTask.
Browse files Browse the repository at this point in the history
Debug skySources codeblock.
  • Loading branch information
morriscb committed Jul 6, 2021
1 parent 1a9a513 commit d7f3e7a
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion python/lsst/pipe/tasks/imageDifference.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import lsst.afw.table as afwTable
from lsst.meas.astrom import AstrometryConfig, AstrometryTask
from lsst.meas.base import ForcedMeasurementTask, ApplyApCorrTask
from lsst.meas.algorithms import LoadIndexedReferenceObjectsTask
from lsst.meas.algorithms import LoadIndexedReferenceObjectsTask, SkyObjectsTask
from lsst.pipe.tasks.registerImage import RegisterTask
from lsst.pipe.tasks.scaleVariance import ScaleVarianceTask
from lsst.meas.algorithms import SourceDetectionTask, SingleGaussianPsf, ObjectSizeStarSelectorTask
Expand Down Expand Up @@ -318,6 +318,15 @@ class ImageDifferenceConfig(pipeBase.PipelineTaskConfig,
doc="Do not attempt to run task if template covers less than this fraction of pixels."
"Setting to 0 will always attempt image subtraction"
)
doSkySources = pexConfig.Field(
dtype=bool,
default=True,
doc="Generate sky sources?",
)
skySources = pexConfig.ConfigurableField(
target=SkyObjectsTask,
doc="Generate sky sources",
)

def setDefaults(self):
# defaults are OK for catalog and diacatalog
Expand Down Expand Up @@ -475,6 +484,9 @@ def __init__(self, butler=None, **kwargs):
if self.config.doMatchSources:
self.schema.addField("refMatchId", "L", "unique id of reference catalog match")
self.schema.addField("srcMatchId", "L", "unique id of source match")
if self.config.doSkySources:
self.makeSubtask("skySources")
self.skySourceKey = self.schema.addField("sky_source", type="Flag", doc="Sky objects.")

# initialize InitOutputs
self.outputSchema = afwTable.SourceCatalog(self.schema)
Expand Down Expand Up @@ -1002,6 +1014,16 @@ def run(self, exposure=None, selectSources=None, templateExposure=None, template
self.log.info("Merging detections into %d sources" % (len(diaSources)))
else:
diaSources = results.sources
# Inject skySources before measurement.
if self.config.doSkySources:
skySourceFootprints = self.skySources.run(
mask=detectionExposure.mask,
seed=detectionExposure.getInfo().getVisitInfo().getExposureId())
if skySourceFootprints:
for foot in skySourceFootprints:
s = diaSources.addNew()
s.setFootprint(foot)
s.set(self.skySourceKey, True)

if self.config.doMeasurement:
newDipoleFitting = self.config.doDipoleFitting
Expand Down

0 comments on commit d7f3e7a

Please sign in to comment.