22__all__ = [
"DetectCoaddSourcesConfig",
"DetectCoaddSourcesTask"]
24from lsst.pipe.base
import (Struct, PipelineTask, PipelineTaskConfig, PipelineTaskConnections)
25import lsst.pipe.base.connectionTypes
as cT
29 SingleFrameMeasurementTask,
31 CatalogCalculationTask,
32 SkyMapIdGeneratorConfig,
43from .mergeDetections
import MergeDetectionsConfig, MergeDetectionsTask
44from .mergeMeasurements
import MergeMeasurementsConfig, MergeMeasurementsTask
45from .multiBandUtils
import CullPeaksConfig
46from .deblendCoaddSourcesPipeline
import DeblendCoaddSourcesSingleConfig
47from .deblendCoaddSourcesPipeline
import DeblendCoaddSourcesSingleTask
48from .deblendCoaddSourcesPipeline
import DeblendCoaddSourcesMultiConfig
49from .deblendCoaddSourcesPipeline
import DeblendCoaddSourcesMultiTask
54* deepCoadd_det: detections from what used to be processCoadd (tract, patch, filter)
55* deepCoadd_mergeDet: merged detections (tract, patch)
56* deepCoadd_meas: measurements of merged detections (tract, patch, filter)
57* deepCoadd_ref: reference sources (tract, patch)
58All of these have associated *_schema catalogs that require no data ID and hold no records.
60In addition, we have a schema-only dataset, which saves the schema for the PeakRecords in
61the mergeDet, meas, and ref dataset Footprints:
62* deepCoadd_peak_schema
68 dimensions=(
"tract",
"patch",
"band",
"skymap"),
69 defaultTemplates={
"inputCoaddName":
"deep",
"outputCoaddName":
"deep"}):
70 detectionSchema = cT.InitOutput(
71 doc=
"Schema of the detection catalog",
72 name=
"{outputCoaddName}Coadd_det_schema",
73 storageClass=
"SourceCatalog",
76 doc=
"Exposure on which detections are to be performed",
77 name=
"{inputCoaddName}Coadd",
78 storageClass=
"ExposureF",
79 dimensions=(
"tract",
"patch",
"band",
"skymap")
81 outputBackgrounds = cT.Output(
82 doc=
"Output Backgrounds used in detection",
83 name=
"{outputCoaddName}Coadd_calexp_background",
84 storageClass=
"Background",
85 dimensions=(
"tract",
"patch",
"band",
"skymap")
87 outputSources = cT.Output(
88 doc=
"Detected sources catalog",
89 name=
"{outputCoaddName}Coadd_det",
90 storageClass=
"SourceCatalog",
91 dimensions=(
"tract",
"patch",
"band",
"skymap")
93 outputExposure = cT.Output(
94 doc=
"Exposure post detection",
95 name=
"{outputCoaddName}Coadd_calexp",
96 storageClass=
"ExposureF",
97 dimensions=(
"tract",
"patch",
"band",
"skymap")
101class DetectCoaddSourcesConfig(PipelineTaskConfig, pipelineConnections=DetectCoaddSourcesConnections):
102 """Configuration parameters for the DetectCoaddSourcesTask
105 doScaleVariance = Field(dtype=bool, default=True, doc=
"Scale variance plane using empirical noise?")
106 scaleVariance = ConfigurableField(target=ScaleVarianceTask, doc=
"Variance rescaling")
107 detection = ConfigurableField(target=DynamicDetectionTask, doc=
"Source detection")
108 coaddName = Field(dtype=str, default=
"deep", doc=
"Name of coadd")
112 doc=
"Should be set to True if fake sources have been inserted into the input data.",
114 idGenerator = SkyMapIdGeneratorConfig.make_field()
116 def setDefaults(self):
117 super().setDefaults()
118 self.detection.thresholdType =
"pixel_stdev"
119 self.detection.isotropicGrow =
True
121 self.detection.reEstimateBackground =
False
122 self.detection.background.useApprox =
False
123 self.detection.background.binSize = 4096
124 self.detection.background.undersampleStyle =
'REDUCE_INTERP_ORDER'
125 self.detection.doTempWideBackground =
True
128 self.idGenerator.packer.n_bands =
None
131class DetectCoaddSourcesTask(PipelineTask):
132 """Detect sources on a single filter coadd.
134 Coadding individual visits requires each exposure to be warped. This
135 introduces covariance in the noise properties across pixels. Before
136 detection, we correct the coadd variance by scaling the variance plane
in
137 the coadd to match the observed variance. This
is an approximate
138 approach -- strictly, we should propagate the full covariance matrix --
139 but it
is simple
and works well
in practice.
141 After scaling the variance plane, we detect sources
and generate footprints
142 by delegating to the
@ref SourceDetectionTask_
"detection" subtask.
144 DetectCoaddSourcesTask
is meant to be run after assembling a coadded image
145 in a given band. The purpose of the task
is to update the background,
146 detect all sources
in a single band
and generate a set of parent
147 footprints. Subsequent tasks
in the multi-band processing procedure will
148 merge sources across bands
and, eventually, perform forced photometry.
153 Initial schema
for the output catalog, modified-
in place to include all
154 fields set by this task. If
None, the source minimal schema will be used.
156 Additional keyword arguments.
159 _DefaultName = "detectCoaddSources"
160 ConfigClass = DetectCoaddSourcesConfig
162 def __init__(self, schema=None, **kwargs):
165 super().__init__(**kwargs)
167 schema = afwTable.SourceTable.makeMinimalSchema()
169 self.makeSubtask(
"detection", schema=self.schema)
170 if self.config.doScaleVariance:
171 self.makeSubtask(
"scaleVariance")
173 self.detectionSchema = afwTable.SourceCatalog(self.schema)
175 def runQuantum(self, butlerQC, inputRefs, outputRefs):
176 inputs = butlerQC.get(inputRefs)
177 idGenerator = self.config.idGenerator.apply(butlerQC.quantum.dataId)
178 inputs[
"idFactory"] = idGenerator.make_table_id_factory()
179 inputs[
"expId"] = idGenerator.catalog_id
180 outputs = self.run(**inputs)
181 butlerQC.put(outputs, outputRefs)
183 def run(self, exposure, idFactory, expId):
184 """Run detection on an exposure.
186 First scale the variance plane to match the observed variance
187 using ``ScaleVarianceTask``. Then invoke the ``SourceDetectionTask_`` "detection" subtask to
193 Exposure on which to detect (may be backround-subtracted
and scaled,
194 depending on configuration).
196 IdFactory to set source identifiers.
198 Exposure identifier (integer)
for RNG seed.
202 result : `lsst.pipe.base.Struct`
203 Results
as a struct
with attributes:
208 List of backgrounds (`list`).
210 if self.config.doScaleVariance:
211 varScale = self.scaleVariance.run(exposure.maskedImage)
212 exposure.getMetadata().add(
"VARIANCE_SCALE", varScale)
213 backgrounds = afwMath.BackgroundList()
214 table = afwTable.SourceTable.make(self.schema, idFactory)
215 detections = self.detection.run(table, exposure, expId=expId)
216 sources = detections.sources
217 if hasattr(detections,
"background")
and detections.background:
218 for bg
in detections.background:
219 backgrounds.append(bg)
220 return Struct(outputSources=sources, outputBackgrounds=backgrounds, outputExposure=exposure)
223class MeasureMergedCoaddSourcesConnections(PipelineTaskConnections,
224 dimensions=(
"tract",
"patch",
"band",
"skymap"),
225 defaultTemplates={
"inputCoaddName":
"deep",
226 "outputCoaddName":
"deep",
227 "deblendedCatalog":
"deblendedFlux"}):
228 inputSchema = cT.InitInput(
229 doc=
"Input schema for measure merged task produced by a deblender or detection task",
230 name=
"{inputCoaddName}Coadd_deblendedFlux_schema",
231 storageClass=
"SourceCatalog"
233 outputSchema = cT.InitOutput(
234 doc=
"Output schema after all new fields are added by task",
235 name=
"{inputCoaddName}Coadd_meas_schema",
236 storageClass=
"SourceCatalog"
238 refCat = cT.PrerequisiteInput(
239 doc=
"Reference catalog used to match measured sources against known sources",
241 storageClass=
"SimpleCatalog",
242 dimensions=(
"skypix",),
247 doc=
"Input coadd image",
248 name=
"{inputCoaddName}Coadd_calexp",
249 storageClass=
"ExposureF",
250 dimensions=(
"tract",
"patch",
"band",
"skymap")
253 doc=
"SkyMap to use in processing",
254 name=BaseSkyMap.SKYMAP_DATASET_TYPE_NAME,
255 storageClass=
"SkyMap",
256 dimensions=(
"skymap",),
258 visitCatalogs = cT.Input(
259 doc=
"Source catalogs for visits which overlap input tract, patch, band. Will be "
260 "further filtered in the task for the purpose of propagating flags from image calibration "
261 "and characterization to coadd objects. Only used in legacy PropagateVisitFlagsTask.",
263 dimensions=(
"instrument",
"visit",
"detector"),
264 storageClass=
"SourceCatalog",
267 sourceTableHandles = cT.Input(
268 doc=(
"Source tables that are derived from the ``CalibrateTask`` sources. "
269 "These tables contain astrometry and photometry flags, and optionally "
271 name=
"sourceTable_visit",
272 storageClass=
"DataFrame",
273 dimensions=(
"instrument",
"visit"),
277 finalizedSourceTableHandles = cT.Input(
278 doc=(
"Finalized source tables from ``FinalizeCalibrationTask``. These "
279 "tables contain PSF flags from the finalized PSF estimation."),
280 name=
"finalized_src_table",
281 storageClass=
"DataFrame",
282 dimensions=(
"instrument",
"visit"),
286 inputCatalog = cT.Input(
287 doc=(
"Name of the input catalog to use."
288 "If the single band deblender was used this should be 'deblendedFlux."
289 "If the multi-band deblender was used this should be 'deblendedModel, "
290 "or deblendedFlux if the multiband deblender was configured to output "
291 "deblended flux catalogs. If no deblending was performed this should "
293 name=
"{inputCoaddName}Coadd_{deblendedCatalog}",
294 storageClass=
"SourceCatalog",
295 dimensions=(
"tract",
"patch",
"band",
"skymap"),
297 scarletCatalog = cT.Input(
298 doc=
"Catalogs produced by multiband deblending",
299 name=
"{inputCoaddName}Coadd_deblendedCatalog",
300 storageClass=
"SourceCatalog",
301 dimensions=(
"tract",
"patch",
"skymap"),
303 scarletModels = cT.Input(
304 doc=
"Multiband scarlet models produced by the deblender",
305 name=
"{inputCoaddName}Coadd_scarletModelData",
306 storageClass=
"ScarletModelData",
307 dimensions=(
"tract",
"patch",
"skymap"),
309 outputSources = cT.Output(
310 doc=
"Source catalog containing all the measurement information generated in this task",
311 name=
"{outputCoaddName}Coadd_meas",
312 dimensions=(
"tract",
"patch",
"band",
"skymap"),
313 storageClass=
"SourceCatalog",
315 matchResult = cT.Output(
316 doc=
"Match catalog produced by configured matcher, optional on doMatchSources",
317 name=
"{outputCoaddName}Coadd_measMatch",
318 dimensions=(
"tract",
"patch",
"band",
"skymap"),
319 storageClass=
"Catalog",
321 denormMatches = cT.Output(
322 doc=
"Denormalized Match catalog produced by configured matcher, optional on "
323 "doWriteMatchesDenormalized",
324 name=
"{outputCoaddName}Coadd_measMatchFull",
325 dimensions=(
"tract",
"patch",
"band",
"skymap"),
326 storageClass=
"Catalog",
329 def __init__(self, *, config=None):
330 super().__init__(config=config)
331 if config.doPropagateFlags
is False:
332 self.inputs -= set((
"visitCatalogs",))
333 self.inputs -= set((
"sourceTableHandles",))
334 self.inputs -= set((
"finalizedSourceTableHandles",))
335 elif config.propagateFlags.target == PropagateSourceFlagsTask:
337 self.inputs -= set((
"visitCatalogs",))
339 if not config.propagateFlags.source_flags:
340 self.inputs -= set((
"sourceTableHandles",))
341 if not config.propagateFlags.finalized_source_flags:
342 self.inputs -= set((
"finalizedSourceTableHandles",))
345 self.inputs -= set((
"sourceTableHandles",))
346 self.inputs -= set((
"finalizedSourceTableHandles",))
348 if config.inputCatalog ==
"deblendedCatalog":
349 self.inputs -= set((
"inputCatalog",))
351 if not config.doAddFootprints:
352 self.inputs -= set((
"scarletModels",))
354 self.inputs -= set((
"deblendedCatalog"))
355 self.inputs -= set((
"scarletModels",))
357 if config.doMatchSources
is False:
358 self.outputs -= set((
"matchResult",))
360 if config.doWriteMatchesDenormalized
is False:
361 self.outputs -= set((
"denormMatches",))
364class MeasureMergedCoaddSourcesConfig(PipelineTaskConfig,
365 pipelineConnections=MeasureMergedCoaddSourcesConnections):
366 """Configuration parameters for the MeasureMergedCoaddSourcesTask
368 inputCatalog = ChoiceField(
370 default="deblendedCatalog",
372 "deblendedCatalog":
"Output catalog from ScarletDeblendTask",
373 "deblendedFlux":
"Output catalog from SourceDeblendTask",
374 "mergeDet":
"The merged detections before deblending."
376 doc=
"The name of the input catalog.",
378 doAddFootprints = Field(dtype=bool,
380 doc=
"Whether or not to add footprints to the input catalog from scarlet models. "
381 "This should be true whenever using the multi-band deblender, "
382 "otherwise this should be False.")
383 doConserveFlux = Field(dtype=bool, default=
True,
384 doc=
"Whether to use the deblender models as templates to re-distribute the flux "
385 "from the 'exposure' (True), or to perform measurements on the deblender "
387 doStripFootprints = Field(dtype=bool, default=
True,
388 doc=
"Whether to strip footprints from the output catalog before "
390 "This is usually done when using scarlet models to save disk space.")
391 measurement = ConfigurableField(target=SingleFrameMeasurementTask, doc=
"Source measurement")
392 setPrimaryFlags = ConfigurableField(target=SetPrimaryFlagsTask, doc=
"Set flags for primary tract/patch")
393 doPropagateFlags = Field(
394 dtype=bool, default=
True,
395 doc=
"Whether to match sources to CCD catalogs to propagate flags (to e.g. identify PSF stars)"
397 propagateFlags = ConfigurableField(target=PropagateSourceFlagsTask, doc=
"Propagate source flags to coadd")
398 doMatchSources = Field(dtype=bool, default=
True, doc=
"Match sources to reference catalog?")
399 match = ConfigurableField(target=DirectMatchTask, doc=
"Matching to reference catalog")
400 doWriteMatchesDenormalized = Field(
403 doc=(
"Write reference matches in denormalized format? "
404 "This format uses more disk space, but is more convenient to read."),
406 coaddName = Field(dtype=str, default=
"deep", doc=
"Name of coadd")
407 psfCache = Field(dtype=int, default=100, doc=
"Size of psfCache")
408 checkUnitsParseStrict = Field(
409 doc=
"Strictness of Astropy unit compatibility check, can be 'raise', 'warn' or 'silent'",
416 doc=
"Apply aperture corrections"
418 applyApCorr = ConfigurableField(
419 target=ApplyApCorrTask,
420 doc=
"Subtask to apply aperture corrections"
422 doRunCatalogCalculation = Field(
425 doc=
'Run catalogCalculation task'
427 catalogCalculation = ConfigurableField(
428 target=CatalogCalculationTask,
429 doc=
"Subtask to run catalogCalculation plugins on catalog"
435 doc=
"Should be set to True if fake sources have been inserted into the input data."
437 idGenerator = SkyMapIdGeneratorConfig.make_field()
441 return self.match.refObjLoader
443 def setDefaults(self):
444 super().setDefaults()
445 self.measurement.plugins.names |= [
'base_InputCount',
447 'base_LocalPhotoCalib',
449 self.measurement.plugins[
'base_PixelFlags'].masksFpAnywhere = [
'CLIPPED',
'SENSOR_EDGE',
451 self.measurement.plugins[
'base_PixelFlags'].masksFpCenter = [
'CLIPPED',
'SENSOR_EDGE',
455class MeasureMergedCoaddSourcesTask(PipelineTask):
456 """Deblend sources from main catalog in each coadd seperately and measure.
458 Use peaks and footprints
from a master catalog to perform deblending
and
459 measurement
in each coadd.
461 Given a master input catalog of sources (peaks
and footprints)
or deblender
462 outputs(including a HeavyFootprint
in each band), measure each source on
463 the coadd. Repeating this procedure
with the same master catalog across
464 multiple coadds will generate a consistent set of child sources.
466 The deblender retains all peaks
and deblends any missing peaks (dropouts
in
467 that band)
as PSFs. Source properties are measured
and the
@c is-primary
468 flag (indicating sources
with no children)
is set. Visit flags are
469 propagated to the coadd sources.
471 Optionally, we can match the coadd sources to an external reference
474 After MeasureMergedCoaddSourcesTask has been run on multiple coadds, we
475 have a set of per-band catalogs. The next stage
in the multi-band
476 processing procedure will merge these measurements into a suitable catalog
477 for driving forced photometry.
482 The schema of the merged detection catalog used
as input to this one.
484 The schema of the PeakRecords
in the Footprints
in the merged detection catalog.
485 refObjLoader : `lsst.meas.algorithms.ReferenceObjectLoader`, optional
486 An instance of ReferenceObjectLoader that supplies an external reference
487 catalog. May be
None if the loader can be constructed
from the butler argument
or all steps
488 requiring a reference catalog are disabled.
489 initInputs : `dict`, optional
490 Dictionary that can contain a key ``inputSchema`` containing the
491 input schema. If present will override the value of ``schema``.
493 Additional keyword arguments.
496 _DefaultName = "measureCoaddSources"
497 ConfigClass = MeasureMergedCoaddSourcesConfig
499 def __init__(self, schema=None, peakSchema=None, refObjLoader=None, initInputs=None,
501 super().__init__(**kwargs)
502 self.deblended = self.config.inputCatalog.startswith(
"deblended")
503 self.inputCatalog =
"Coadd_" + self.config.inputCatalog
504 if initInputs
is not None:
505 schema = initInputs[
'inputSchema'].schema
507 raise ValueError(
"Schema must be defined.")
508 self.schemaMapper = afwTable.SchemaMapper(schema)
509 self.schemaMapper.addMinimalSchema(schema)
510 self.schema = self.schemaMapper.getOutputSchema()
512 self.makeSubtask(
"measurement", schema=self.schema, algMetadata=self.algMetadata)
513 self.makeSubtask(
"setPrimaryFlags", schema=self.schema)
514 if self.config.doMatchSources:
515 self.makeSubtask(
"match", refObjLoader=refObjLoader)
516 if self.config.doPropagateFlags:
517 self.makeSubtask(
"propagateFlags", schema=self.schema)
518 self.schema.checkUnits(parse_strict=self.config.checkUnitsParseStrict)
519 if self.config.doApCorr:
520 self.makeSubtask(
"applyApCorr", schema=self.schema)
521 if self.config.doRunCatalogCalculation:
522 self.makeSubtask(
"catalogCalculation", schema=self.schema)
524 self.outputSchema = afwTable.SourceCatalog(self.schema)
526 def runQuantum(self, butlerQC, inputRefs, outputRefs):
527 inputs = butlerQC.get(inputRefs)
529 refObjLoader = ReferenceObjectLoader([ref.datasetRef.dataId
for ref
in inputRefs.refCat],
530 inputs.pop(
'refCat'),
531 name=self.config.connections.refCat,
532 config=self.config.refObjLoader,
534 self.match.setRefObjLoader(refObjLoader)
538 inputs[
'exposure'].getPsf().setCacheCapacity(self.config.psfCache)
542 idGenerator = self.config.idGenerator.apply(butlerQC.quantum.dataId)
543 inputs[
'exposureId'] = idGenerator.catalog_id
546 table = afwTable.SourceTable.make(self.schema, idGenerator.make_table_id_factory())
547 sources = afwTable.SourceCatalog(table)
549 if "scarletCatalog" in inputs:
550 inputCatalog = inputs.pop(
"scarletCatalog")
551 catalogRef = inputRefs.scarletCatalog
553 inputCatalog = inputs.pop(
"inputCatalog")
554 catalogRef = inputRefs.inputCatalog
555 sources.extend(inputCatalog, self.schemaMapper)
558 if self.config.doAddFootprints:
559 modelData = inputs.pop(
'scarletModels')
560 if self.config.doConserveFlux:
561 redistributeImage = inputs[
'exposure'].image
563 redistributeImage =
None
564 modelData.updateCatalogFootprints(
566 band=inputRefs.exposure.dataId[
"band"],
567 psfModel=inputs[
'exposure'].getPsf(),
568 redistributeImage=redistributeImage,
569 removeScarletData=
True,
571 table = sources.getTable()
572 table.setMetadata(self.algMetadata)
573 inputs[
'sources'] = sources
575 skyMap = inputs.pop(
'skyMap')
576 tractNumber = catalogRef.dataId[
'tract']
577 tractInfo = skyMap[tractNumber]
578 patchInfo = tractInfo.getPatchInfo(catalogRef.dataId[
'patch'])
583 wcs=tractInfo.getWcs(),
584 bbox=patchInfo.getOuterBBox()
586 inputs[
'skyInfo'] = skyInfo
588 if self.config.doPropagateFlags:
589 if self.config.propagateFlags.target == PropagateSourceFlagsTask:
591 ccdInputs = inputs[
"exposure"].getInfo().getCoaddInputs().ccds
592 inputs[
"ccdInputs"] = ccdInputs
594 if "sourceTableHandles" in inputs:
595 sourceTableHandles = inputs.pop(
"sourceTableHandles")
596 sourceTableHandleDict = {handle.dataId[
"visit"]: handle
597 for handle
in sourceTableHandles}
598 inputs[
"sourceTableHandleDict"] = sourceTableHandleDict
599 if "finalizedSourceTableHandles" in inputs:
600 finalizedSourceTableHandles = inputs.pop(
"finalizedSourceTableHandles")
601 finalizedSourceTableHandleDict = {handle.dataId[
"visit"]: handle
602 for handle
in finalizedSourceTableHandles}
603 inputs[
"finalizedSourceTableHandleDict"] = finalizedSourceTableHandleDict
607 ccdInputs = inputs[
'exposure'].getInfo().getCoaddInputs().ccds
608 visitKey = ccdInputs.schema.find(
"visit").key
609 ccdKey = ccdInputs.schema.find(
"ccd").key
610 inputVisitIds = set()
612 for ccdRecord
in ccdInputs:
613 visit = ccdRecord.get(visitKey)
614 ccd = ccdRecord.get(ccdKey)
615 inputVisitIds.add((visit, ccd))
616 ccdRecordsWcs[(visit, ccd)] = ccdRecord.getWcs()
618 inputCatalogsToKeep = []
619 inputCatalogWcsUpdate = []
620 for i, dataRef
in enumerate(inputRefs.visitCatalogs):
621 key = (dataRef.dataId[
'visit'], dataRef.dataId[
'detector'])
622 if key
in inputVisitIds:
623 inputCatalogsToKeep.append(inputs[
'visitCatalogs'][i])
624 inputCatalogWcsUpdate.append(ccdRecordsWcs[key])
625 inputs[
'visitCatalogs'] = inputCatalogsToKeep
626 inputs[
'wcsUpdates'] = inputCatalogWcsUpdate
627 inputs[
'ccdInputs'] = ccdInputs
629 outputs = self.run(**inputs)
631 sources = outputs.outputSources
632 butlerQC.put(outputs, outputRefs)
634 def run(self, exposure, sources, skyInfo, exposureId, ccdInputs=None, visitCatalogs=None, wcsUpdates=None,
635 sourceTableHandleDict=None, finalizedSourceTableHandleDict=None):
636 """Run measurement algorithms on the input exposure, and optionally populate the
637 resulting catalog with extra information.
641 exposure : `lsst.afw.exposure.Exposure`
642 The input exposure on which measurements are to be performed.
644 A catalog built
from the results of merged detections,
or
646 skyInfo : `lsst.pipe.base.Struct`
647 A struct containing information about the position of the input exposure within
648 a `SkyMap`, the `SkyMap`, its `Wcs`,
and its bounding box.
649 exposureId : `int`
or `bytes`
650 Packed unique number
or bytes unique to the input exposure.
652 Catalog containing information on the individual visits which went into making
654 visitCatalogs : `list` of `lsst.afw.table.SourceCatalogs`, optional
655 A list of source catalogs corresponding to measurements made on the individual
656 visits which went into the input exposure. If
None and butler
is `
None` then
657 the task cannot propagate visit flags to the output catalog.
658 Deprecated, to be removed
with PropagateVisitFlagsTask.
660 If visitCatalogs
is not `
None` this should be a list of wcs objects which correspond
661 to the input visits. Used to put all coordinates to common system. If `
None`
and
662 butler
is `
None` then the task cannot propagate visit flags to the output catalog.
663 Deprecated, to be removed
with PropagateVisitFlagsTask.
664 sourceTableHandleDict : `dict` [`int`, `lsst.daf.butler.DeferredDatasetHandle`], optional
665 Dict
for sourceTable_visit handles (key
is visit)
for propagating flags.
666 These tables are derived
from the ``CalibrateTask`` sources,
and contain
667 astrometry
and photometry flags,
and optionally PSF flags.
668 finalizedSourceTableHandleDict : `dict` [`int`, `lsst.daf.butler.DeferredDatasetHandle`], optional
669 Dict
for finalized_src_table handles (key
is visit)
for propagating flags.
670 These tables are derived
from ``FinalizeCalibrationTask``
and contain
671 PSF flags
from the finalized PSF estimation.
675 results : `lsst.pipe.base.Struct`
676 Results of running measurement task. Will contain the catalog
in the
677 sources attribute. Optionally will have results of matching to a
678 reference catalog
in the matchResults attribute,
and denormalized
679 matches
in the denormMatches attribute.
681 self.measurement.run(sources, exposure, exposureId=exposureId)
683 if self.config.doApCorr:
684 self.applyApCorr.run(
686 apCorrMap=exposure.getInfo().getApCorrMap()
693 if not sources.isContiguous():
694 sources = sources.copy(deep=
True)
696 if self.config.doRunCatalogCalculation:
697 self.catalogCalculation.run(sources)
699 self.setPrimaryFlags.run(sources, skyMap=skyInfo.skyMap, tractInfo=skyInfo.tractInfo,
700 patchInfo=skyInfo.patchInfo)
701 if self.config.doPropagateFlags:
702 if self.config.propagateFlags.target == PropagateSourceFlagsTask:
704 self.propagateFlags.run(
707 sourceTableHandleDict,
708 finalizedSourceTableHandleDict
712 self.propagateFlags.run(
722 if self.config.doMatchSources:
723 matchResult = self.match.run(sources, exposure.getInfo().getFilter().bandLabel)
724 matches = afwTable.packMatches(matchResult.matches)
725 matches.table.setMetadata(matchResult.matchMeta)
726 results.matchResult = matches
727 if self.config.doWriteMatchesDenormalized:
728 if matchResult.matches:
729 denormMatches = denormalizeMatches(matchResult.matches, matchResult.matchMeta)
731 self.log.warning(
"No matches, so generating dummy denormalized matches file")
732 denormMatches = afwTable.BaseCatalog(afwTable.Schema())
734 denormMatches.getMetadata().add(
"COMMENT",
735 "This catalog is empty because no matches were found.")
736 results.denormMatches = denormMatches
737 results.denormMatches = denormMatches
739 results.outputSources = sources