24 import lsst.coadd.utils
27 from .forcedPhotImage
import ForcedPhotImageConfig, ForcedPhotImageTask
29 __all__ = (
"ForcedPhotCoaddConfig",
"ForcedPhotCoaddTask")
33 footprintDatasetName = lsst.pex.config.Field(
34 doc=
"Dataset (without coadd prefix) that should be used to obtain (Heavy)Footprints for sources. " 35 "Must have IDs that match those of the reference catalog." 36 "If None, Footprints will be generated by transforming the reference Footprints.",
43 ForcedPhotImageTask.ConfigClass.setDefaults(self)
50 self.
measurement.plugins.names |= [
'base_InputCount',
'base_Variance']
51 self.
measurement.plugins[
'base_PixelFlags'].masksFpAnywhere = [
'CLIPPED',
'SENSOR_EDGE',
52 'REJECTED',
'INEXACT_PSF']
53 self.
measurement.plugins[
'base_PixelFlags'].masksFpCenter = [
'CLIPPED',
'SENSOR_EDGE',
54 'REJECTED',
'INEXACT_PSF']
57 ForcedPhotImageTask.ConfigClass.validate(self)
60 raise ValueError(
"Cannot use removePatchOverlaps=True with deblended footprints, as parent " 61 "sources may be rejected while their children are not.")
65 """Get the psfCache setting into ForcedPhotCoaddTask""" 68 return lsst.pipe.base.ButlerInitializedTaskRunner.getTargetList(parsedCmd,
69 psfCache=parsedCmd.psfCache)
73 """A command-line driver for performing forced measurement on coadd images. 77 In addition to the run method, `ForcedPhotCcdTask` overrides several 78 methods of `ForcedPhotImageTask` to specialize it for coadd processing, 79 including `~ForcedPhotImageTask.makeIdFactory` and 80 `~ForcedPhotImageTask.fetchReferences`. None of these should be called 81 directly by the user, though it may be useful to override them further in 85 ConfigClass = ForcedPhotCoaddConfig
86 RunnerClass = lsst.pipe.base.ButlerInitializedTaskRunner
87 _DefaultName =
"forcedPhotCoadd" 88 dataPrefix =
"deepCoadd_" 91 name = self.config.coaddName +
"Coadd_calexp" 92 return dataRef.get(name)
if dataRef.datasetExists(name)
else None 95 """Create an object that generates globally unique source IDs. 97 Source IDs are created based on a per-CCD ID and the ID of the CCD 102 dataRef : `lsst.daf.persistence.ButlerDataRef` 103 Butler data reference. The "CoaddId_bits" and "CoaddId" datasets 104 are accessed. The data ID must have tract and patch keys. 113 expBits = dataRef.get(self.config.coaddName +
"CoaddId_bits")
114 expId = int(dataRef.get(self.config.coaddName +
"CoaddId"))
118 return int(dataRef.get(self.config.coaddName +
"CoaddId"))
121 """Return an iterable of reference sources which overlap the exposure. 125 dataRef : `lsst.daf.persistence.ButlerDataRef` 126 Butler data reference corresponding to the image to be measured; 127 should have tract, patch, and filter keys. 129 exposure : `lsst.afw.image.Exposure` 134 All work is delegated to the references subtask; see 135 `CoaddSrcReferencesTask` for information about the default behavior. 137 skyMap = dataRef.get(self.
dataPrefix +
"skyMap", immediate=
True)
138 tractInfo = skyMap[dataRef.dataId[
"tract"]]
139 patch = tuple(int(v)
for v
in dataRef.dataId[
"patch"].split(
","))
140 patchInfo = tractInfo.getPatchInfo(patch)
142 references.extend(self.references.fetchInPatches(dataRef, patchList=[patchInfo]))
146 r"""Attach Footprints to source records. 148 For coadd forced photometry, we use the deblended "heavy" 149 `~lsst.afw.detection.Footprint`\ s from the single-band measurements 150 of the same band - because we've guaranteed that the peaks (and hence 151 child sources) will be consistent across all bands before we get to 152 measurement, this should yield reasonable deblending for most sources. 153 It's most likely limitation is that it will not provide good flux 154 upper limits for sources that were not detected in this band but were 155 blended with sources that were. 157 if self.config.footprintDatasetName
is None:
158 return ForcedPhotImageTask.attachFootprints(self, sources, refCat, exposure, refWcs, dataRef)
159 self.log.info(
"Loading deblended footprints for sources from %s, %s" %
160 (self.config.footprintDatasetName, dataRef.dataId))
161 fpCat = dataRef.get(
"%sCoadd_%s" % (self.config.coaddName, self.config.footprintDatasetName),
163 for refRecord, srcRecord
in zip(refCat, sources):
164 fpRecord = fpCat.find(refRecord.getId())
166 raise LookupError(
"Cannot find Footprint for source %s; please check that %sCoadd_%s " 167 "IDs are compatible with reference source IDs" %
168 (srcRecord.getId(), self.config.coaddName,
169 self.config.footprintDatasetName))
170 srcRecord.setFootprint(fpRecord.getFootprint())
173 def _makeArgumentParser(cls):
174 parser = lsst.pipe.base.ArgumentParser(name=cls.
_DefaultName)
175 parser.add_id_argument(
"--id",
"deepCoadd_forced_src", help=
"data ID, with raw CCD keys + tract",
176 ContainerClass=lsst.coadd.utils.CoaddDataIdContainer)
177 parser.add_argument(
"--psfCache", type=int, default=100, help=
"Size of CoaddPsf cache")
static std::shared_ptr< IdFactory > makeSource(RecordId expId, int reserved)
def getExposure(self, dataRef)
def attachFootprints(self, sources, refCat, exposure, refWcs, dataRef)
def makeIdFactory(self, dataRef)
def getExposureId(self, dataRef)
def getTargetList(parsedCmd, kwargs)
def fetchReferences(self, dataRef, exposure)