lsst.pipe.tasks g8b9e2231ea+fa07cb600e
Loading...
Searching...
No Matches
Classes | Variables
lsst.pipe.tasks.multiBand Namespace Reference

Classes

class  DetectCoaddSourcesConnections
 

Variables

 patch
 
 tract
 
 filter
 
 parsedCmd :
 
 kwargs :
 
list targetList
 
Butler butler : `Butler`
 
Schema schema : `Schema`
 
Schema peakSchema : `Schema`
 
dict result
 
list patchRefList
 
data dataRef reference
 
SourceCatalog sources : `SourceCatalog`
 

Variable Documentation

◆ butler

Butler lsst.pipe.tasks.multiBand.butler : `Butler`
refDict = MergeSourcesRunner.buildRefDict(parsedCmd)
kwargs["psfCache"] = parsedCmd.psfCache
return [(list(p.values()), kwargs) for t in refDict.values() for p in t.values()]


class DeblendCoaddSourcesTask(CmdLineTask):

Definition at line 421 of file multiBand.py.

◆ dataRef

data lsst.pipe.tasks.multiBand.dataRef reference
if self.config.hasFakes:
    coaddType = "fakes_" + self.config.coaddName
else:
    coaddType = self.config.coaddName

if self.config.simultaneous:
    # Use SCARLET to simultaneously deblend across filters
    filters = []
    exposures = []
    for patchRef in patchRefList:
        exposure = patchRef.get(coaddType + "Coadd_calexp", immediate=True)
        filter = patchRef.get(coaddType + "Coadd_filterLabel", immediate=True)
        filters.append(filter.bandLabel)
        exposures.append(exposure)
    # Sort inputs by band to match Gen3 order of inputs
    exposures = [exposure for _, exposure in sorted(zip(filters, exposures))]
    patchRefList = [patchRef for _, patchRef in sorted(zip(filters, patchRefList))]
    filters.sort()
    # The input sources are the same for all bands, since it is a merged catalog
    sources = self.readSources(patchRef)
    exposure = afwImage.MultibandExposure.fromExposures(filters, exposures)
    templateCatalogs, fluxCatalogs = self.multiBandDeblend.run(exposure, sources)
    for n in range(len(patchRefList)):
        self.write(patchRefList[n], templateCatalogs[filters[n]], "Model")
        if filters[n] in fluxCatalogs:
            self.write(patchRefList[n], fluxCatalogs[filters[n]], "Flux")
else:
    # Use the singeband deblender to deblend each band separately
    for patchRef in patchRefList:
        exposure = patchRef.get(coaddType + "Coadd_calexp", immediate=True)
        exposure.getPsf().setCacheCapacity(psfCache)
        sources = self.readSources(patchRef)
        self.singleBandDeblend.run(exposure, sources)
        self.write(patchRef, sources)

def readSources(self, dataRef):

Definition at line 530 of file multiBand.py.

◆ filter

lsst.pipe.tasks.multiBand.filter

Definition at line 231 of file multiBand.py.

◆ kwargs

lsst.pipe.tasks.multiBand.kwargs :

Definition at line 389 of file multiBand.py.

◆ parsedCmd

lsst.pipe.tasks.multiBand.parsedCmd :
_DefaultName = "detectCoaddSources"
ConfigClass = DetectCoaddSourcesConfig
getSchemaCatalogs = _makeGetSchemaCatalogs("det")
makeIdFactory = _makeMakeIdFactory("CoaddId")

@classmethod
def _makeArgumentParser(cls):
    parser = ArgumentParser(name=cls._DefaultName)
    parser.add_id_argument("--id", "deepCoadd", help="data ID, e.g. --id tract=12345 patch=1,2 filter=r",
                           ContainerClass=ExistingCoaddDataIdContainer)
    return parser

def __init__(self, schema=None, **kwargs):
# N.B. Super is used here to handle the multiple inheritance of PipelineTasks, the init tree
# call structure has been reviewed carefully to be sure super will work as intended.
super().__init__(**kwargs)
if schema is None:
    schema = afwTable.SourceTable.makeMinimalSchema()
