LSST Applications g0265f82a02+776ea6fe0d,g159b3db504+2ad2e847e4,g1e7d6db67d+6147fcb7b1,g22560d942e+17f6891819,g2ab4ef6978+36a80bf878,g2bbee38e9b+776ea6fe0d,g2cc88a2952+157e6a7dfa,g3273194fdb+f6908454ef,g337abbeb29+776ea6fe0d,g44018dc512+776ea6fe0d,g4500d70958+2faa5faad4,g4728e35f0d+70f2b761fb,g47da3c6c86+ce8e72185e,g58be5f913a+8b80975358,g6ae5381d9b+81bc2a20b4,g7dc46dff8f+ce8e72185e,g91cdbf1c4d+d35db57202,g93973518b8+696ec083d0,g98ffbb4407+81bc2a20b4,g9ddcbc5298+7f7571301f,ga1e77700b3+9fd6c7179d,ga7ab7f6f60+8eb3636680,gae46bcf261+776ea6fe0d,gb2715bf1a1+8eb3636680,gb957171fc7+21ad70029f,gc86a011abf+8eb3636680,gcd84e84c5d+c77ce436e7,gcf0d15dbbd+ce8e72185e,gd162630629+677de33a64,gdaeeff99f8+0d8dbea60f,gdb4ec4c597+776ea6fe0d,ge24ae8ed47+4a28407819,gf041782ebf+6cd16f14a6,gf36cf20d7f+8eb3636680,w.2023.37
LSST Data Management Base Package
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | Protected Member Functions | Static Protected Attributes | List of all members
lsst.pipe.tasks.assembleCoadd.CompareWarpAssembleCoaddTask Class Reference
Inheritance diagram for lsst.pipe.tasks.assembleCoadd.CompareWarpAssembleCoaddTask:
lsst.pipe.tasks.assembleCoadd.AssembleCoaddTask lsst.pipe.tasks.coaddBase.CoaddBaseTask

Public Member Functions

 __init__ (self, *args, **kwargs)
 
 run (self, skyInfo, tempExpRefList, imageScalerList, weightList, supplementaryData)
 
 applyAltEdgeMask (self, mask, altMaskList)
 
 findArtifacts (self, templateCoadd, tempExpRefList, imageScalerList)
 
 prefilterArtifacts (self, spanSetList, exp)
 
 filterArtifacts (self, spanSetList, epochCountImage, nImage, footprintsToExclude=None)
 

Static Public Attributes

 ConfigClass = CompareWarpAssembleCoaddConfig
 

Protected Member Functions

 _makeSupplementaryData (self, butlerQC, inputRefs, outputRefs)
 
 _noTemplateMessage (self, warpType)
 
 _readAndComputeWarpDiff (self, warpRef, imageScaler, templateCoadd)
 

Static Protected Attributes

str _DefaultName = "compareWarpAssembleCoadd"
 

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
-----
Debugging:
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

Definition at line 1374 of file assembleCoadd.py.

Constructor & Destructor Documentation

◆ __init__()

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

Reimplemented from lsst.pipe.tasks.assembleCoadd.AssembleCoaddTask.

Definition at line 1422 of file assembleCoadd.py.

1422 def __init__(self, *args, **kwargs):
1423 AssembleCoaddTask.__init__(self, *args, **kwargs)
1424 self.makeSubtask("assembleStaticSkyModel")
1425 detectionSchema = afwTable.SourceTable.makeMinimalSchema()
1426 self.makeSubtask("detect", schema=detectionSchema)
1427 if self.config.doPreserveContainedBySource:
1428 self.makeSubtask("detectTemplate", schema=afwTable.SourceTable.makeMinimalSchema())
1429 if self.config.doScaleWarpVariance:
1430 self.makeSubtask("scaleWarpVariance")
1431 if self.config.doFilterMorphological:
1432 self.makeSubtask("maskStreaks")
1433

Member Function Documentation

◆ _makeSupplementaryData()

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

Returns
-------
result : `~lsst.pipe.base.Struct`
    Results as a struct with attributes:

    ``templateCoadd``
        Coadded exposure (`lsst.afw.image.Exposure`).
    ``nImage``
        Keeps track of exposure count for each pixel (`lsst.afw.image.ImageU`).

Raises
------
RuntimeError
    Raised if ``templateCoadd`` is `None`.

