Running source detection/deblend/measurement on coadds

Hi all,

I want to run source detection/deblending/measurement on coadds, as is done in calibrate.py and the pipeline definition from ProcessCcd.yaml in ap_pipe. I’ve tried making a new pipeline definition file that excludes some of the steps of the CalibrateTask:

description: Coaddition Sources
instrument: lsst.obs.decam.DarkEnergyCamera
tasks:  
  calibrate: 
    class: lsst.pipe.tasks.calibrate.CalibrateTask
    config:
      doAstrometry: false
      doPhotoCal: false 
      doWriteMatches: false
      doWriteMatchesDenormalized: false
      doWriteExposure: false
      connections.exposure: "goodSeeingCoadd"
      connections.outputCat: "goodSeeingCoadd_src"

This doesn’t work however; the stack complains that the dimensions of the input exposures aren’t what is expected: ValueError: Supplied dataset type (DatasetType('goodSeeingCoadd', {band, instrument, detector, physical_filter, visit_system, visit}, ExposureF)) inconsistent with registry definition (DatasetType('goodSeeingCoadd', {band, skymap, tract, patch}, ExposureF)) for calibrate. This makes sense to me since coadds are defined differently from CCD exposures. So that rules out using the calibrate task.

I can do source detection in a notebook (my reference is the notebooks/tutorial-notebooks/05_Intro_to_Source_Detection.ipynb notebook from the Rubin Science Platform), something like:

schema = afwTable.SourceTable.makeMinimalSchema()
# Characterize the image properties
config = CharacterizeImageTask.ConfigClass()
config.psfIterations = 1
charImageTask = CharacterizeImageTask(config=config)

# Detect sources
config = SourceDetectionTask.ConfigClass()
# detection threshold in units of thresholdType
config.thresholdValue = 10
# units for thresholdValue
config.thresholdType = "stdev"
sourceDetectionTask = SourceDetectionTask(schema=schema, config=config)

# Deblend sources
sourceDeblendTask = SourceDeblendTask(schema=schema)

# Measure source properties
config = SingleFrameMeasurementTask.ConfigClass()
sourceMeasurementTask = SingleFrameMeasurementTask(schema=schema,
                                                   config=config,
                                                   algMetadata=algMetadata)
result = sourceDetectionTask.run(tab, coadd)
sources = result.sources
# Source deblending
sourceDeblendTask.run(coadd, sources)

# Source measurement (catch future warning about machine precision)
sourceMeasurementTask.run(measCat=sources, exposure=coadd)
sources = sources.copy(True)

image = cutout.image

fig = plt.figure()
afw_display = afwDisplay.Display(frame=fig)
afw_display.scale('asinh', 'zscale')
afw_display.mtv(image)
plt.gca().axis('off')

# We use display buffering to avoid re-drawing the image
#  after each source is plotted
with afw_display.Buffering():
    for s in sources:
        afw_display.dot('+', s.getX(), s.getY(), ctype=afwDisplay.RED)
        afw_display.dot('o', s.getX(), s.getY(), size=20, ctype='orange')

gives me what I’m looking for:
image

So I’m just wondering if anyone has pointers for doing this in a pipeline task so I can do pipetask run instead of using a notebook. Is there an alternative pre-made pipeline task that will do source detection on a coadd? Or should I go about making one myself?

Thanks,
Steven Stetzler

The pipelines you’re looking for are in “step3” of DRP; see detection, mergeDetections, deblend, measure et al in DRP.yaml.

1 Like

Awesome, thanks Colin!