self.schema = schema
self.makeSubtask("detection", schema=self.schema)
if self.config.doScaleVariance:
    self.makeSubtask("scaleVariance")

self.detectionSchema = afwTable.SourceCatalog(self.schema)

def runDataRef(self, patchRef):
if self.config.hasFakes:
    exposure = patchRef.get("fakes_" + self.config.coaddName + "Coadd", immediate=True)
else:
    exposure = patchRef.get(self.config.coaddName + "Coadd", immediate=True)
expId = getGen3CoaddExposureId(patchRef, coaddName=self.config.coaddName, log=self.log)
results = self.run(exposure, self.makeIdFactory(patchRef), expId=expId)
self.write(results, patchRef)
return results

def runQuantum(self, butlerQC, inputRefs, outputRefs):
inputs = butlerQC.get(inputRefs)
exposureIdInfo = ExposureIdInfo.fromDataId(butlerQC.quantum.dataId, "tract_patch_band")
inputs["idFactory"] = exposureIdInfo.makeSourceIdFactory()
inputs["expId"] = exposureIdInfo.expId
outputs = self.run(**inputs)
butlerQC.put(outputs, outputRefs)

def run(self, exposure, idFactory, expId):
if self.config.doScaleVariance:
    varScale = self.scaleVariance.run(exposure.maskedImage)
    exposure.getMetadata().add("VARIANCE_SCALE", varScale)
backgrounds = afwMath.BackgroundList()
table = afwTable.SourceTable.make(self.schema, idFactory)
detections = self.detection.run(table, exposure, expId=expId)
sources = detections.sources
fpSets = detections.fpSets
if hasattr(fpSets, "background") and fpSets.background:
    for bg in fpSets.background:
        backgrounds.append(bg)
return Struct(outputSources=sources, outputBackgrounds=backgrounds, outputExposure=exposure)

def write(self, results, patchRef):
coaddName = self.config.coaddName + "Coadd"
patchRef.put(results.outputBackgrounds, coaddName + "_calexp_background")
patchRef.put(results.outputSources, coaddName + "_det")
if self.config.hasFakes:
    patchRef.put(results.outputExposure, "fakes_" + coaddName + "_calexp")
else:
    patchRef.put(results.outputExposure, coaddName + "_calexp")

##############################################################################################################


class DeblendCoaddSourcesConfig(Config):
singleBandDeblend = ConfigurableField(target=SourceDeblendTask,
                                      doc="Deblend sources separately in each band")
multiBandDeblend = ConfigurableField(target=ScarletDeblendTask,
                                     doc="Deblend sources simultaneously across bands")
simultaneous = Field(dtype=bool,
                     default=True,
                     doc="Simultaneously deblend all bands? "
                         "True uses `multibandDeblend` while False uses `singleBandDeblend`")
coaddName = Field(dtype=str, default="deep", doc="Name of coadd")
hasFakes = Field(dtype=bool,
                 default=False,
                 doc="Should be set to True if fake sources have been inserted into the input data.")

def setDefaults(self):
    Config.setDefaults(self)
    self.singleBandDeblend.propagateAllPeaks = True


class DeblendCoaddSourcesRunner(MergeSourcesRunner):
@staticmethod
def getTargetList(parsedCmd, **kwargs):

Definition at line 387 of file multiBand.py.

◆ patch

lsst.pipe.tasks.multiBand.patch
doScaleVariance = Field(dtype=bool, default=True, doc="Scale variance plane using empirical noise?")
scaleVariance = ConfigurableField(target=ScaleVarianceTask, doc="Variance rescaling")
detection = ConfigurableField(target=DynamicDetectionTask, doc="Source detection")
coaddName = Field(dtype=str, default="deep", doc="Name of coadd")
doInsertFakes = Field(dtype=bool, default=False,
                      doc="Run fake sources injection task",
                      deprecated=("doInsertFakes is no longer supported. This config will be removed "
                                  "after v24."))
