Coverage for python/lsst/pipe/tasks/coaddBase.py : 45%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# # LSST Data Management System # Copyright 2008-2015 AURA/LSST. # # This product includes software developed by the # LSST Project (http://www.lsst.org/). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the LSST License Statement and # the GNU General Public License along with this program. If not, # see <http://www.lsstcorp.org/LegalNotices/>. #
"""!Configuration parameters for CoaddBaseTask
@anchor CoaddBaseConfig_
@brief Configuration parameters shared between MakeCoaddTempExp and AssembleCoadd """ doc="Coadd name: typically one of deep or goodSeeing.", dtype=str, default="deep", ) doc="Image selection subtask.", target=WcsSelectImagesTask, ) dtype=str, doc="Mask planes that, if set, the associated pixel should not be included in the coaddTempExp.", default=("NO_DATA",), ) doc="Subtask that helps fill CoaddInputs catalogs added to the final Exposure", target=CoaddInputRecorderTask ) dtype=bool, doc="Match to modelPsf? Deprecated. Sets makePsfMatched=True, makeDirect=False", default=False ) dtype=bool, doc="Apply jointcal WCS and PhotoCalib results to input calexps?", default=False ) dtype=bool, doc="Use meas_mosaic's applyMosaicResultsExposure() to do the photometric " "calibration/wcs update (deprecated).", default=False ) dtype=bool, doc="Add photometric calibration variance to warp variance plane.", default=False ) dtype=int, doc="Size in pixels of matching kernel. Must be odd.", default=21, check=lambda x: x % 2 == 1 )
def getTargetList(parsedCmd, **kwargs): return pipeBase.TaskRunner.getTargetList(parsedCmd, selectDataList=parsedCmd.selectId.dataList, **kwargs)
"""!Base class for coaddition.
Subclasses must specify _DefaultName """
pipeBase.Task.__init__(self, *args, **kwargs) self.makeSubtask("select") self.makeSubtask("inputRecorder")
"""! @brief Select exposures to coadd
Get the corners of the bbox supplied in skyInfo using @ref afwGeom.Box2D and convert the pixel positions of the bbox corners to sky coordinates using @ref skyInfo.wcs.pixelToSky. Use the @ref WcsSelectImagesTask_ "WcsSelectImagesTask" to select exposures that lie inside the patch indicated by the dataRef.
@param[in] patchRef data reference for sky map patch. Must include keys "tract", "patch", plus the camera-specific filter key (e.g. "filter" or "band") @param[in] skyInfo geometry for the patch; output from getSkyInfo @return a list of science exposures to coadd, as butler data references """ if skyInfo is None: skyInfo = self.getSkyInfo(patchRef) cornerPosList = afwGeom.Box2D(skyInfo.bbox).getCorners() coordList = [skyInfo.wcs.pixelToSky(pos) for pos in cornerPosList] return self.select.runDataRef(patchRef, coordList, selectDataList=selectDataList).dataRefList
"""! @brief Use @ref getSkyinfo to return the skyMap, tract and patch information, wcs and the outer bbox of the patch.
@param[in] patchRef data reference for sky map. Must include keys "tract" and "patch"
@return pipe_base Struct containing: - skyMap: sky map - tractInfo: information for chosen tract of sky map - patchInfo: information about chosen patch of tract - wcs: WCS of tract - bbox: outer bbox of patch, as an afwGeom Box2I """ return getSkyInfo(coaddName=self.config.coaddName, patchRef=patchRef)
"""Return coadd name for given warpType and task config
Parameters ---------- warpType : string Either 'direct' or 'psfMatched'
Returns ------- CoaddDatasetName : `string` """ suffix = "" if warpType == "direct" else warpType[0].upper() + warpType[1:] return self.config.coaddName + "Coadd" + suffix
"""Return warp name for given warpType and task config
Parameters ---------- warpType : string Either 'direct' or 'psfMatched'
Returns ------- WarpDatasetName : `string` """ return self.config.coaddName + "Coadd_" + warpType + "Warp"
def _makeArgumentParser(cls): """Create an argument parser """ parser = pipeBase.ArgumentParser(name=cls._DefaultName) parser.add_id_argument("--id", "deepCoadd", help="data ID, e.g. --id tract=12345 patch=1,2", ContainerClass=CoaddDataIdContainer) parser.add_id_argument("--selectId", "calexp", help="data ID, e.g. --selectId visit=6789 ccd=0..9", ContainerClass=SelectDataIdContainer) return parser
"""Return the name of the config dataset """ return "%s_%s_config" % (self.config.coaddName, self._DefaultName)
"""Return the name of the metadata dataset """ return "%s_%s_metadata" % (self.config.coaddName, self._DefaultName)
"""! @brief Convenience method to provide the bitmask from the mask plane names """ return afwImage.Mask.getPlaneBitMask(self.config.badMaskPlanes)
"""! @brief A dataId container for inputs to be selected.
Read the header (including the size and Wcs) for all specified inputs and pass those along, ultimately for the SelectImagesTask. This is most useful when used with multiprocessing, as input headers are only read once. """
"""Add a dataList containing useful information for selecting images""" super(SelectDataIdContainer, self).makeDataRefList(namespace) self.dataList = [] for ref in self.refList: try: md = ref.get("calexp_md", immediate=True) wcs = afwGeom.makeSkyWcs(md) data = SelectStruct(dataRef=ref, wcs=wcs, bbox=afwImage.bboxFromMetadata(md)) except FitsError: namespace.log.warn("Unable to construct Wcs from %s" % (ref.dataId)) continue self.dataList.append(data)
"""! @brief Return the SkyMap, tract and patch information, wcs, and outer bbox of the patch to be coadded.
@param[in] coaddName coadd name; typically one of deep or goodSeeing @param[in] patchRef data reference for sky map. Must include keys "tract" and "patch"
@return pipe_base Struct containing: - skyMap: sky map - tractInfo: information for chosen tract of sky map - patchInfo: information about chosen patch of tract - wcs: WCS of tract - bbox: outer bbox of patch, as an afwGeom Box2I """ skyMap = patchRef.get(coaddName + "Coadd_skyMap") tractId = patchRef.dataId["tract"] tractInfo = skyMap[tractId]
# patch format is "xIndex,yIndex" patchIndex = tuple(int(i) for i in patchRef.dataId["patch"].split(",")) patchInfo = tractInfo.getPatchInfo(patchIndex)
return pipeBase.Struct( skyMap=skyMap, tractInfo=tractInfo, patchInfo=patchInfo, wcs=tractInfo.getWcs(), bbox=patchInfo.getOuterBBox(), )
"""! @brief Scale the variance in a maskedImage
The variance plane in a convolved or warped image (or a coadd derived from warped images) does not accurately reflect the noise properties of the image because variance has been lost to covariance. This function attempts to correct for this by scaling the variance plane to match the observed variance in the image. This is not perfect (because we're not tracking the covariance) but it's simple and is often good enough.
@deprecated Use the ScaleVarianceTask instead.
@param maskedImage MaskedImage to operate on; variance will be scaled @param maskPlanes List of mask planes for pixels to reject @param log Log for reporting the renormalization factor; or None @return renormalisation factor """ config = ScaleVarianceTask.ConfigClass() config.maskPlanes = maskPlanes task = ScaleVarianceTask(config=config, name="scaleVariance", log=log) return task.run(maskedImage) |