Reimplemented from lsst.pipe.tasks.assembleCoadd.AssembleCoaddTask.

Definition at line 1435 of file assembleCoadd.py.

1435 def _makeSupplementaryData(self, butlerQC, inputRefs, outputRefs):
1436 """Generate a templateCoadd to use as a naive model of static sky to
1437 subtract from PSF-Matched warps.
1438
1439 Returns
1440 -------
1441 result : `~lsst.pipe.base.Struct`
1442 Results as a struct with attributes:
1443
1444 ``templateCoadd``
1445 Coadded exposure (`lsst.afw.image.Exposure`).
1446 ``nImage``
1447 Keeps track of exposure count for each pixel (`lsst.afw.image.ImageU`).
1448
1449 Raises
1450 ------
1451 RuntimeError
1452 Raised if ``templateCoadd`` is `None`.
1453 """
1454 # Ensure that psfMatchedWarps are used as input warps for template generation
1455 staticSkyModelInputRefs = copy.deepcopy(inputRefs)
1456 staticSkyModelInputRefs.inputWarps = inputRefs.psfMatchedWarps
1457
1458 # Because subtasks don't have connections we have to make one.
1459 # The main task's `templateCoadd` is the subtask's `coaddExposure`
1460 staticSkyModelOutputRefs = copy.deepcopy(outputRefs)
1461 if self.config.assembleStaticSkyModel.doWrite:
1462 staticSkyModelOutputRefs.coaddExposure = staticSkyModelOutputRefs.templateCoadd
1463 # Remove template coadd from both subtask's and main tasks outputs,
1464 # because it is handled by the subtask as `coaddExposure`
1465 del outputRefs.templateCoadd
1466 del staticSkyModelOutputRefs.templateCoadd
1467
1468 # A PSF-Matched nImage does not exist as a dataset type
1469 if 'nImage' in staticSkyModelOutputRefs.keys():
1470 del staticSkyModelOutputRefs.nImage
1471
1472 templateCoadd = self.assembleStaticSkyModel.runQuantum(butlerQC, staticSkyModelInputRefs,
1473 staticSkyModelOutputRefs)
1474 if templateCoadd is None:
1475 raise RuntimeError(self._noTemplateMessage(self.assembleStaticSkyModel.warpType))
1476
1477 return pipeBase.Struct(templateCoadd=templateCoadd.coaddExposure,
1478 nImage=templateCoadd.nImage,
1479 warpRefList=templateCoadd.warpRefList,
1480 imageScalerList=templateCoadd.imageScalerList,
1481 weightList=templateCoadd.weightList)
1482
A class to contain the data, WCS, and other information needed to describe an image of the sky.
Definition Exposure.h:72

◆ _noTemplateMessage()

lsst.pipe.tasks.assembleCoadd.CompareWarpAssembleCoaddTask._noTemplateMessage (   self,
  warpType 
)
protected

Definition at line 1483 of file assembleCoadd.py.

1483 def _noTemplateMessage(self, warpType):
1484 warpName = (warpType[0].upper() + warpType[1:])
1485 message = """No %(warpName)s warps were found to build the template coadd which is
1486 required to run CompareWarpAssembleCoaddTask. To continue assembling this type of coadd,
1487 first either rerun makeCoaddTempExp with config.make%(warpName)s=True or
1488 coaddDriver with config.makeCoadTempExp.make%(warpName)s=True, before assembleCoadd.
1489
1490 Alternatively, to use another algorithm with existing warps, retarget the CoaddDriverConfig to
1491 another algorithm like:
1492
1493 from lsst.pipe.tasks.assembleCoadd import SafeClipAssembleCoaddTask
1494 config.assemble.retarget(SafeClipAssembleCoaddTask)
1495 """ % {"warpName": warpName}
1496 return message
1497

◆ _readAndComputeWarpDiff()

lsst.pipe.tasks.assembleCoadd.CompareWarpAssembleCoaddTask._readAndComputeWarpDiff (   self,
  warpRef,
  imageScaler,
  templateCoadd 
)
protected
Fetch a warp from the butler and return a warpDiff.

Parameters
----------
warpRef : `lsst.daf.butler.DeferredDatasetHandle`
    Handle for the warp.
imageScaler : `lsst.pipe.tasks.scaleZeroPoint.ImageScaler`
    An image scaler object.