insertFakes = ConfigurableField(target=BaseFakeSourcesTask,
                                doc="Injection of fake sources for testing "
                                "purposes (must be retargeted)",
                                deprecated=("insertFakes is no longer supported. This config will "
                                            "be removed after v24."))
hasFakes = Field(
    dtype=bool,
    default=False,
    doc="Should be set to True if fake sources have been inserted into the input data.",
)

def setDefaults(self):
    super().setDefaults()
    self.detection.thresholdType = "pixel_stdev"
    self.detection.isotropicGrow = True
    # Coadds are made from background-subtracted CCDs, so any background subtraction should be very basic
    self.detection.reEstimateBackground = False
    self.detection.background.useApprox = False
    self.detection.background.binSize = 4096
    self.detection.background.undersampleStyle = 'REDUCE_INTERP_ORDER'
    self.detection.doTempWideBackground = True  # Suppress large footprints that overwhelm the deblender

## @addtogroup LSST_task_documentation
## @{
## @page page_DetectCoaddSourcesTask DetectCoaddSourcesTask
## @ref DetectCoaddSourcesTask_ "DetectCoaddSourcesTask"
## @copybrief DetectCoaddSourcesTask
## @}


class DetectCoaddSourcesTask(PipelineTask, CmdLineTask):
r

Definition at line 231 of file multiBand.py.

◆ patchRefList

list lsst.pipe.tasks.multiBand.patchRefList
catalog = afwTable.SourceCatalog(self.schema)
return {self.config.coaddName + "Coadd_deblendedFlux": catalog,
        self.config.coaddName + "Coadd_deblendedModel": catalog}

def runDataRef(self, patchRefList, psfCache=100):

Definition at line 483 of file multiBand.py.

◆ peakSchema

Schema lsst.pipe.tasks.multiBand.peakSchema : `Schema`

Definition at line 426 of file multiBand.py.

◆ result

dict lsst.pipe.tasks.multiBand.result
ConfigClass = DeblendCoaddSourcesConfig
RunnerClass = DeblendCoaddSourcesRunner
_DefaultName = "deblendCoaddSources"
makeIdFactory = _makeMakeIdFactory("MergedCoaddId", includeBand=False)

@classmethod
def _makeArgumentParser(cls):
    parser = ArgumentParser(name=cls._DefaultName)
    parser.add_id_argument("--id", "deepCoadd_calexp",
                           help="data ID, e.g. --id tract=12345 patch=1,2 filter=g^r^i",
                           ContainerClass=ExistingCoaddDataIdContainer)
    parser.add_argument("--psfCache", type=int, default=100, help="Size of CoaddPsf cache")
    return parser

def __init__(self, butler=None, schema=None, peakSchema=None, **kwargs):
    CmdLineTask.__init__(self, **kwargs)
    if schema is None:
        assert butler is not None, "Neither butler nor schema is defined"
        schema = butler.get(self.config.coaddName + "Coadd_mergeDet_schema", immediate=True).schema
    self.schemaMapper = afwTable.SchemaMapper(schema)
    self.schemaMapper.addMinimalSchema(schema)
    self.schema = self.schemaMapper.getOutputSchema()
    if peakSchema is None:
        assert butler is not None, "Neither butler nor peakSchema is defined"
        peakSchema = butler.get(self.config.coaddName + "Coadd_peak_schema", immediate=True).schema

    if self.config.simultaneous:
        self.makeSubtask("multiBandDeblend", schema=self.schema, peakSchema=peakSchema)
    else:
        self.makeSubtask("singleBandDeblend", schema=self.schema, peakSchema=peakSchema)

def getSchemaCatalogs(self):

Definition at line 465 of file multiBand.py.

◆ schema

Schema lsst.pipe.tasks.multiBand.schema : `Schema`

Definition at line 424 of file multiBand.py.

◆ sources

SourceCatalog lsst.pipe.tasks.multiBand.sources : `SourceCatalog`

Definition at line 535 of file multiBand.py.

◆ targetList

list lsst.pipe.tasks.multiBand.targetList

Definition at line 394 of file multiBand.py.

◆ tract

lsst.pipe.tasks.multiBand.tract

Definition at line 231 of file multiBand.py.