31 from .selectImages
import WcsSelectImagesTask, SelectStruct
32 from .coaddInputRecorder
import CoaddInputRecorderTask
33 from .scaleVariance
import ScaleVarianceTask
35 __all__ = [
"CoaddBaseTask",
"getSkyInfo",
"makeSkyInfo"]
39 """!Configuration parameters for CoaddBaseTask 41 @anchor CoaddBaseConfig_ 43 @brief Configuration parameters shared between MakeCoaddTempExp and AssembleCoadd 45 coaddName = pexConfig.Field(
46 doc=
"Coadd name: typically one of deep or goodSeeing.",
50 select = pexConfig.ConfigurableField(
51 doc=
"Image selection subtask.",
52 target=WcsSelectImagesTask,
54 badMaskPlanes = pexConfig.ListField(
56 doc=
"Mask planes that, if set, the associated pixel should not be included in the coaddTempExp.",
59 inputRecorder = pexConfig.ConfigurableField(
60 doc=
"Subtask that helps fill CoaddInputs catalogs added to the final Exposure",
61 target=CoaddInputRecorderTask
63 doPsfMatch = pexConfig.Field(
65 doc=
"Match to modelPsf? Deprecated. Sets makePsfMatched=True, makeDirect=False",
68 modelPsf = measAlg.GaussianPsfFactory.makeField(doc=
"Model Psf factory")
69 doApplyUberCal = pexConfig.Field(
71 doc=
"Apply jointcal WCS and PhotoCalib results to input calexps?",
74 useMeasMosaic = pexConfig.Field(
76 doc=
"Use meas_mosaic's applyMosaicResultsExposure() to do the photometric " 77 "calibration/wcs update (deprecated).",
80 includeCalibVar = pexConfig.Field(
82 doc=
"Add photometric calibration variance to warp variance plane.",
85 matchingKernelSize = pexConfig.Field(
87 doc=
"Size in pixels of matching kernel. Must be odd.",
89 check=
lambda x: x % 2 == 1
97 return pipeBase.TaskRunner.getTargetList(parsedCmd, selectDataList=parsedCmd.selectId.dataList,
102 """!Base class for coaddition. 104 Subclasses must specify _DefaultName 106 ConfigClass = CoaddBaseConfig
107 RunnerClass = CoaddTaskRunner
111 self.makeSubtask(
"select")
112 self.makeSubtask(
"inputRecorder")
116 @brief Select exposures to coadd 118 Get the corners of the bbox supplied in skyInfo using @ref geom.Box2D and convert the pixel 119 positions of the bbox corners to sky coordinates using @ref skyInfo.wcs.pixelToSky. Use the 120 @ref WcsSelectImagesTask_ "WcsSelectImagesTask" to select exposures that lie inside the patch 121 indicated by the dataRef. 123 @param[in] patchRef data reference for sky map patch. Must include keys "tract", "patch", 124 plus the camera-specific filter key (e.g. "filter" or "band") 125 @param[in] skyInfo geometry for the patch; output from getSkyInfo 126 @return a list of science exposures to coadd, as butler data references 130 cornerPosList =
geom.Box2D(skyInfo.bbox).getCorners()
131 coordList = [skyInfo.wcs.pixelToSky(pos)
for pos
in cornerPosList]
132 return self.select.runDataRef(patchRef, coordList, selectDataList=selectDataList).dataRefList
136 @brief Use @ref getSkyinfo to return the skyMap, tract and patch information, wcs and the outer bbox 139 @param[in] patchRef data reference for sky map. Must include keys "tract" and "patch" 141 @return pipe_base Struct containing: 143 - tractInfo: information for chosen tract of sky map 144 - patchInfo: information about chosen patch of tract 146 - bbox: outer bbox of patch, as an geom Box2I 148 return getSkyInfo(coaddName=self.config.coaddName, patchRef=patchRef)
151 """Return coadd name for given warpType and task config 156 Either 'direct' or 'psfMatched' 160 CoaddDatasetName : `string` 162 suffix =
"" if warpType ==
"direct" else warpType[0].upper() + warpType[1:]
163 return self.config.coaddName +
"Coadd" + suffix
166 """Return warp name for given warpType and task config 171 Either 'direct' or 'psfMatched' 175 WarpDatasetName : `string` 177 return self.config.coaddName +
"Coadd_" + warpType +
"Warp" 180 def _makeArgumentParser(cls):
181 """Create an argument parser 183 parser = pipeBase.ArgumentParser(name=cls._DefaultName)
184 parser.add_id_argument(
"--id",
"deepCoadd", help=
"data ID, e.g. --id tract=12345 patch=1,2",
185 ContainerClass=CoaddDataIdContainer)
186 parser.add_id_argument(
"--selectId",
"calexp", help=
"data ID, e.g. --selectId visit=6789 ccd=0..9",
187 ContainerClass=SelectDataIdContainer)
190 def _getConfigName(self):
191 """Return the name of the config dataset 193 return "%s_%s_config" % (self.config.coaddName, self._DefaultName)
195 def _getMetadataName(self):
196 """Return the name of the metadata dataset 198 return "%s_%s_metadata" % (self.config.coaddName, self._DefaultName)
202 @brief Convenience method to provide the bitmask from the mask plane names 204 return afwImage.Mask.getPlaneBitMask(self.config.badMaskPlanes)
209 @brief A dataId container for inputs to be selected. 211 Read the header (including the size and Wcs) for all specified 212 inputs and pass those along, ultimately for the SelectImagesTask. 213 This is most useful when used with multiprocessing, as input headers are 218 """Add a dataList containing useful information for selecting images""" 221 for ref
in self.refList:
223 md = ref.get(
"calexp_md", immediate=
True)
224 wcs = afwGeom.makeSkyWcs(md)
225 data =
SelectStruct(dataRef=ref, wcs=wcs, bbox=afwImage.bboxFromMetadata(md))
227 namespace.log.warn(
"Unable to construct Wcs from %s" % (ref.dataId))
234 @brief Return the SkyMap, tract and patch information, wcs, and outer bbox of the patch to be coadded. 236 @param[in] coaddName coadd name; typically one of deep or goodSeeing 237 @param[in] patchRef data reference for sky map. Must include keys "tract" and "patch" 239 @return pipe_base Struct containing: 241 - tractInfo: information for chosen tract of sky map 242 - patchInfo: information about chosen patch of tract 244 - bbox: outer bbox of patch, as an geom Box2I 246 skyMap = patchRef.get(coaddName +
"Coadd_skyMap")
247 return makeSkyInfo(skyMap, patchRef.dataId[
"tract"], patchRef.dataId[
"patch"])
251 """Return SkyInfo Struct 253 Constructs SkyInfo used by coaddition tasks for multiple 258 skyMap : `lsst.skyMap.SkyMap` 260 patchId : str or int or tuple of int 261 Either Gen2-style comma delimited string (e.g. '4,5'), 262 tuple of integers (e.g (4, 5), Gen3-style integer. 264 tractInfo = skyMap[tractId]
266 if isinstance(patchId, str)
and ',' in patchId:
268 patchIndex = tuple(int(i)
for i
in patchId.split(
","))
272 patchInfo = tractInfo.getPatchInfo(patchIndex)
274 return pipeBase.Struct(
278 wcs=tractInfo.getWcs(),
279 bbox=patchInfo.getOuterBBox(),
285 @brief Scale the variance in a maskedImage 287 The variance plane in a convolved or warped image (or a coadd derived 288 from warped images) does not accurately reflect the noise properties of 289 the image because variance has been lost to covariance. This function 290 attempts to correct for this by scaling the variance plane to match 291 the observed variance in the image. This is not perfect (because we're 292 not tracking the covariance) but it's simple and is often good enough. 294 @deprecated Use the ScaleVarianceTask instead. 296 @param maskedImage MaskedImage to operate on; variance will be scaled 297 @param maskPlanes List of mask planes for pixels to reject 298 @param log Log for reporting the renormalization factor; or None 299 @return renormalisation factor 301 config = ScaleVarianceTask.ConfigClass()
302 config.maskPlanes = maskPlanes
304 return task.run(maskedImage)
def getCoaddDatasetName(self, warpType="direct")
def makeDataRefList(self, namespace)
Base class for coaddition.
Configuration parameters for CoaddBaseTask.
A dataId container for inputs to be selected.
def makeSkyInfo(skyMap, tractId, patchId)
def getSkyInfo(self, patchRef)
Use getSkyinfo to return the skyMap, tract and patch information, wcs and the outer bbox of the patch...
def getTempExpDatasetName(self, warpType="direct")
def getBadPixelMask(self)
Convenience method to provide the bitmask from the mask plane names.
def __init__(self, kwargs)
def getTargetList(parsedCmd, kwargs)
def selectExposures(self, patchRef, skyInfo=None, selectDataList=[])
Select exposures to coadd.
def scaleVariance(maskedImage, maskPlanes, log=None)
Scale the variance in a maskedImage.
def getSkyInfo(coaddName, patchRef)
Return the SkyMap, tract and patch information, wcs, and outer bbox of the patch to be coadded...