Coverage for python/lsst/analysis/tools/analysisMetrics/apDiaSourceMetrics.py: 50%
18 statements
« prev ^ index » next coverage.py v6.5.0, created at 2022-11-18 03:12 -0800
« prev ^ index » next coverage.py v6.5.0, created at 2022-11-18 03:12 -0800
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 "NumDiaSourcesMetric",
25 "NumDipolesMetric",
26)
28from ..actions.scalar import CountAction
29from ..actions.vector import FlagSelector
30from ..interfaces import AnalysisMetric
33class NumDiaSourcesMetric(AnalysisMetric):
34 """Calculate the number of DIA Sources that do not have known
35 bad/quality flags set to true.
36 """
38 def setDefaults(self):
39 super().setDefaults()
41 # filter out DIA sources with bad flags
42 self.prep.selectors.flagSelector = FlagSelector()
43 self.prep.selectors.flagSelector.selectWhenFalse = [
44 "base_PixelFlags_flag_bad",
45 "base_PixelFlags_flag_suspect",
46 "base_PixelFlags_flag_saturatedCenter",
47 "base_PixelFlags_flag_interpolated",
48 "base_PixelFlags_flag_interpolatedCenter",
49 "base_PixelFlags_flag_edge",
50 ]
52 # Count the number of dia sources left after filtering
53 self.process.calculateActions.numDiaSources = CountAction(vectorKey="diaSourceId")
55 # the units for the quantity (count, an astropy quantity)
56 self.produce.units = {"numDiaSources": "ct"}
59class NumDipolesMetric(AnalysisMetric):
60 """Calculate the number of dipoles."""
62 def setDefaults(self):
63 super().setDefaults()
65 # select all diaSources flagged as dipole
66 self.prep.selectors.flags = FlagSelector(selectWhenTrue=["isDipole"])
68 # count the number of dipoles
69 self.process.buildActions.numDipoles = CountAction(vectorKey="isDipole")
71 # the units for the quantity (count, an astropy quantity)
72 self.produce.units = {"numDipoles": "ct"}