Coverage for python / lsst / analysis / tools / atools / diaSpatialMetricsPlots.py: 38%
53 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-04-28 09:21 +0000
« prev ^ index » next coverage.py v7.13.5, created at 2026-04-28 09:21 +0000
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/>.
21__all__ = (
22 "DiffimSpatialMetricsHistPlot",
23 "DiffimSpatialMetricsInterpolatePlot",
24 "DiffimSpatialMetricsQuiverPlot",
25)
27from lsst.pex.config import Field, ListField
29from ..actions.plot.histPlot import HistPanel, HistPlot
30from ..actions.plot.interpolateDetectorPlot import InterpolateDetectorMetricPlot
31from ..actions.plot.quiverPlot import QuiverPlot
32from ..actions.vector import LoadVector
33from ..interfaces import AnalysisTool
36class DiffimSpatialMetricsHistPlot(AnalysisTool):
37 """Create histograms of the fraction of pixels with certain mask planes
38 set.
39 """
41 parameterizedBand: bool = False
43 def setDefaults(self):
44 super().setDefaults()
46 self.process.buildActions.bad_mask_fraction = LoadVector(vectorKey="bad_mask_fraction")
47 self.process.buildActions.cr_mask_fraction = LoadVector(vectorKey="cr_mask_fraction")
48 self.process.buildActions.detected_mask_fraction = LoadVector(vectorKey="detected_mask_fraction")
49 self.process.buildActions.detected_negative_mask_fraction = LoadVector(
50 vectorKey="detected_negative_mask_fraction"
51 )
52 self.process.buildActions.intrp_mask_fraction = LoadVector(vectorKey="intrp_mask_fraction")
53 self.process.buildActions.no_data_mask_fraction = LoadVector(vectorKey="no_data_mask_fraction")
54 self.process.buildActions.sat_mask_fraction = LoadVector(vectorKey="sat_mask_fraction")
55 self.process.buildActions.sat_template_mask_fraction = LoadVector(
56 vectorKey="sat_template_mask_fraction"
57 )
58 self.process.buildActions.streak_mask_fraction = LoadVector(vectorKey="streak_mask_fraction")
60 self.produce.plot = HistPlot()
62 self.produce.plot.panels["panel_flags"] = HistPanel()
63 self.produce.plot.panels["panel_flags"].label = "Flagged pixel fraction"
64 self.produce.plot.panels["panel_flags"].bins = 20
65 self.produce.plot.panels["panel_flags"].rangeType = "fixed"
66 self.produce.plot.panels["panel_flags"].lowerRange = 0
67 self.produce.plot.panels["panel_flags"].upperRange = 1.0
68 self.produce.plot.panels["panel_flags"].hists = dict(
69 no_data_mask_fraction="No data",
70 sat_mask_fraction="Saturated",
71 bad_mask_fraction="Bad",
72 cr_mask_fraction="Cosmic ray",
73 detected_mask_fraction="Detected",
74 detected_negative_mask_fraction="Detected negative",
75 intrp_mask_fraction="Interpolated",
76 sat_template_mask_fraction="Saturated template",
77 streak_mask_fraction="Streak",
78 )
81class DiffimSpatialMetricsInterpolatePlot(AnalysisTool):
82 """Interpolate spatially-sampled metric values and create low-resolution
83 images of the result.
84 """
86 metricNames = ListField[str](doc="List of metric names to interpolate on", optional=False)
87 parameterizedBand: bool = False
89 def setDefaults(self):
90 super().setDefaults()
92 self.produce.plot = InterpolateDetectorMetricPlot()
93 self.process.buildActions.x = LoadVector()
94 self.process.buildActions.x.vectorKey = "x"
95 self.process.buildActions.y = LoadVector()
96 self.process.buildActions.y.vectorKey = "y"
98 def finalize(self):
99 for name in self.metricNames:
100 setattr(self.process.buildActions, name, LoadVector(vectorKey=name))
103class DiffimSpatialMetricsQuiverPlot(AnalysisTool):
104 """Draw arrow quiver plot with average information from
105 spatially sampled metrics"""
107 angleName = Field[str](doc="Angle parameter name to plot", optional=False)
108 lengthName = Field[str](doc="Length parameter name to plot", optional=False)
109 parameterizedBand: bool = False
111 def setDefaults(self):
112 super().setDefaults()
114 self.produce.plot = QuiverPlot()
115 self.process.buildActions.x = LoadVector(vectorKey="x")
116 self.process.buildActions.y = LoadVector(vectorKey="y")
118 def finalize(self) -> None:
119 self.process.buildActions.angle = LoadVector(vectorKey=self.angleName)
120 self.process.buildActions.length = LoadVector(vectorKey=self.lengthName)