LSST Applications  21.0.0-172-gfb10e10a+18fedfabac,22.0.0+297cba6710,22.0.0+80564b0ff1,22.0.0+8d77f4f51a,22.0.0+a28f4c53b1,22.0.0+dcf3732eb2,22.0.1-1-g7d6de66+2a20fdde0d,22.0.1-1-g8e32f31+297cba6710,22.0.1-1-geca5380+7fa3b7d9b6,22.0.1-12-g44dc1dc+2a20fdde0d,22.0.1-15-g6a90155+515f58c32b,22.0.1-16-g9282f48+790f5f2caa,22.0.1-2-g92698f7+dcf3732eb2,22.0.1-2-ga9b0f51+7fa3b7d9b6,22.0.1-2-gd1925c9+bf4f0e694f,22.0.1-24-g1ad7a390+a9625a72a8,22.0.1-25-g5bf6245+3ad8ecd50b,22.0.1-25-gb120d7b+8b5510f75f,22.0.1-27-g97737f7+2a20fdde0d,22.0.1-32-gf62ce7b1+aa4237961e,22.0.1-4-g0b3f228+2a20fdde0d,22.0.1-4-g243d05b+871c1b8305,22.0.1-4-g3a563be+32dcf1063f,22.0.1-4-g44f2e3d+9e4ab0f4fa,22.0.1-42-gca6935d93+ba5e5ca3eb,22.0.1-5-g15c806e+85460ae5f3,22.0.1-5-g58711c4+611d128589,22.0.1-5-g75bb458+99c117b92f,22.0.1-6-g1c63a23+7fa3b7d9b6,22.0.1-6-g50866e6+84ff5a128b,22.0.1-6-g8d3140d+720564cf76,22.0.1-6-gd805d02+cc5644f571,22.0.1-8-ge5750ce+85460ae5f3,master-g6e05de7fdc+babf819c66,master-g99da0e417a+8d77f4f51a,w.2021.48
LSST Data Management Base Package
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 2059 of file assembleCoadd.py.

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 2183 of file assembleCoadd.py.

2183  def __init__(self, *args, **kwargs):
2184  AssembleCoaddTask.__init__(self, *args, **kwargs)
2185  self.makeSubtask("assembleStaticSkyModel")
2186  detectionSchema = afwTable.SourceTable.makeMinimalSchema()
2187  self.makeSubtask("detect", schema=detectionSchema)
2188  if self.config.doPreserveContainedBySource:
2189  self.makeSubtask("detectTemplate", schema=afwTable.SourceTable.makeMinimalSchema())
2190  if self.config.doScaleWarpVariance:
2191  self.makeSubtask("scaleWarpVariance")
2192  if self.config.doFilterMorphological:
2193  self.makeSubtask("maskStreaks")
2194 

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 2323 of file assembleCoadd.py.

2323  def applyAltEdgeMask(self, mask, altMaskList):
2324  """Propagate alt EDGE mask to SENSOR_EDGE AND INEXACT_PSF planes.
2325 
2326  Parameters
2327  ----------
2328  mask : `lsst.afw.image.Mask`
2329  Original mask.
2330  altMaskList : `list`
2331  List of Dicts containing ``spanSet`` lists.
2332  Each element contains the new mask plane name (e.g. "CLIPPED
2333  and/or "NO_DATA") as the key, and list of ``SpanSets`` to apply to
2334  the mask.
2335  """
2336  maskValue = mask.getPlaneBitMask(["SENSOR_EDGE", "INEXACT_PSF"])
2337  for visitMask in altMaskList:
2338  if "EDGE" in visitMask:
2339  for spanSet in visitMask['EDGE']:
2340  spanSet.clippedTo(mask.getBBox()).setMask(mask, maskValue)
2341 

◆ 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 2494 of file assembleCoadd.py.