templateCoadd : `lsst.afw.image.Exposure`
    Exposure to be substracted from the scaled warp.

Returns
-------
warp : `lsst.afw.image.Exposure`
    Exposure of the image difference between the warp and template.

Definition at line 1770 of file assembleCoadd.py.

1770 def _readAndComputeWarpDiff(self, warpRef, imageScaler, templateCoadd):
1771 """Fetch a warp from the butler and return a warpDiff.
1772
1773 Parameters
1774 ----------
1775 warpRef : `lsst.daf.butler.DeferredDatasetHandle`
1776 Handle for the warp.
1778 An image scaler object.
1779 templateCoadd : `lsst.afw.image.Exposure`
1780 Exposure to be substracted from the scaled warp.
1781
1782 Returns
1783 -------
1785 Exposure of the image difference between the warp and template.
1786 """
1787 # If the PSF-Matched warp did not exist for this direct warp
1788 # None is holding its place to maintain order in Gen 3
1789 if warpRef is None:
1790 return None
1791
1792 warp = warpRef.get()
1793 # direct image scaler OK for PSF-matched Warp
1794 imageScaler.scaleMaskedImage(warp.getMaskedImage())
1795 mi = warp.getMaskedImage()
1796 if self.config.doScaleWarpVariance:
1797 try:
1798 self.scaleWarpVariance.run(mi)
1799 except Exception as exc:
1800 self.log.warning("Unable to rescale variance of warp (%s); leaving it as-is", exc)
1801 mi -= templateCoadd.getMaskedImage()
1802 return warp

◆ applyAltEdgeMask()

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` of `dict`
    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 1541 of file assembleCoadd.py.

1541 def applyAltEdgeMask(self, mask, altMaskList):
1542 """Propagate alt EDGE mask to SENSOR_EDGE AND INEXACT_PSF planes.
1543
1544 Parameters
1545 ----------
1546 mask : `lsst.afw.image.Mask`
1547 Original mask.
1548 altMaskList : `list` of `dict`
1549 List of Dicts containing ``spanSet`` lists.
1550 Each element contains the new mask plane name (e.g. "CLIPPED
1551 and/or "NO_DATA") as the key, and list of ``SpanSets`` to apply to
1552 the mask.
1553 """
1554 maskValue = mask.getPlaneBitMask(["SENSOR_EDGE", "INEXACT_PSF"])
1555 for visitMask in altMaskList:
1556 if "EDGE" in visitMask:
1557 for spanSet in visitMask['EDGE']:
1558 spanSet.clippedTo(mask.getBBox()).setMask(mask, maskValue)
1559
Represent a 2-dimensional array of bitmask pixels.
Definition Mask.h:77

◆ filterArtifacts()

lsst.pipe.tasks.assembleCoadd.CompareWarpAssembleCoaddTask.filterArtifacts (   self,
  spanSetList,
  epochCountImage,
  nImage,
  footprintsToExclude = None 
)
Filter artifact candidates.

Parameters
----------
spanSetList : `list` of `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`
    List of SpanSets with artifacts.

Definition at line 1718 of file assembleCoadd.py.

1718 def filterArtifacts(self, spanSetList, epochCountImage, nImage, footprintsToExclude=None):
1719 """Filter artifact candidates.
1720
1721 Parameters
1722 ----------
1723 spanSetList : `list` of `lsst.afw.geom.SpanSet`
1724 List of SpanSets representing artifact candidates.
1725 epochCountImage : `lsst.afw.image.Image`
1726 Image of accumulated number of warpDiff detections.
1727 nImage : `lsst.afw.image.ImageU`
1728 Image of the accumulated number of total epochs contributing.
1729
1730 Returns
1731 -------
1732 maskSpanSetList : `list`
1733 List of SpanSets with artifacts.
1734 """
1735 maskSpanSetList = []
1736 x0, y0 = epochCountImage.getXY0()
1737 for i, span in enumerate(spanSetList):
1738 y, x = span.indices()
1739 yIdxLocal = [y1 - y0 for y1 in y]
1740 xIdxLocal = [x1 - x0 for x1 in x]
1741 outlierN = epochCountImage.array[yIdxLocal, xIdxLocal]
1742 totalN = nImage.array[yIdxLocal, xIdxLocal]
1743
1744 # effectiveMaxNumEpochs is broken line (fraction of N) with characteristic config.maxNumEpochs
1745 effMaxNumEpochsHighN = (self.config.maxNumEpochs
1746 + self.config.maxFractionEpochsHigh*numpy.mean(totalN))
1747 effMaxNumEpochsLowN = self.config.maxFractionEpochsLow * numpy.mean(totalN)
1748 effectiveMaxNumEpochs = int(min(effMaxNumEpochsLowN, effMaxNumEpochsHighN))
1749 nPixelsBelowThreshold = numpy.count_nonzero((outlierN > 0)
1750 & (outlierN <= effectiveMaxNumEpochs))
1751 percentBelowThreshold = nPixelsBelowThreshold / len(outlierN)
1752 if percentBelowThreshold > self.config.spatialThreshold:
1753 maskSpanSetList.append(span)
1754
1755 if self.config.doPreserveContainedBySource and footprintsToExclude is not None:
1756 # If a candidate is contained by a footprint on the template coadd, do not clip
1757 filteredMaskSpanSetList = []
1758 for span in maskSpanSetList:
1759 doKeep = True
1760 for footprint in footprintsToExclude.positive.getFootprints():
1761 if footprint.spans.contains(span):
1762 doKeep = False
1763 break
1764 if doKeep:
1765 filteredMaskSpanSetList.append(span)
1766 maskSpanSetList = filteredMaskSpanSetList
1767
1768 return maskSpanSetList
1769
int min
A compact representation of a collection of pixels.
Definition SpanSet.h:78
A class to represent a 2-dimensional array of pixels.
Definition Image.h:51

◆ findArtifacts()

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` of `dict`
    List of dicts containing information about CLIPPED
    (i.e., artifacts), NO_DATA, and EDGE pixels.

