LSSTApplications  17.0+10,17.0+52,17.0+91,18.0.0+11,18.0.0+16,18.0.0+38,18.0.0+4,18.0.0-2-ge43143a+8,18.1.0-1-g0001055+4,18.1.0-1-g1349e88+13,18.1.0-1-g2505f39+10,18.1.0-1-g380d4d4+13,18.1.0-1-g5315e5e,18.1.0-1-g5e4b7ea+4,18.1.0-1-g7e8fceb,18.1.0-1-g85f8cd4+10,18.1.0-1-g9a6769a+4,18.1.0-1-ga1a4c1a+9,18.1.0-1-gd55f500+5,18.1.0-1-ge10677a+10,18.1.0-11-gb2589d7b,18.1.0-13-g451e75588+2,18.1.0-13-gbfe7f7f+4,18.1.0-14-g2e73c10+1,18.1.0-2-g31c43f9+10,18.1.0-2-g919ecaf,18.1.0-2-g9c63283+13,18.1.0-2-gdf0b915+13,18.1.0-2-gfefb8b5+2,18.1.0-3-g52aa583+4,18.1.0-3-g8f4a2b1+4,18.1.0-3-g9cb968e+12,18.1.0-3-gab23065,18.1.0-4-g7bbbad0+4,18.1.0-5-g510c42a+12,18.1.0-5-gaeab27e+13,18.1.0-6-gc4bdb98+2,18.1.0-6-gdda7f3e+15,18.1.0-9-g9613d271+1,w.2019.34
LSSTDataManagementBasePackage
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
lsst.pipe.tasks.multiBand.DetectCoaddSourcesTask Class Reference

Detect sources on a coadd. More...

Inheritance diagram for lsst.pipe.tasks.multiBand.DetectCoaddSourcesTask:
lsst.pipe.tasks.dcrMultiBand.DetectDcrCoaddSources

Public Member Functions

def __init__ (self, schema=None, kwargs)
 Initialize the task. More...
 
def getInitOutputDatasets (self)
 
def runDataRef (self, patchRef)
 Run detection on a coadd. More...
 
def adaptArgsAndRun (self, inputData, inputDataIds, outputDataIds, butler)
 
def run (self, exposure, idFactory, expId)
 Run detection on an exposure. More...
 
def write (self, results, patchRef)
 Write out results from runDetection. More...
 

Public Attributes

 schema
 

Static Public Attributes

 ConfigClass = DetectCoaddSourcesConfig
 
 getSchemaCatalogs = _makeGetSchemaCatalogs("det")
 
 makeIdFactory = _makeMakeIdFactory("CoaddId")
 

Detailed Description

Detect sources on a coadd.

Contents

Description

Command-line task that detects sources on a coadd of exposures obtained with a single filter.

Coadding individual visits requires each exposure to be warped. This introduces covariance in the noise properties across pixels. Before detection, we correct the coadd variance by scaling the variance plane in the coadd to match the observed variance. This is an approximate approach – strictly, we should propagate the full covariance matrix – but it is simple and works well in practice.

After scaling the variance plane, we detect sources and generate footprints by delegating to the detection subtask.

Inputs:
deepCoadd{tract,patch,filter}: ExposureF
Outputs:
deepCoadd_det{tract,patch,filter}: SourceCatalog (only parent Footprints)
deepCoadd_calexp{tract,patch,filter}: Variance scaled, background-subtracted input exposure (ExposureF)
deepCoadd_calexp_background{tract,patch,filter}: BackgroundList
Data Unit:
tract, patch, filter

DetectCoaddSourcesTask delegates most of its work to the detection subtask. You can retarget this subtask if you wish.

Task initialization

Initialize the task. Create the detection subtask.

Keyword arguments (in addition to those forwarded to CmdLineTask.__init__):

Parameters
[in]schemainitial schema for the output catalog, modified-in place to include all fields set by this task. If None, the source minimal schema will be used.
[in]**kwargskeyword arguments to be passed to lsst.pipe.base.task.Task.__init__

Invoking the Task

Run detection on an exposure. First scale the variance plane to match the observed variance using ScaleVarianceTask. Then invoke the detection subtask to detect sources.

Parameters
[in,out]exposureExposure on which to detect (may be backround-subtracted and scaled, depending on configuration).
[in]idFactoryIdFactory to set source identifiers
[in]expIdExposure identifier (integer) for RNG seed
Returns
a pipe.base.Struct with fields
  • sources: catalog of detections
  • backgrounds: list of backgrounds

Configuration parameters

See DetectSourcesConfig

Debug variables

The command line task interface supports a flag -d to import debug.py from your PYTHONPATH; see Using lsstDebug to control debugging output for more about debug.py files.

