Coverage for python/lsst/analysis/tools/atools/apDiaSourceMetrics.py: 50%
22 statements
« prev ^ index » next coverage.py v7.2.7, created at 2023-06-07 03:18 -0700
« prev ^ index » next coverage.py v7.2.7, created at 2023-06-07 03:18 -0700
1# This file is part of analysis_tools.
2#
3# Developed for the LSST Data Management System.
4# This product includes software developed by the LSST Project
5# (https://www.lsst.org).
6# See the COPYRIGHT file at the top-level directory of this distribution
7# for details of code ownership.
8#
9# This program is free software: you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation, either version 3 of the License, or
12# (at your option) any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with this program. If not, see <https://www.gnu.org/licenses/>.
21from __future__ import annotations
23__all__ = (
24 "NumDiaSourcesAllMetric",
25 "NumDiaSourcesMetric",
26 "NumDipolesMetric",
27)
29from ..actions.scalar import CountAction
30from ..actions.vector import FlagSelector, GoodDiaSourceSelector
31from ..interfaces import AnalysisTool
34class NumDiaSourcesAllMetric(AnalysisTool):
35 """Calculate the number of DIA Sources."""
37 def setDefaults(self):
38 super().setDefaults()
40 # Count the number of dia sources
41 self.process.calculateActions.NumDiaSourcesMetricAll = CountAction(vectorKey="diaSourceId")
43 # the units for the quantity (count, an astropy quantity)
44 self.produce.metric.units = {"NumDiaSourcesAll": "ct"}
47class NumDiaSourcesMetric(AnalysisTool):
48 """Calculate the number of DIA Sources that do not have known
49 bad/quality flags set to true.
50 """
52 def setDefaults(self):
53 super().setDefaults()
55 # select dia sources that do not have bad flags
56 self.prep.selectors.goodDiaSourceSelector = GoodDiaSourceSelector()
58 # Count the number of dia sources left after filtering
59 self.process.calculateActions.numDiaSources = CountAction(vectorKey="diaSourceId")
61 # the units for the quantity (count, an astropy quantity)
62 self.produce.metric.units = {"numDiaSources": "ct"}
65class NumDipolesMetric(AnalysisTool):
66 """Calculate the number of dipoles."""
68 def setDefaults(self):
69 super().setDefaults()
71 # select all diaSources flagged as dipole
72 self.prep.selectors.flags = FlagSelector(selectWhenTrue=["isDipole"])
74 # count the number of dipoles
75 self.process.buildActions.numDipoles = CountAction(vectorKey="isDipole")
77 # the units for the quantity (count, an astropy quantity)
78 self.produce.metric.units = {"numDipoles": "ct"}