CompareWarpAssembleCoaddTask¶
-
class
lsst.pipe.tasks.assembleCoadd.
CompareWarpAssembleCoaddTask
(*args, **kwargs)¶ Bases:
lsst.pipe.tasks.assembleCoadd.AssembleCoaddTask
Assemble 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 parameterstemporalThreshold
andspatialThreshold
. 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.CompareWarpAssembleCoaddTask
sub-classesAssembleCoaddTask
and instantiatesAssembleCoaddTask
as a subtask to generate the TemplateCoadd (the model of the static sky).Notes
The
lsst.pipe.base.CmdLineTask
interface supports a flag-d
to importdebug.py
from yourPYTHONPATH
; seebaseDebug
for more aboutdebug.py
files.This task supports the following debug variables:
saveCountIm
- If True then save the Epoch Count Image as a fits file in the
figPath
figPath
- Path to save the debug fits images and figures
For example, put something like:
import lsstDebug def DebugInfo(name): di = lsstDebug.getInfo(name) if name == "lsst.pipe.tasks.assembleCoadd": di.saveCountIm = True di.figPath = "/desired/path/to/debugging/output/images" return di lsstDebug.Info = DebugInfo
into your
debug.py
file and runassemebleCoadd.py
with the--debug
flag. Some subtasks may have their own debug variables; see individual Task documentation.Examples
CompareWarpAssembleCoaddTask
assembles a set of warped images into a coadded image. TheCompareWarpAssembleCoaddTask
is invoked by runningassembleCoadd.py
with the flag--compareWarpCoadd
. Usage ofassembleCoadd.py
expects a data reference to the tract patch and filter to be coadded (specified using ‘–id = [KEY=VALUE1[^VALUE2[^VALUE3…] [KEY=VALUE1[^VALUE2[^VALUE3…] …]]’) along with a list of coaddTempExps to attempt to coadd (specified using ‘–selectId [KEY=VALUE1[^VALUE2[^VALUE3…] [KEY=VALUE1[^VALUE2[^VALUE3…] …]]’). Only the warps that cover the specified tract and patch will be coadded. A list of the available optional arguments can be obtained by callingassembleCoadd.py
with the--help
command line argument:assembleCoadd.py --help
To demonstrate usage of the
CompareWarpAssembleCoaddTask
in the larger context of multi-band processing, we will generate the HSC-I & -R band oadds from HSC engineering test data provided in theci_hsc
package. To begin, assuming that the lsst stack has been already set up, we must set up theobs_subaru
andci_hsc
packages. This defines the environment variable$CI_HSC_DIR
and points at the location of the package. The raw HSC data live in the$CI_HSC_DIR/raw
directory. To begin assembling the coadds, we must first- processCcd process the individual ccds in $CI_HSC_RAW to produce calibrated exposures
- makeSkyMap create a skymap that covers the area of the sky present in the raw exposures
- makeCoaddTempExp warp the individual calibrated exposures to the tangent plane of the coadd
We can perform all of these steps by running
$CI_HSC_DIR scons warp-903986 warp-904014 warp-903990 warp-904010 warp-903988
This will produce warped
coaddTempExps
for each visit. To coadd the warped data, we callassembleCoadd.py
as follows:assembleCoadd.py --compareWarpCoadd $CI_HSC_DIR/DATA --id patch=5,4 tract=0 filter=HSC-I --selectId visit=903986 ccd=16 --selectId visit=903986 ccd=22 --selectId visit=903986 ccd=23 --selectId visit=903986 ccd=100 --selectId visit=904014 ccd=1 --selectId visit=904014 ccd=6 --selectId visit=904014 ccd=12 --selectId visit=903990 ccd=18 --selectId visit=903990 ccd=25 --selectId visit=904010 ccd=4 --selectId visit=904010 ccd=10 --selectId visit=904010 ccd=100 --selectId visit=903988 ccd=16 --selectId visit=903988 ccd=17 --selectId visit=903988 ccd=23 --selectId visit=903988 ccd=24
This will process the HSC-I band data. The results are written in
$CI_HSC_DIR/DATA/deepCoadd-results/HSC-I
.Methods Summary
applyAltEdgeMask
(mask, altMaskList)Propagate alt EDGE mask to SENSOR_EDGE AND INEXACT_PSF planes. assemble
(skyInfo, tempExpRefList, …)Assemble the coadd. filterArtifacts
(spanSetList, …[, …])Filter artifact candidates. findArtifacts
(templateCoadd, tempExpRefList, …)Find artifacts. makeSupplementaryData
(dataRef, selectDataList)Make inputs specific to Subclass. prefilterArtifacts
(spanSetList, exp)Remove artifact candidates covered by bad mask plane. 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 :
list
List of Dicts containing
spanSet
lists. Each element contains the new mask plane name (e.g. “CLIPPED and/or “NO_DATA”) as the key, and list ofSpanSets
to apply to the mask.
- mask :
-
assemble
(skyInfo, tempExpRefList, imageScalerList, weightList, supplementaryData, *args, **kwargs)¶ 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 assemble method.
Parameters: - skyInfo :
lsst.pipe.base.Struct
Patch geometry information.
- tempExpRefList :
list
List of data references to warps.
- imageScalerList :
list
List of image scalers.
- weightList :
list
List of weights.
- supplementaryData :
lsst.pipe.base.Struct
This Struct must contain a
templateCoadd
that serves as the model of the static sky.
Returns: - result :
lsst.pipe.base.Struct
Result struct with components:
coaddExposure
: coadded exposure (lsst.afw.image.Exposure
).nImage
: exposure count image (lsst.afw.image.Image
), if requested.
- skyInfo :
-
filterArtifacts
(spanSetList, epochCountImage, nImage, footprintsToExclude=None)¶ Filter artifact candidates.
Parameters: - spanSetList :
list
List of SpanSets representing artifact candidates.
- epochCountImage :
lsst.afw.image.Image
Image of accumulated number of warpDiff detections.
- nImage :
lsst.afw.image.Image
Image of the accumulated number of total epochs contributing.
Returns: - maskSpanSetList :
list
List of SpanSets with artifacts.
- spanSetList :
-
findArtifacts
(templateCoadd, tempExpRefList, 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.chiThreshold
sigma. 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: Returns: - altMasks :
list
List of dicts containing information about CLIPPED (i.e., artifacts), NO_DATA, and EDGE pixels.
- altMasks :
-
makeSupplementaryData
(dataRef, selectDataList)¶ Make inputs specific to Subclass.
Generate a templateCoadd to use as a native model of static sky to subtract from warps.
Parameters: - dataRef :
lsst.daf.persistence.butlerSubset.ButlerDataRef
Butler dataRef for supplementary data.
- selectDataList :
list
List of data references to Warps.
Returns: - result :
lsst.pipe.base.Struct
Result struct with components:
templateCoaddcoadd
: coadded exposure (lsst.afw.image.Exposure
).
- dataRef :
-
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
List of SpanSets representing artifact candidates.
- exp :
lsst.afw.image.Exposure
Exposure containing mask planes used to prefilter.
Returns: - returnSpanSetList :
list
List of SpanSets with artifacts.
- spanSetList :