DetectCoaddSourcesTask has no debug variables of its own because it relegates all the work to SourceDetectionTask; see the documetation for SourceDetectionTask for further information.

A complete example

of using DetectCoaddSourcesTask

DetectCoaddSourcesTask is meant to be run after assembling a coadded image in a given band. The purpose of the task is to update the background, detect all sources in a single band and generate a set of parent footprints. Subsequent tasks in the multi-band processing procedure will merge sources across bands and, eventually, perform forced photometry. Command-line usage of DetectCoaddSourcesTask expects a data reference to the coadd to be processed. A list of the available optional arguments can be obtained by calling detectCoaddSources.py with the --help command line argument:

detectCoaddSources.py --help

To demonstrate usage of the DetectCoaddSourcesTask in the larger context of multi-band processing, we will process HSC data in the ci_hsc package. Assuming one has followed steps 1 - 4 at pipeTasks_multiBand, one may detect all the sources in each coadd as follows:

detectCoaddSources.py $CI_HSC_DIR/DATA --id patch=5,4 tract=0 filter=HSC-I

that will process the HSC-I band data. The results are written to $CI_HSC_DIR/DATA/deepCoadd-results/HSC-I.

It is also necessary to run:

detectCoaddSources.py $CI_HSC_DIR/DATA --id patch=5,4 tract=0 filter=HSC-R

to generate the sources catalogs for the HSC-R band required by the next step in the multi-band processing procedure: MergeDetectionsTask.

Definition at line 144 of file multiBand.py.

Constructor & Destructor Documentation

◆ __init__()

def lsst.pipe.tasks.multiBand.DetectCoaddSourcesTask.__init__ (   self,
  schema = None,
  kwargs 
)

Initialize the task.

Create the detection subtask.

Keyword arguments (in addition to those forwarded to CmdLineTask.__init__):

Parameters
[in]schemainitial schema for the output catalog, modified-in place to include all fields set by this task. If None, the source minimal schema will be used.
[in]**kwargskeyword arguments to be passed to lsst.pipe.base.task.Task.__init__

Definition at line 247 of file multiBand.py.

247  def __init__(self, schema=None, **kwargs):
248  """!
249  @brief Initialize the task. Create the @ref SourceDetectionTask_ "detection" subtask.
250 
251  Keyword arguments (in addition to those forwarded to CmdLineTask.__init__):
252 
253  @param[in] schema: initial schema for the output catalog, modified-in place to include all
254  fields set by this task. If None, the source minimal schema will be used.
255  @param[in] **kwargs: keyword arguments to be passed to lsst.pipe.base.task.Task.__init__
256  """
257  # N.B. Super is used here to handle the multiple inheritance of PipelineTasks, the init tree
258  # call structure has been reviewed carefully to be sure super will work as intended.
259  super().__init__(**kwargs)
260  if schema is None:
261  schema = afwTable.SourceTable.makeMinimalSchema()
262  if self.config.doInsertFakes:
263  self.makeSubtask("insertFakes")
264  self.schema = schema
265  self.makeSubtask("detection", schema=self.schema)
266  if self.config.doScaleVariance:
267  self.makeSubtask("scaleVariance")
268 
def __init__(self, minimum, dataRange, Q)

Member Function Documentation

◆ adaptArgsAndRun()

def lsst.pipe.tasks.multiBand.DetectCoaddSourcesTask.adaptArgsAndRun (   self,
  inputData,
  inputDataIds,
  outputDataIds,
  butler 
)

Definition at line 290 of file multiBand.py.

290  def adaptArgsAndRun(self, inputData, inputDataIds, outputDataIds, butler):
291  packedId, maxBits = butler.registry.packDataId("tract_patch_abstract_filter",
292  inputDataIds["exposure"],
293  returnMaxBits=True)
294  inputData["idFactory"] = afwTable.IdFactory.makeSource(packedId, 64 - maxBits)
295  inputData["expId"] = packedId
296  return self.run(**inputData)
297 

◆ getInitOutputDatasets()

def lsst.pipe.tasks.multiBand.DetectCoaddSourcesTask.getInitOutputDatasets (   self)

Definition at line 269 of file multiBand.py.

269  def getInitOutputDatasets(self):
270  return {"detectionSchema": afwTable.SourceCatalog(self.schema)}
271 

◆ run()

def lsst.pipe.tasks.multiBand.DetectCoaddSourcesTask.run (   self,
  exposure,
  idFactory,
  expId 
)

Run detection on an exposure.

First scale the variance plane to match the observed variance using ScaleVarianceTask. Then invoke the detection subtask to detect sources.