Definition at line 1560 of file assembleCoadd.py.

1560 def findArtifacts(self, templateCoadd, tempExpRefList, imageScalerList):
1561 """Find artifacts.
1562
1563 Loop through warps twice. The first loop builds a map with the count
1564 of how many epochs each pixel deviates from the templateCoadd by more
1565 than ``config.chiThreshold`` sigma. The second loop takes each
1566 difference image and filters the artifacts detected in each using
1567 count map to filter out variable sources and sources that are
1568 difficult to subtract cleanly.
1569
1570 Parameters
1571 ----------
1572 templateCoadd : `lsst.afw.image.Exposure`
1573 Exposure to serve as model of static sky.
1574 tempExpRefList : `list`
1575 List of data references to warps.
1576 imageScalerList : `list`
1577 List of image scalers.
1578
1579 Returns
1580 -------
1581 altMasks : `list` of `dict`
1582 List of dicts containing information about CLIPPED
1583 (i.e., artifacts), NO_DATA, and EDGE pixels.
1584 """
1585 self.log.debug("Generating Count Image, and mask lists.")
1586 coaddBBox = templateCoadd.getBBox()
1587 slateIm = afwImage.ImageU(coaddBBox)
1588 epochCountImage = afwImage.ImageU(coaddBBox)
1589 nImage = afwImage.ImageU(coaddBBox)
1590 spanSetArtifactList = []
1591 spanSetNoDataMaskList = []
1592 spanSetEdgeList = []
1593 spanSetBadMorphoList = []
1594 badPixelMask = self.getBadPixelMask()
1595
1596 # mask of the warp diffs should = that of only the warp
1597 templateCoadd.mask.clearAllMaskPlanes()
1598
1599 if self.config.doPreserveContainedBySource:
1600 templateFootprints = self.detectTemplate.detectFootprints(templateCoadd)
1601 else:
1602 templateFootprints = None
1603
1604 for warpRef, imageScaler in zip(tempExpRefList, imageScalerList):
1605 warpDiffExp = self._readAndComputeWarpDiff(warpRef, imageScaler, templateCoadd)
1606 if warpDiffExp is not None:
1607 # This nImage only approximates the final nImage because it uses the PSF-matched mask
1608 nImage.array += (numpy.isfinite(warpDiffExp.image.array)
1609 * ((warpDiffExp.mask.array & badPixelMask) == 0)).astype(numpy.uint16)
1610 fpSet = self.detect.detectFootprints(warpDiffExp, doSmooth=False, clearMask=True)
1611 fpSet.positive.merge(fpSet.negative)
1612 footprints = fpSet.positive
1613 slateIm.set(0)
1614 spanSetList = [footprint.spans for footprint in footprints.getFootprints()]
1615
1616 # Remove artifacts due to defects before they contribute to the epochCountImage
1617 if self.config.doPrefilterArtifacts:
1618 spanSetList = self.prefilterArtifacts(spanSetList, warpDiffExp)
1619
1620 # Clear mask before adding prefiltered spanSets
1621 self.detect.clearMask(warpDiffExp.mask)
1622 for spans in spanSetList:
1623 spans.setImage(slateIm, 1, doClip=True)
1624 spans.setMask(warpDiffExp.mask, warpDiffExp.mask.getPlaneBitMask("DETECTED"))
1625 epochCountImage += slateIm
1626
1627 if self.config.doFilterMorphological:
1628 maskName = self.config.streakMaskName
1629 _ = self.maskStreaks.run(warpDiffExp)
1630 streakMask = warpDiffExp.mask
1631 spanSetStreak = afwGeom.SpanSet.fromMask(streakMask,
1632 streakMask.getPlaneBitMask(maskName)).split()
1633 # Pad the streaks to account for low-surface brightness wings
1634 psf = warpDiffExp.getPsf()
1635 for s, sset in enumerate(spanSetStreak):
1636 psfShape = psf.computeShape(sset.computeCentroid())
1637 dilation = self.config.growStreakFp * psfShape.getDeterminantRadius()
1638 sset_dilated = sset.dilated(int(dilation))
1639 spanSetStreak[s] = sset_dilated
1640
1641 # PSF-Matched warps have less available area (~the matching kernel) because the calexps
1642 # undergo a second convolution. Pixels with data in the direct warp
1643 # but not in the PSF-matched warp will not have their artifacts detected.
1644 # NaNs from the PSF-matched warp therefore must be masked in the direct warp
1645 nans = numpy.where(numpy.isnan(warpDiffExp.maskedImage.image.array), 1, 0)
1646 nansMask = afwImage.makeMaskFromArray(nans.astype(afwImage.MaskPixel))
1647 nansMask.setXY0(warpDiffExp.getXY0())
1648 edgeMask = warpDiffExp.mask
1649 spanSetEdgeMask = afwGeom.SpanSet.fromMask(edgeMask,
1650 edgeMask.getPlaneBitMask("EDGE")).split()
1651 else:
1652 # If the directWarp has <1% coverage, the psfMatchedWarp can have 0% and not exist
1653 # In this case, mask the whole epoch
1654 nansMask = afwImage.MaskX(coaddBBox, 1)
1655 spanSetList = []
1656 spanSetEdgeMask = []
1657 spanSetStreak = []
1658
1659 spanSetNoDataMask = afwGeom.SpanSet.fromMask(nansMask).split()
1660
1661 spanSetNoDataMaskList.append(spanSetNoDataMask)
1662 spanSetArtifactList.append(spanSetList)
1663 spanSetEdgeList.append(spanSetEdgeMask)
1664 if self.config.doFilterMorphological:
1665 spanSetBadMorphoList.append(spanSetStreak)
1666
1667 if lsstDebug.Info(__name__).saveCountIm:
1668 path = self._dataRef2DebugPath("epochCountIm", tempExpRefList[0], coaddLevel=True)
1669 epochCountImage.writeFits(path)
1670
1671 for i, spanSetList in enumerate(spanSetArtifactList):
1672 if spanSetList:
1673 filteredSpanSetList = self.filterArtifacts(spanSetList, epochCountImage, nImage,
1674 templateFootprints)
1675 spanSetArtifactList[i] = filteredSpanSetList
1676 if self.config.doFilterMorphological:
1677 spanSetArtifactList[i] += spanSetBadMorphoList[i]
1678
1679 altMasks = []
1680 for artifacts, noData, edge in zip(spanSetArtifactList, spanSetNoDataMaskList, spanSetEdgeList):
1681 altMasks.append({'CLIPPED': artifacts,
1682 'NO_DATA': noData,
1683 'EDGE': edge})
1684 return altMasks
1685

