30 from .selectImages
import WcsSelectImagesTask, SelectStruct
31 from .coaddInputRecorder
import CoaddInputRecorderTask
32 from .scaleVariance
import ScaleVarianceTask
34 __all__ = [
"CoaddBaseTask",
"getSkyInfo"]
38 """!Configuration parameters for CoaddBaseTask 40 @anchor CoaddBaseConfig_ 42 @brief Configuration parameters shared between MakeCoaddTempExp and AssembleCoadd 44 coaddName = pexConfig.Field(
45 doc=
"Coadd name: typically one of deep or goodSeeing.",
49 select = pexConfig.ConfigurableField(
50 doc=
"Image selection subtask.",
51 target=WcsSelectImagesTask,
53 badMaskPlanes = pexConfig.ListField(
55 doc=
"Mask planes that, if set, the associated pixel should not be included in the coaddTempExp.",
58 inputRecorder = pexConfig.ConfigurableField(
59 doc=
"Subtask that helps fill CoaddInputs catalogs added to the final Exposure",
60 target=CoaddInputRecorderTask
62 doPsfMatch = pexConfig.Field(
64 doc=
"Match to modelPsf? Deprecated. Sets makePsfMatched=True, makeDirect=False",
67 modelPsf = measAlg.GaussianPsfFactory.makeField(doc=
"Model Psf factory")
68 doApplyUberCal = pexConfig.Field(
70 doc=
"Apply jointcal WCS and PhotoCalib results to input calexps?",
73 useMeasMosaic = pexConfig.Field(
75 doc=
"Use meas_mosaic's applyMosaicResultsExposure() to do the photometric " 76 "calibration/wcs update (deprecated).",
79 matchingKernelSize = pexConfig.Field(
81 doc=
"Size in pixels of matching kernel. Must be odd.",
83 check=
lambda x: x % 2 == 1
91 return pipeBase.TaskRunner.getTargetList(parsedCmd, selectDataList=parsedCmd.selectId.dataList,
96 """!Base class for coaddition. 98 Subclasses must specify _DefaultName 100 ConfigClass = CoaddBaseConfig
101 RunnerClass = CoaddTaskRunner
104 pipeBase.Task.__init__(self, *args, **kwargs)
105 self.makeSubtask(
"select")
106 self.makeSubtask(
"inputRecorder")
110 @brief Select exposures to coadd 112 Get the corners of the bbox supplied in skyInfo using @ref afwGeom.Box2D and convert the pixel 113 positions of the bbox corners to sky coordinates using @ref skyInfo.wcs.pixelToSky. Use the 114 @ref WcsSelectImagesTask_ "WcsSelectImagesTask" to select exposures that lie inside the patch 115 indicated by the dataRef. 117 @param[in] patchRef data reference for sky map patch. Must include keys "tract", "patch", 118 plus the camera-specific filter key (e.g. "filter" or "band") 119 @param[in] skyInfo geometry for the patch; output from getSkyInfo 120 @return a list of science exposures to coadd, as butler data references 124 cornerPosList = afwGeom.Box2D(skyInfo.bbox).getCorners()
125 coordList = [skyInfo.wcs.pixelToSky(pos)
for pos
in cornerPosList]
126 return self.select.runDataRef(patchRef, coordList, selectDataList=selectDataList).dataRefList
130 @brief Use @ref getSkyinfo to return the skyMap, tract and patch information, wcs and the outer bbox 133 @param[in] patchRef data reference for sky map. Must include keys "tract" and "patch" 135 @return pipe_base Struct containing: 137 - tractInfo: information for chosen tract of sky map 138 - patchInfo: information about chosen patch of tract 140 - bbox: outer bbox of patch, as an afwGeom Box2I 142 return getSkyInfo(coaddName=self.config.coaddName, patchRef=patchRef)
145 """Return coadd name for given warpType and task config 150 Either 'direct' or 'psfMatched' 154 CoaddDatasetName : `string` 156 suffix =
"" if warpType ==
"direct" else warpType[0].upper() + warpType[1:]
157 return self.config.coaddName +
"Coadd" + suffix
160 """Return warp name for given warpType and task config 165 Either 'direct' or 'psfMatched' 169 WarpDatasetName : `string` 171 return self.config.coaddName +
"Coadd_" + warpType +
"Warp" 174 def _makeArgumentParser(cls):
175 """Create an argument parser 177 parser = pipeBase.ArgumentParser(name=cls._DefaultName)
178 parser.add_id_argument(
"--id",
"deepCoadd", help=
"data ID, e.g. --id tract=12345 patch=1,2",
179 ContainerClass=CoaddDataIdContainer)
180 parser.add_id_argument(
"--selectId",
"calexp", help=
"data ID, e.g. --selectId visit=6789 ccd=0..9",
181 ContainerClass=SelectDataIdContainer)
184 def _getConfigName(self):
185 """Return the name of the config dataset 187 return "%s_%s_config" % (self.config.coaddName, self._DefaultName)
189 def _getMetadataName(self):
190 """Return the name of the metadata dataset 192 return "%s_%s_metadata" % (self.config.coaddName, self._DefaultName)
196 @brief Convenience method to provide the bitmask from the mask plane names 198 return afwImage.Mask.getPlaneBitMask(self.config.badMaskPlanes)
203 @brief A dataId container for inputs to be selected. 205 Read the header (including the size and Wcs) for all specified 206 inputs and pass those along, ultimately for the SelectImagesTask. 207 This is most useful when used with multiprocessing, as input headers are 212 """Add a dataList containing useful information for selecting images""" 215 for ref
in self.refList:
217 md = ref.get(
"calexp_md", immediate=
True)
218 wcs = afwGeom.makeSkyWcs(md)
219 data =
SelectStruct(dataRef=ref, wcs=wcs, bbox=afwImage.bboxFromMetadata(md))
221 namespace.log.warn(
"Unable to construct Wcs from %s" % (ref.dataId))
228 @brief Return the SkyMap, tract and patch information, wcs, and outer bbox of the patch to be coadded. 230 @param[in] coaddName coadd name; typically one of deep or goodSeeing 231 @param[in] patchRef data reference for sky map. Must include keys "tract" and "patch" 233 @return pipe_base Struct containing: 235 - tractInfo: information for chosen tract of sky map 236 - patchInfo: information about chosen patch of tract 238 - bbox: outer bbox of patch, as an afwGeom Box2I 240 skyMap = patchRef.get(coaddName +
"Coadd_skyMap")
241 tractId = patchRef.dataId[
"tract"]
242 tractInfo = skyMap[tractId]
245 patchIndex = tuple(int(i)
for i
in patchRef.dataId[
"patch"].split(
","))
246 patchInfo = tractInfo.getPatchInfo(patchIndex)
248 return pipeBase.Struct(
252 wcs=tractInfo.getWcs(),
253 bbox=patchInfo.getOuterBBox(),
259 @brief Scale the variance in a maskedImage 261 The variance plane in a convolved or warped image (or a coadd derived 262 from warped images) does not accurately reflect the noise properties of 263 the image because variance has been lost to covariance. This function 264 attempts to correct for this by scaling the variance plane to match 265 the observed variance in the image. This is not perfect (because we're 266 not tracking the covariance) but it's simple and is often good enough. 268 @deprecated Use the ScaleVarianceTask instead. 270 @param maskedImage MaskedImage to operate on; variance will be scaled 271 @param maskPlanes List of mask planes for pixels to reject 272 @param log Log for reporting the renormalization factor; or None 273 @return renormalisation factor 275 config = ScaleVarianceTask.ConfigClass()
276 config.maskPlanes = maskPlanes
278 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 __init__(self, args, kwargs)
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 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...