Parameters
[in,out]exposureExposure on which to detect (may be backround-subtracted and scaled, depending on configuration).
[in]idFactoryIdFactory to set source identifiers
[in]expIdExposure identifier (integer) for RNG seed
Returns
a pipe.base.Struct with fields
  • sources: catalog of detections
  • backgrounds: list of backgrounds

Definition at line 298 of file multiBand.py.

298  def run(self, exposure, idFactory, expId):
299  """!
300  @brief Run detection on an exposure.
301 
302  First scale the variance plane to match the observed variance
303  using @ref ScaleVarianceTask. Then invoke the @ref SourceDetectionTask_ "detection" subtask to
304  detect sources.
305 
306  @param[in,out] exposure: Exposure on which to detect (may be backround-subtracted and scaled,
307  depending on configuration).
308  @param[in] idFactory: IdFactory to set source identifiers
309  @param[in] expId: Exposure identifier (integer) for RNG seed
310 
311  @return a pipe.base.Struct with fields
312  - sources: catalog of detections
313  - backgrounds: list of backgrounds
314  """
315  if self.config.doScaleVariance:
316  varScale = self.scaleVariance.run(exposure.maskedImage)
317  exposure.getMetadata().add("variance_scale", varScale)
318  backgrounds = afwMath.BackgroundList()
319  if self.config.doInsertFakes:
320  self.insertFakes.run(exposure, background=backgrounds)
321  table = afwTable.SourceTable.make(self.schema, idFactory)
322  detections = self.detection.makeSourceCatalog(table, exposure, expId=expId)
323  sources = detections.sources
324  fpSets = detections.fpSets
325  if hasattr(fpSets, "background") and fpSets.background:
326  for bg in fpSets.background:
327  backgrounds.append(bg)
328  return Struct(outputSources=sources, outputBackgrounds=backgrounds, outputExposure=exposure)
329 

◆ runDataRef()

def lsst.pipe.tasks.multiBand.DetectCoaddSourcesTask.runDataRef (   self,
  patchRef 
)

Run detection on a coadd.

Invokes run and then uses write to output the results.

Parameters
[in]patchRefdata reference for patch

Definition at line 272 of file multiBand.py.

272  def runDataRef(self, patchRef):
273  """!
274  @brief Run detection on a coadd.
275 
276  Invokes @ref run and then uses @ref write to output the
277  results.
278 
279  @param[in] patchRef: data reference for patch
280  """
281  if self.config.hasFakes:
282  exposure = patchRef.get("fakes_" + self.config.coaddName + "Coadd", immediate=True)
283  else:
284  exposure = patchRef.get(self.config.coaddName + "Coadd", immediate=True)
285  expId = int(patchRef.get(self.config.coaddName + "CoaddId"))
286  results = self.run(exposure, self.makeIdFactory(patchRef), expId=expId)
287  self.write(results, patchRef)
288  return results
289 

◆ write()

def lsst.pipe.tasks.multiBand.DetectCoaddSourcesTask.write (   self,
  results,
  patchRef 
)

Write out results from runDetection.

Parameters
[in]exposureExposure to write out
[in]resultsStruct returned from runDetection
[in]patchRefdata reference for patch

Definition at line 330 of file multiBand.py.

330  def write(self, results, patchRef):
331  """!
332  @brief Write out results from runDetection.
333 
334  @param[in] exposure: Exposure to write out
335  @param[in] results: Struct returned from runDetection
336  @param[in] patchRef: data reference for patch
337  """
338  coaddName = self.config.coaddName + "Coadd"
339  patchRef.put(results.outputBackgrounds, coaddName + "_calexp_background")
340  patchRef.put(results.outputSources, coaddName + "_det")
341  if self.config.hasFakes:
342  patchRef.put(results.outputExposure, "fakes_" + coaddName + "_calexp")
343  else:
344  patchRef.put(results.outputExposure, coaddName + "_calexp")
345 

Member Data Documentation

◆ ConfigClass

lsst.pipe.tasks.multiBand.DetectCoaddSourcesTask.ConfigClass = DetectCoaddSourcesConfig
static

Definition at line 236 of file multiBand.py.

◆ getSchemaCatalogs

lsst.pipe.tasks.multiBand.DetectCoaddSourcesTask.getSchemaCatalogs = _makeGetSchemaCatalogs("det")
static

Definition at line 237 of file multiBand.py.

◆ makeIdFactory

lsst.pipe.tasks.multiBand.DetectCoaddSourcesTask.makeIdFactory = _makeMakeIdFactory("CoaddId")
static

Definition at line 238 of file multiBand.py.

◆ schema

lsst.pipe.tasks.multiBand.DetectCoaddSourcesTask.schema

Definition at line 264 of file multiBand.py.


The documentation for this class was generated from the following file: