Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-43176: Add deblender metric to count children with no flux after re-distribution #217

Merged
merged 1 commit into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 26 additions & 0 deletions python/lsst/analysis/tools/actions/vector/selectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,32 @@ def setDefaults(self):
self.selectWhenTrue = ["detect_isPatchInner"]


class ChildObjectSelector(RangeSelector):
"""Select only children from deblended parents"""

vectorKey = Field[str](doc="Key to select from data", default="parentSourceId")

def getInputSchema(self) -> KeyedDataSchema:
yield self.vectorKey, Vector

def __call__(self, data: KeyedData, **kwargs) -> Vector:
"""Return a mask of rows with values within the specified range.

Parameters
----------
data : `KeyedData`

Returns
-------
result : `Vector`
A mask of the rows with values within the specified range.
"""
values = cast(Vector, data[self.vectorKey])
mask = values > 0

return cast(Vector, mask)


class MagSelector(SelectorBase):
"""Selects points that have minMag < mag (AB) < maxMag.

Expand Down
22 changes: 21 additions & 1 deletion python/lsst/analysis/tools/atools/deblenderMetric.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@
__all__ = ("ParentDeblenderMetrics", "SkippedDeblenderMetrics", "BlendMetrics", "IsolatedDeblenderMetrics")

from ..actions.scalar.scalarActions import CountAction, MeanAction, SumAction
from ..actions.vector.selectors import FlagSelector, ParentObjectSelector, ThresholdSelector
from ..actions.vector.selectors import (
ChildObjectSelector,
FlagSelector,
ParentObjectSelector,
ThresholdSelector,
)
from ..interfaces import AnalysisTool


Expand Down Expand Up @@ -140,3 +145,18 @@ def setDefaults(self):
"meanIsolatedIterations": "",
"meanIsolatedLogL": "",
}


class ChildDeblenderMetrics(AnalysisTool):
"""Calculate metrics based on the performance of the deblender for
single sources.
"""

def setDefaults(self):
super().setDefaults()
self.prep.selectors.childSelector = ChildObjectSelector()
self.process.calculateActions.zeroFlux = SumAction(vectorKey="deblend_zeroFlux")

self.produce.metric.units = {
"zeroFlux": "",
}