2494  def filterArtifacts(self, spanSetList, epochCountImage, nImage, footprintsToExclude=None):
2495  """Filter artifact candidates.
2496 
2497  Parameters
2498  ----------
2499  spanSetList : `list`
2500  List of SpanSets representing artifact candidates.
2501  epochCountImage : `lsst.afw.image.Image`
2502  Image of accumulated number of warpDiff detections.
2503  nImage : `lsst.afw.image.Image`
2504  Image of the accumulated number of total epochs contributing.
2505 
2506  Returns
2507  -------
2508  maskSpanSetList : `list`
2509  List of SpanSets with artifacts.
2510  """
2511 
2512  maskSpanSetList = []
2513  x0, y0 = epochCountImage.getXY0()
2514  for i, span in enumerate(spanSetList):
2515  y, x = span.indices()
2516  yIdxLocal = [y1 - y0 for y1 in y]
2517  xIdxLocal = [x1 - x0 for x1 in x]
2518  outlierN = epochCountImage.array[yIdxLocal, xIdxLocal]
2519  totalN = nImage.array[yIdxLocal, xIdxLocal]
2520 
2521  # effectiveMaxNumEpochs is broken line (fraction of N) with characteristic config.maxNumEpochs
2522  effMaxNumEpochsHighN = (self.config.maxNumEpochs
2523  + self.config.maxFractionEpochsHigh*numpy.mean(totalN))
2524  effMaxNumEpochsLowN = self.config.maxFractionEpochsLow * numpy.mean(totalN)
2525  effectiveMaxNumEpochs = int(min(effMaxNumEpochsLowN, effMaxNumEpochsHighN))
2526  nPixelsBelowThreshold = numpy.count_nonzero((outlierN > 0)
2527  & (outlierN <= effectiveMaxNumEpochs))
2528  percentBelowThreshold = nPixelsBelowThreshold / len(outlierN)
2529  if percentBelowThreshold > self.config.spatialThreshold:
2530  maskSpanSetList.append(span)
2531 
2532  if self.config.doPreserveContainedBySource and footprintsToExclude is not None:
2533  # If a candidate is contained by a footprint on the template coadd, do not clip
2534  filteredMaskSpanSetList = []
2535  for span in maskSpanSetList:
2536  doKeep = True
2537  for footprint in footprintsToExclude.positive.getFootprints():
2538  if footprint.spans.contains(span):
2539  doKeep = False
2540  break
2541  if doKeep:
2542  filteredMaskSpanSetList.append(span)
2543  maskSpanSetList = filteredMaskSpanSetList
2544 
2545  return maskSpanSetList
2546 
int min

◆ 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 2342 of file assembleCoadd.py.

