CompareWarpAssembleCoaddTask#
- class lsst.drp.tasks.assemble_coadd.CompareWarpAssembleCoaddTask(*args, **kwargs)#
Bases:
AssembleCoaddTaskAssemble a compareWarp coadded image from a set of warps by masking artifacts detected by comparing PSF-matched warps.
In
AssembleCoaddTask, we compute the coadd as an clipped mean (i.e., we clip outliers). The problem with doing this is that when computing the coadd PSF at a given location, individual visit PSFs from visits with outlier pixels contribute to the coadd PSF and cannot be treated correctly. In this task, we correct for this behavior by creating a new badMaskPlane ‘CLIPPED’ which marks pixels in the individual warps suspected to contain an artifact. We populate this plane on the input warps by comparing PSF-matched warps with a PSF-matched median coadd which serves as a model of the static sky. Any group of pixels that deviates from the PSF-matched template coadd by more than config.detect.threshold sigma, is an artifact candidate. The candidates are then filtered to remove variable sources and sources that are difficult to subtract such as bright stars. This filter is configured using the config parameterstemporalThresholdandspatialThreshold. The temporalThreshold is the maximum fraction of epochs that the deviation can appear in and still be considered an artifact. The spatialThreshold is the maximum fraction of pixels in the footprint of the deviation that appear in other epochs (where other epochs is defined by the temporalThreshold). If the deviant region meets this criteria of having a significant percentage of pixels that deviate in only a few epochs, these pixels have the ‘CLIPPED’ bit set in the mask. These regions will not contribute to the final coadd. Furthermore, any routine to determine the coadd PSF can now be cognizant of clipped regions. Note that the algorithm implemented by this task is preliminary and works correctly for HSC data. Parameter modifications and or considerable redesigning of the algorithm is likley required for other surveys.CompareWarpAssembleCoaddTasksub-classesAssembleCoaddTaskand instantiatesAssembleCoaddTaskas a subtask to generate the TemplateCoadd (the model of the static sky).Notes#
Debugging: This task supports the following debug variables: -
saveCountImIf True then save the Epoch Count Image as a fits file in the
figPathfigPathPath to save the debug fits images and figures
Methods Summary
applyAltEdgeMask(mask, altMaskList)Propagate alt EDGE mask to SENSOR_EDGE AND INEXACT_PSF planes.
filterArtifacts(spanSetList, ...[, ...])Filter artifact candidates.
findArtifacts(templateCoadd, warpRefList, ...)Find artifacts.
prefilterArtifacts(spanSetList, exp)Remove artifact candidates covered by bad mask plane.
run(skyInfo, *, warpRefList, ...)Assemble a coadd from input warps.
Methods Documentation
- applyAltEdgeMask(mask, altMaskList)#
Propagate alt EDGE mask to SENSOR_EDGE AND INEXACT_PSF planes.
Parameters#
- mask
lsst.afw.image.Mask Original mask.
- altMaskList
listofdict List of Dicts containing
spanSetlists. Each element contains the new mask plane name (e.g. “CLIPPED and/or “NO_DATA”) as the key, and list ofSpanSetsto apply to the mask.
- mask
- filterArtifacts(spanSetList, epochCountImage, nImage, footprintsToExclude=None)#
Filter artifact candidates.
Parameters#
- spanSetList
list[lsst.afw.geom.SpanSet] List of SpanSets representing artifact candidates.
- epochCountImage
lsst.afw.image.Image Image of accumulated number of warpDiff detections.
- nImage
lsst.afw.image.ImageU Image of the accumulated number of total epochs contributing.
Returns#
- maskSpanSetList
list[lsst.afw.geom.SpanSet] List of SpanSets with artifacts.
- spanSetList
- findArtifacts(templateCoadd, warpRefList, imageScalerList)#
Find artifacts.
Loop through warps twice. The first loop builds a map with the count of how many epochs each pixel deviates from the templateCoadd by more than
config.chiThresholdsigma. The second loop takes each difference image and filters the artifacts detected in each using count map to filter out variable sources and sources that are difficult to subtract cleanly.Parameters#
- templateCoadd
lsst.afw.image.Exposure Exposure to serve as model of static sky.
- warpRefList
list List of dataset handles (data references) to warps.
- imageScalerList
list List of image scalers. Deprecated and will be removed after v29.
Returns#
- altMasks
listofdict List of dicts containing information about CLIPPED (i.e., artifacts), NO_DATA, and EDGE pixels.
- templateCoadd
- prefilterArtifacts(spanSetList, exp)#
Remove artifact candidates covered by bad mask plane.
Any future editing of the candidate list that does not depend on temporal information should go in this method.
Parameters#
- spanSetList
list[lsst.afw.geom.SpanSet] List of SpanSets representing artifact candidates.
- exp
lsst.afw.image.Exposure Exposure containing mask planes used to prefilter.
Returns#
- returnSpanSetList
list[lsst.afw.geom.SpanSet] List of SpanSets with artifacts.
- spanSetList
- run(skyInfo, *, warpRefList, imageScalerList, weightList, psfMatchedWarpRefList, supplementaryData)#
Assemble a coadd from input warps.
Assemble the coadd using the provided list of coaddTempExps. Since the full coadd covers a patch (a large area), the assembly is performed over small areas on the image at a time in order to conserve memory usage. Iterate over subregions within the outer bbox of the patch using
assembleSubregionto stack the corresponding subregions from the coaddTempExps with the statistic specified. Set the edge bits the coadd mask based on the weight map.Parameters#
- skyInfo
Struct Struct with geometric information about the patch.
- warpRefList
list List of dataset handles (data references) to Warps (previously called CoaddTempExps).
- imageScalerList
list List of image scalers. Deprecated and will be removed after v29 in DM-49083.
- weightList
list List of weights.
- psfMatchedWarpRefList
list, optional List of dataset handles (data references) to psfMatchedWarps.
- altMaskList
list, optional List of alternate masks to use rather than those stored with warp.
- mask
int, optional Bit mask value to exclude from coaddition.
- supplementaryData
Struct, optional Struct with additional data products needed to assemble coadd. Only used by subclasses that implement
_makeSupplementaryDataand overriderun.
Returns#
- result
Struct Results as a struct with attributes:
coaddExposureCoadded exposure (
Exposure).nImageExposure count image (
Image), if requested.inputMapBit-wise map of inputs, if requested.
warpRefListInput list of dataset handles (data refs) to the warps (
DeferredDatasetHandle) (unmodified).imageScalerListInput list of image scalers (
list) (unmodified). Deprecated and will be removed after v29 in DM-49083.weightListInput list of weights (
list) (unmodified).
Raises#
- lsst.pipe.base.NoWorkFound
Raised if no dataset handles (data references) are provided.
Notes#
Assemble the coadd.
Find artifacts and apply them to the warps’ masks creating a list of alternative masks with a new “CLIPPED” plane and updated “NO_DATA” plane. Then pass these alternative masks to the base class’s
runmethod.- skyInfo