◆ prefilterArtifacts()

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` of `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` of `lsst.afw.geom.SpanSet`
    List of SpanSets with artifacts.

Definition at line 1686 of file assembleCoadd.py.

1686 def prefilterArtifacts(self, spanSetList, exp):
1687 """Remove artifact candidates covered by bad mask plane.
1688
1689 Any future editing of the candidate list that does not depend on
1690 temporal information should go in this method.
1691
1692 Parameters
1693 ----------
1694 spanSetList : `list` of `lsst.afw.geom.SpanSet`
1695 List of SpanSets representing artifact candidates.
1697 Exposure containing mask planes used to prefilter.
1698
1699 Returns
1700 -------
1701 returnSpanSetList : `list` of `lsst.afw.geom.SpanSet`
1702 List of SpanSets with artifacts.
1703 """
1704 badPixelMask = exp.mask.getPlaneBitMask(self.config.prefilterArtifactsMaskPlanes)
1705 goodArr = (exp.mask.array & badPixelMask) == 0
1706 returnSpanSetList = []
1707 bbox = exp.getBBox()
1708 x0, y0 = exp.getXY0()
1709 for i, span in enumerate(spanSetList):
1710 y, x = span.clippedTo(bbox).indices()
1711 yIndexLocal = numpy.array(y) - y0
1712 xIndexLocal = numpy.array(x) - x0
1713 goodRatio = numpy.count_nonzero(goodArr[yIndexLocal, xIndexLocal])/span.getArea()
1714 if goodRatio > self.config.prefilterArtifactsRatio:
1715 returnSpanSetList.append(span)
1716 return returnSpanSetList
1717

◆ run()

lsst.pipe.tasks.assembleCoadd.CompareWarpAssembleCoaddTask.run (   self,
  skyInfo,
  tempExpRefList,
  imageScalerList,
  weightList,
  supplementaryData 
)
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 ``run``
method.

Reimplemented from lsst.pipe.tasks.assembleCoadd.AssembleCoaddTask.

Definition at line 1500 of file assembleCoadd.py.

1501 supplementaryData):
1502 """Notes
1503 -----
1504 Assemble the coadd.
1505
1506 Find artifacts and apply them to the warps' masks creating a list of
1507 alternative masks with a new "CLIPPED" plane and updated "NO_DATA"
1508 plane. Then pass these alternative masks to the base class's ``run``
1509 method.
1510 """
1511 # Check and match the order of the supplementaryData
1512 # (PSF-matched) inputs to the order of the direct inputs,
1513 # so that the artifact mask is applied to the right warp
1514 dataIds = [ref.dataId for ref in tempExpRefList]
1515 psfMatchedDataIds = [ref.dataId for ref in supplementaryData.warpRefList]
1516
1517 if dataIds != psfMatchedDataIds:
1518 self.log.info("Reordering and or/padding PSF-matched visit input list")
1519 supplementaryData.warpRefList = reorderAndPadList(supplementaryData.warpRefList,
1520 psfMatchedDataIds, dataIds)
1521 supplementaryData.imageScalerList = reorderAndPadList(supplementaryData.imageScalerList,
1522 psfMatchedDataIds, dataIds)
1523
1524 # Use PSF-Matched Warps (and corresponding scalers) and coadd to find artifacts
1525 spanSetMaskList = self.findArtifacts(supplementaryData.templateCoadd,
1526 supplementaryData.warpRefList,
1527 supplementaryData.imageScalerList)
1528
1529 badMaskPlanes = self.config.badMaskPlanes[:]
1530 badMaskPlanes.append("CLIPPED")
1531 badPixelMask = afwImage.Mask.getPlaneBitMask(badMaskPlanes)
1532
1533 result = AssembleCoaddTask.run(self, skyInfo, tempExpRefList, imageScalerList, weightList,
1534 spanSetMaskList, mask=badPixelMask)
1535
1536 # Propagate PSF-matched EDGE pixels to coadd SENSOR_EDGE and INEXACT_PSF
1537 # Psf-Matching moves the real edge inwards
1538 self.applyAltEdgeMask(result.coaddExposure.maskedImage.mask, spanSetMaskList)
1539 return result
1540

Member Data Documentation

◆ _DefaultName

str lsst.pipe.tasks.assembleCoadd.CompareWarpAssembleCoaddTask._DefaultName = "compareWarpAssembleCoadd"
staticprotected

Definition at line 1420 of file assembleCoadd.py.

◆ ConfigClass

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

Definition at line 1419 of file assembleCoadd.py.


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