2342  def findArtifacts(self, templateCoadd, tempExpRefList, imageScalerList):
2343  """Find artifacts.
2344 
2345  Loop through warps twice. The first loop builds a map with the count
2346  of how many epochs each pixel deviates from the templateCoadd by more
2347  than ``config.chiThreshold`` sigma. The second loop takes each
2348  difference image and filters the artifacts detected in each using
2349  count map to filter out variable sources and sources that are
2350  difficult to subtract cleanly.
2351 
2352  Parameters
2353  ----------
2354  templateCoadd : `lsst.afw.image.Exposure`
2355  Exposure to serve as model of static sky.
2356  tempExpRefList : `list`
2357  List of data references to warps.
2358  imageScalerList : `list`
2359  List of image scalers.
2360 
2361  Returns
2362  -------
2363  altMasks : `list`
2364  List of dicts containing information about CLIPPED
2365  (i.e., artifacts), NO_DATA, and EDGE pixels.
2366  """
2367 
2368  self.log.debug("Generating Count Image, and mask lists.")
2369  coaddBBox = templateCoadd.getBBox()
2370  slateIm = afwImage.ImageU(coaddBBox)
2371  epochCountImage = afwImage.ImageU(coaddBBox)
2372  nImage = afwImage.ImageU(coaddBBox)
2373  spanSetArtifactList = []
2374  spanSetNoDataMaskList = []
2375  spanSetEdgeList = []
2376  spanSetBadMorphoList = []
2377  badPixelMask = self.getBadPixelMask()
2378 
2379  # mask of the warp diffs should = that of only the warp
2380  templateCoadd.mask.clearAllMaskPlanes()
2381 
2382  if self.config.doPreserveContainedBySource:
2383  templateFootprints = self.detectTemplate.detectFootprints(templateCoadd)
2384  else:
2385  templateFootprints = None
2386 
2387  for warpRef, imageScaler in zip(tempExpRefList, imageScalerList):
2388  warpDiffExp = self._readAndComputeWarpDiff(warpRef, imageScaler, templateCoadd)
2389  if warpDiffExp is not None:
2390  # This nImage only approximates the final nImage because it uses the PSF-matched mask
2391  nImage.array += (numpy.isfinite(warpDiffExp.image.array)
2392  * ((warpDiffExp.mask.array & badPixelMask) == 0)).astype(numpy.uint16)
2393  fpSet = self.detect.detectFootprints(warpDiffExp, doSmooth=False, clearMask=True)
2394  fpSet.positive.merge(fpSet.negative)
2395  footprints = fpSet.positive
2396  slateIm.set(0)
2397  spanSetList = [footprint.spans for footprint in footprints.getFootprints()]
2398 
2399  # Remove artifacts due to defects before they contribute to the epochCountImage
2400  if self.config.doPrefilterArtifacts:
2401  spanSetList = self.prefilterArtifacts(spanSetList, warpDiffExp)
2402 
2403  # Clear mask before adding prefiltered spanSets
2404  self.detect.clearMask(warpDiffExp.mask)
2405  for spans in spanSetList:
2406  spans.setImage(slateIm, 1, doClip=True)
2407  spans.setMask(warpDiffExp.mask, warpDiffExp.mask.getPlaneBitMask("DETECTED"))
2408  epochCountImage += slateIm
2409 
2410  if self.config.doFilterMorphological:
2411  maskName = self.config.streakMaskName
2412  _ = self.maskStreaks.run(warpDiffExp)
2413  streakMask = warpDiffExp.mask
2414  spanSetStreak = afwGeom.SpanSet.fromMask(streakMask,
2415  streakMask.getPlaneBitMask(maskName)).split()
2416 
2417  # PSF-Matched warps have less available area (~the matching kernel) because the calexps
2418  # undergo a second convolution. Pixels with data in the direct warp
2419  # but not in the PSF-matched warp will not have their artifacts detected.
2420  # NaNs from the PSF-matched warp therefore must be masked in the direct warp
2421  nans = numpy.where(numpy.isnan(warpDiffExp.maskedImage.image.array), 1, 0)
2422  nansMask = afwImage.makeMaskFromArray(nans.astype(afwImage.MaskPixel))
2423  nansMask.setXY0(warpDiffExp.getXY0())
2424  edgeMask = warpDiffExp.mask
2425  spanSetEdgeMask = afwGeom.SpanSet.fromMask(edgeMask,
2426  edgeMask.getPlaneBitMask("EDGE")).split()
2427  else:
2428  # If the directWarp has <1% coverage, the psfMatchedWarp can have 0% and not exist
2429  # In this case, mask the whole epoch
2430  nansMask = afwImage.MaskX(coaddBBox, 1)
2431  spanSetList = []
2432  spanSetEdgeMask = []
2433  spanSetStreak = []
2434 
2435  spanSetNoDataMask = afwGeom.SpanSet.fromMask(nansMask).split()
2436 
2437  spanSetNoDataMaskList.append(spanSetNoDataMask)
2438  spanSetArtifactList.append(spanSetList)
2439  spanSetEdgeList.append(spanSetEdgeMask)
2440  if self.config.doFilterMorphological:
2441  spanSetBadMorphoList.append(spanSetStreak)
2442 
2443  if lsstDebug.Info(__name__).saveCountIm:
2444  path = self._dataRef2DebugPath("epochCountIm", tempExpRefList[0], coaddLevel=True)
2445  epochCountImage.writeFits(path)
2446 
2447  for i, spanSetList in enumerate(spanSetArtifactList):
2448  if spanSetList:
2449  filteredSpanSetList = self.filterArtifacts(spanSetList, epochCountImage, nImage,
2450  templateFootprints)
2451  spanSetArtifactList[i] = filteredSpanSetList
2452  if self.config.doFilterMorphological:
2453  spanSetArtifactList[i] += spanSetBadMorphoList[i]
2454 
2455  altMasks = []
2456  for artifacts, noData, edge in zip(spanSetArtifactList, spanSetNoDataMaskList, spanSetEdgeList):
2457  altMasks.append({'CLIPPED': artifacts,
2458  'NO_DATA': noData,
2459  'EDGE': edge})
2460  return altMasks
2461 
def run(self, skyInfo, tempExpRefList, imageScalerList, weightList, altMaskList=None, mask=None, supplementaryData=None)

