lsst.pipe.tasks gcc9029db3c+eeb411f812
Public Member Functions | Static Public Attributes | List of all members
lsst.pipe.tasks.assembleCoadd.CompareWarpAssembleCoaddTask Class Reference
Inheritance diagram for lsst.pipe.tasks.assembleCoadd.CompareWarpAssembleCoaddTask:

Public Member Functions

def __init__ (self, *args, **kwargs)
 
def makeSupplementaryDataGen3 (self, butlerQC, inputRefs, outputRefs)
 
def makeSupplementaryData (self, dataRef, selectDataList=None, warpRefList=None)
 
def run (self, skyInfo, tempExpRefList, imageScalerList, weightList, supplementaryData, *args, **kwargs)
 
def applyAltEdgeMask (self, mask, altMaskList)
 
def findArtifacts (self, templateCoadd, tempExpRefList, imageScalerList)
 
def prefilterArtifacts (self, spanSetList, exp)
 
def filterArtifacts (self, spanSetList, epochCountImage, nImage, footprintsToExclude=None)
 

Static Public Attributes

 ConfigClass
 

Detailed Description

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 parameters
``temporalThreshold`` and ``spatialThreshold``. 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-classes
``AssembleCoaddTask`` and instantiates ``AssembleCoaddTask``
as a subtask to generate the TemplateCoadd (the model of the static sky).

Notes
-----
The `lsst.pipe.base.cmdLineTask.CmdLineTask` interface supports a
flag ``-d`` to import ``debug.py`` from your ``PYTHONPATH``; see
``baseDebug`` for more about ``debug.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:

.. code-block:: python

   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 run ``assemebleCoadd.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. The ``CompareWarpAssembleCoaddTask`` is invoked by running
``assembleCoadd.py`` with the flag ``--compareWarpCoadd``.
Usage of ``assembleCoadd.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 calling
``assembleCoadd.py`` with the ``--help`` command line argument:

.. code-block:: none

   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 the ``ci_hsc`` package.
To begin, assuming that the lsst stack has been already set up, we must
set up the ``obs_subaru`` and ``ci_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

.. code-block:: none

   $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 call ``assembleCoadd.py`` as follows:

.. code-block:: none

   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``.

Definition at line 2067 of file assembleCoadd.py.

Constructor & Destructor Documentation

◆ __init__()

def lsst.pipe.tasks.assembleCoadd.CompareWarpAssembleCoaddTask.__init__ (   self,
args,
**  kwargs 
)

Definition at line 2191 of file assembleCoadd.py.

Member Function Documentation

◆ applyAltEdgeMask()

def lsst.pipe.tasks.assembleCoadd.CompareWarpAssembleCoaddTask.applyAltEdgeMask (   self,
  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 of ``SpanSets`` to apply to
    the mask.

Definition at line 2331 of file assembleCoadd.py.

◆ filterArtifacts()

def lsst.pipe.tasks.assembleCoadd.CompareWarpAssembleCoaddTask.filterArtifacts (   self,
  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.

Definition at line 2509 of file assembleCoadd.py.

◆ findArtifacts()

def lsst.pipe.tasks.assembleCoadd.CompareWarpAssembleCoaddTask.findArtifacts (   self,
  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
----------
templateCoadd : `lsst.afw.image.Exposure`
    Exposure to serve as model of static sky.
tempExpRefList : `list`
    List of data references to warps.
imageScalerList : `list`
    List of image scalers.

Returns
-------
altMasks : `list`
    List of dicts containing information about CLIPPED
    (i.e., artifacts), NO_DATA, and EDGE pixels.

Definition at line 2350 of file assembleCoadd.py.

◆ makeSupplementaryData()

def lsst.pipe.tasks.assembleCoadd.CompareWarpAssembleCoaddTask.makeSupplementaryData (   self,
  dataRef,
  selectDataList = None,
  warpRefList = None 
)
Generate a templateCoadd to use as a naive model of static sky to
subtract from PSF-Matched warps.

Returns
-------
result : `lsst.pipe.base.Struct`
   Result struct with components:

   - ``templateCoadd``: coadded exposure (``lsst.afw.image.Exposure``)
   - ``nImage``: N Image (``lsst.afw.image.Image``)

Definition at line 2247 of file assembleCoadd.py.

◆ makeSupplementaryDataGen3()

def lsst.pipe.tasks.assembleCoadd.CompareWarpAssembleCoaddTask.makeSupplementaryDataGen3 (   self,
  butlerQC,
  inputRefs,
  outputRefs 
)
Generate a templateCoadd to use as a naive model of static sky to
subtract from PSF-Matched warps.

Returns
-------
result : `lsst.pipe.base.Struct`
   Result struct with components:

   - ``templateCoadd`` : coadded exposure (``lsst.afw.image.Exposure``)
   - ``nImage`` : N Image (``lsst.afw.image.Image``)

Definition at line 2204 of file assembleCoadd.py.

◆ prefilterArtifacts()

def lsst.pipe.tasks.assembleCoadd.CompareWarpAssembleCoaddTask.prefilterArtifacts (   self,
  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.

Definition at line 2477 of file assembleCoadd.py.

◆ run()

def lsst.pipe.tasks.assembleCoadd.CompareWarpAssembleCoaddTask.run (   self,
  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 `run`
method.

The input parameters ``supplementaryData`` is a `lsst.pipe.base.Struct`
that must contain a ``templateCoadd`` that serves as the
model of the static sky.

Definition at line 2287 of file assembleCoadd.py.

Member Data Documentation

◆ ConfigClass

lsst.pipe.tasks.assembleCoadd.CompareWarpAssembleCoaddTask.ConfigClass
static

Definition at line 2188 of file assembleCoadd.py.


The documentation for this class was generated from the following file: