30 from .selectImages
import WcsSelectImagesTask, SelectStruct
31 from .coaddInputRecorder
import CoaddInputRecorderTask
32 from .scaleVariance
import ScaleVarianceTask
34 __all__ = [
"CoaddBaseTask",
"getSkyInfo",
"makeSkyInfo"]
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 includeCalibVar = pexConfig.Field(
81 doc=
"Add photometric calibration variance to warp variance plane.",
84 matchingKernelSize = pexConfig.Field(
86 doc=
"Size in pixels of matching kernel. Must be odd.",
88 check=
lambda x: x % 2 == 1
96 return pipeBase.TaskRunner.getTargetList(parsedCmd, selectDataList=parsedCmd.selectId.dataList,
101 """!Base class for coaddition. 103 Subclasses must specify _DefaultName 105 ConfigClass = CoaddBaseConfig
106 RunnerClass = CoaddTaskRunner
110 self.makeSubtask(
"select")
111 self.makeSubtask(
"inputRecorder")
115 @brief Select exposures to coadd 117 Get the corners of the bbox supplied in skyInfo using @ref afwGeom.Box2D and convert the pixel 118 positions of the bbox corners to sky coordinates using @ref skyInfo.wcs.pixelToSky. Use the 119 @ref WcsSelectImagesTask_ "WcsSelectImagesTask" to select exposures that lie inside the patch 120 indicated by the dataRef. 122 @param[in] patchRef data reference for sky map patch. Must include keys "tract", "patch", 123 plus the camera-specific filter key (e.g. "filter" or "band") 124 @param[in] skyInfo geometry for the patch; output from getSkyInfo 125 @return a list of science exposures to coadd, as butler data references 130 coordList = [skyInfo.wcs.pixelToSky(pos)
for pos
in cornerPosList]
131 return self.select.runDataRef(patchRef, coordList, selectDataList=selectDataList).dataRefList
135 @brief Use @ref getSkyinfo to return the skyMap, tract and patch information, wcs and the outer bbox 138 @param[in] patchRef data reference for sky map. Must include keys "tract" and "patch" 140 @return pipe_base Struct containing: 142 - tractInfo: information for chosen tract of sky map 143 - patchInfo: information about chosen patch of tract 145 - bbox: outer bbox of patch, as an afwGeom Box2I 147 return getSkyInfo(coaddName=self.config.coaddName, patchRef=patchRef)
150 """Return coadd name for given warpType and task config 155 Either 'direct' or 'psfMatched' 159 CoaddDatasetName : `string` 161 suffix =
"" if warpType ==
"direct" else warpType[0].upper() + warpType[1:]
162 return self.config.coaddName +
"Coadd" + suffix
165 """Return warp name for given warpType and task config 170 Either 'direct' or 'psfMatched' 174 WarpDatasetName : `string` 176 return self.config.coaddName +
"Coadd_" + warpType +
"Warp" 179 def _makeArgumentParser(cls):
180 """Create an argument parser 182 parser = pipeBase.ArgumentParser(name=cls._DefaultName)
183 parser.add_id_argument(
"--id",
"deepCoadd", help=
"data ID, e.g. --id tract=12345 patch=1,2",
184 ContainerClass=CoaddDataIdContainer)
185 parser.add_id_argument(
"--selectId",
"calexp", help=
"data ID, e.g. --selectId visit=6789 ccd=0..9",
186 ContainerClass=SelectDataIdContainer)
189 def _getConfigName(self):
190 """Return the name of the config dataset 192 return "%s_%s_config" % (self.config.coaddName, self._DefaultName)
194 def _getMetadataName(self):
195 """Return the name of the metadata dataset 197 return "%s_%s_metadata" % (self.config.coaddName, self._DefaultName)
201 @brief Convenience method to provide the bitmask from the mask plane names 203 return afwImage.Mask.getPlaneBitMask(self.config.badMaskPlanes)
208 @brief A dataId container for inputs to be selected. 210 Read the header (including the size and Wcs) for all specified 211 inputs and pass those along, ultimately for the SelectImagesTask. 212 This is most useful when used with multiprocessing, as input headers are 217 """Add a dataList containing useful information for selecting images""" 220 for ref
in self.refList:
222 md = ref.get(
"calexp_md", immediate=
True)
226 namespace.log.warn(
"Unable to construct Wcs from %s" % (ref.dataId))
233 @brief Return the SkyMap, tract and patch information, wcs, and outer bbox of the patch to be coadded. 235 @param[in] coaddName coadd name; typically one of deep or goodSeeing 236 @param[in] patchRef data reference for sky map. Must include keys "tract" and "patch" 238 @return pipe_base Struct containing: 240 - tractInfo: information for chosen tract of sky map 241 - patchInfo: information about chosen patch of tract 243 - bbox: outer bbox of patch, as an afwGeom Box2I 245 skyMap = patchRef.get(coaddName +
"Coadd_skyMap")
246 return makeSkyInfo(skyMap, patchRef.dataId[
"tract"], patchRef.dataId[
"patch"])
250 """Return SkyInfo Struct 252 Constructs SkyInfo used by coaddition tasks for multiple 257 skyMap : `lsst.skyMap.SkyMap` 259 patchId : str or int or tuple of int 260 Either Gen2-style comma delimited string (e.g. '4,5'), 261 tuple of integers (e.g (4, 5), Gen3-style integer. 263 tractInfo = skyMap[tractId]
265 if isinstance(patchId, str)
and ',' in patchId:
267 patchIndex = tuple(
int(i)
for i
in patchId.split(
","))
271 patchInfo = tractInfo.getPatchInfo(patchIndex)
273 return pipeBase.Struct(
277 wcs=tractInfo.getWcs(),
278 bbox=patchInfo.getOuterBBox(),
284 @brief Scale the variance in a maskedImage 286 The variance plane in a convolved or warped image (or a coadd derived 287 from warped images) does not accurately reflect the noise properties of 288 the image because variance has been lost to covariance. This function 289 attempts to correct for this by scaling the variance plane to match 290 the observed variance in the image. This is not perfect (because we're 291 not tracking the covariance) but it's simple and is often good enough. 293 @deprecated Use the ScaleVarianceTask instead. 295 @param maskedImage MaskedImage to operate on; variance will be scaled 296 @param maskPlanes List of mask planes for pixels to reject 297 @param log Log for reporting the renormalization factor; or None 298 @return renormalisation factor 300 config = ScaleVarianceTask.ConfigClass()
301 config.maskPlanes = maskPlanes
303 return task.run(maskedImage)
def getCoaddDatasetName(self, warpType="direct")
def makeDataRefList(self, namespace)
Base class for coaddition.
A floating-point coordinate rectangle geometry.
Configuration parameters for CoaddBaseTask.
A dataId container for inputs to be selected.
def makeSkyInfo(skyMap, tractId, patchId)
std::shared_ptr< FrameSet > append(FrameSet const &first, FrameSet const &second)
Construct a FrameSet that performs two transformations in series.
Fit spatial kernel using approximate fluxes for candidates, and solving a linear system of equations...
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.
std::shared_ptr< SkyWcs > makeSkyWcs(TransformPoint2ToPoint2 const &pixelsToFieldAngle, lsst::geom::Angle const &orientation, bool flipX, lsst::geom::SpherePoint const &boresight, std::string const &projection="TAN")
Construct a FITS SkyWcs from camera geometry.
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...
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects...
lsst::geom::Box2I bboxFromMetadata(daf::base::PropertySet &metadata)
Determine the image bounding box from its metadata (FITS header)