◆ 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 2239 of file assembleCoadd.py.

2239  def makeSupplementaryData(self, dataRef, selectDataList=None, warpRefList=None):
2240  """
2241  Generate a templateCoadd to use as a naive model of static sky to
2242  subtract from PSF-Matched warps.
2243 
2244  Returns
2245  -------
2246  result : `lsst.pipe.base.Struct`
2247  Result struct with components:
2248 
2249  - ``templateCoadd``: coadded exposure (``lsst.afw.image.Exposure``)
2250  - ``nImage``: N Image (``lsst.afw.image.Image``)
2251  """
2252  templateCoadd = self.assembleStaticSkyModel.runDataRef(dataRef, selectDataList, warpRefList)
2253  if templateCoadd is None:
2254  raise RuntimeError(self._noTemplateMessage(self.assembleStaticSkyModel.warpType))
2255 
2256  return pipeBase.Struct(templateCoadd=templateCoadd.coaddExposure,
2257  nImage=templateCoadd.nImage,
2258  warpRefList=templateCoadd.warpRefList,
2259  imageScalerList=templateCoadd.imageScalerList,
2260  weightList=templateCoadd.weightList)
2261 
def makeSupplementaryData(self, dataRef, selectDataList=None, warpRefList=None)

◆ 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 2196 of file assembleCoadd.py.

2196  def makeSupplementaryDataGen3(self, butlerQC, inputRefs, outputRefs):
2197  """
2198  Generate a templateCoadd to use as a naive model of static sky to
2199  subtract from PSF-Matched warps.
2200 
2201  Returns
2202  -------
2203  result : `lsst.pipe.base.Struct`
2204  Result struct with components:
2205 
2206  - ``templateCoadd`` : coadded exposure (``lsst.afw.image.Exposure``)
2207  - ``nImage`` : N Image (``lsst.afw.image.Image``)
2208  """
2209  # Ensure that psfMatchedWarps are used as input warps for template generation
2210  staticSkyModelInputRefs = copy.deepcopy(inputRefs)
2211  staticSkyModelInputRefs.inputWarps = inputRefs.psfMatchedWarps
2212 
2213  # Because subtasks don't have connections we have to make one.
2214  # The main task's `templateCoadd` is the subtask's `coaddExposure`
2215  staticSkyModelOutputRefs = copy.deepcopy(outputRefs)
2216  if self.config.assembleStaticSkyModel.doWrite:
2217  staticSkyModelOutputRefs.coaddExposure = staticSkyModelOutputRefs.templateCoadd
2218  # Remove template coadd from both subtask's and main tasks outputs,
2219  # because it is handled by the subtask as `coaddExposure`
2220  del outputRefs.templateCoadd
2221  del staticSkyModelOutputRefs.templateCoadd
2222 
2223  # A PSF-Matched nImage does not exist as a dataset type
2224  if 'nImage' in staticSkyModelOutputRefs.keys():
2225  del staticSkyModelOutputRefs.nImage
2226 
2227  templateCoadd = self.assembleStaticSkyModel.runQuantum(butlerQC, staticSkyModelInputRefs,
2228  staticSkyModelOutputRefs)
2229  if templateCoadd is None:
2230  raise RuntimeError(self._noTemplateMessage(self.assembleStaticSkyModel.warpType))
2231 
2232  return pipeBase.Struct(templateCoadd=templateCoadd.coaddExposure,
2233  nImage=templateCoadd.nImage,
2234  warpRefList=templateCoadd.warpRefList,
2235  imageScalerList=templateCoadd.imageScalerList,
2236  weightList=templateCoadd.weightList)
2237 
def makeSupplementaryDataGen3(self, butlerQC, inputRefs, outputRefs)

◆ 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 2462 of file assembleCoadd.py.

2462  def prefilterArtifacts(self, spanSetList, exp):
2463  """Remove artifact candidates covered by bad mask plane.
2464 
2465  Any future editing of the candidate list that does not depend on
2466  temporal information should go in this method.
2467 
2468  Parameters
2469  ----------
2470  spanSetList : `list`
2471  List of SpanSets representing artifact candidates.
2472  exp : `lsst.afw.image.Exposure`
2473  Exposure containing mask planes used to prefilter.
2474 
2475  Returns
2476  -------
2477  returnSpanSetList : `list`
2478  List of SpanSets with artifacts.
2479  """
2480  badPixelMask = exp.mask.getPlaneBitMask(self.config.prefilterArtifactsMaskPlanes)
2481  goodArr = (exp.mask.array & badPixelMask) == 0
2482  returnSpanSetList = []
2483  bbox = exp.getBBox()
2484  x0, y0 = exp.getXY0()
2485  for i, span in enumerate(spanSetList):
2486  y, x = span.clippedTo(bbox).indices()
2487  yIndexLocal = numpy.array(y) - y0
2488  xIndexLocal = numpy.array(x) - x0
2489  goodRatio = numpy.count_nonzero(goodArr[yIndexLocal, xIndexLocal])/span.getArea()
2490  if goodRatio > self.config.prefilterArtifactsRatio:
2491  returnSpanSetList.append(span)
2492  return returnSpanSetList
2493 

◆ 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 2279 of file assembleCoadd.py.

2280  supplementaryData, *args, **kwargs):
2281  """Assemble the coadd.
2282 
2283  Find artifacts and apply them to the warps' masks creating a list of
2284  alternative masks with a new "CLIPPED" plane and updated "NO_DATA"
2285  plane. Then pass these alternative masks to the base class's `run`
2286  method.
2287 
2288  The input parameters ``supplementaryData`` is a `lsst.pipe.base.Struct`
2289  that must contain a ``templateCoadd`` that serves as the
2290  model of the static sky.
2291  """
2292 
2293  # Check and match the order of the supplementaryData
2294  # (PSF-matched) inputs to the order of the direct inputs,
2295  # so that the artifact mask is applied to the right warp
2296  dataIds = [ref.dataId for ref in tempExpRefList]
2297  psfMatchedDataIds = [ref.dataId for ref in supplementaryData.warpRefList]
2298 
2299  if dataIds != psfMatchedDataIds:
2300  self.log.info("Reordering and or/padding PSF-matched visit input list")
2301  supplementaryData.warpRefList = reorderAndPadList(supplementaryData.warpRefList,
2302  psfMatchedDataIds, dataIds)
2303  supplementaryData.imageScalerList = reorderAndPadList(supplementaryData.imageScalerList,
2304  psfMatchedDataIds, dataIds)
2305 
2306  # Use PSF-Matched Warps (and corresponding scalers) and coadd to find artifacts
2307  spanSetMaskList = self.findArtifacts(supplementaryData.templateCoadd,
2308  supplementaryData.warpRefList,
2309  supplementaryData.imageScalerList)
2310 
2311  badMaskPlanes = self.config.badMaskPlanes[:]
2312  badMaskPlanes.append("CLIPPED")
2313  badPixelMask = afwImage.Mask.getPlaneBitMask(badMaskPlanes)
2314 
2315  result = AssembleCoaddTask.run(self, skyInfo, tempExpRefList, imageScalerList, weightList,
2316  spanSetMaskList, mask=badPixelMask)
2317 
2318  # Propagate PSF-matched EDGE pixels to coadd SENSOR_EDGE and INEXACT_PSF
2319  # Psf-Matching moves the real edge inwards
2320  self.applyAltEdgeMask(result.coaddExposure.maskedImage.mask, spanSetMaskList)
2321  return result
2322 
def reorderAndPadList(inputList, inputKeys, outputKeys, padWith=None)

Member Data Documentation

◆ ConfigClass

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

Definition at line 2180 of file assembleCoadd.py.


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