Coverage for python/lsst/analysis/tools/atools/diaSpatialMetricsPlots.py: 35%
40 statements
« prev ^ index » next coverage.py v7.4.4, created at 2024-04-13 11:45 +0000
« prev ^ index » next coverage.py v7.4.4, created at 2024-04-13 11:45 +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__ = ("DiffimSpatialMetricsHistPlot", "DiffimSpatialMetricsInterpolatePlot")
23from lsst.pex.config import Field
25from ..actions.plot.histPlot import HistPanel, HistPlot
26from ..actions.plot.interpolateDetectorPlot import InterpolateDetectorMetricPlot
27from ..actions.vector import LoadVector
28from ..interfaces import AnalysisTool
31class DiffimSpatialMetricsHistPlot(AnalysisTool):
32 """Create histograms of the fraction of pixels with certain mask planes
33 set.
34 """
36 parameterizedBand: bool = False
38 def setDefaults(self):
39 super().setDefaults()
41 self.process.buildActions.bad_mask_fraction = LoadVector(vectorKey="bad_mask_fraction")
42 self.process.buildActions.cr_mask_fraction = LoadVector(vectorKey="cr_mask_fraction")
43 self.process.buildActions.detected_mask_fraction = LoadVector(vectorKey="detected_mask_fraction")
44 self.process.buildActions.detected_negative_mask_fraction = LoadVector(
45 vectorKey="detected_negative_mask_fraction"
46 )
47 self.process.buildActions.intrp_mask_fraction = LoadVector(vectorKey="intrp_mask_fraction")
48 self.process.buildActions.no_data_mask_fraction = LoadVector(vectorKey="no_data_mask_fraction")
49 self.process.buildActions.sat_mask_fraction = LoadVector(vectorKey="sat_mask_fraction")
50 self.process.buildActions.sat_template_mask_fraction = LoadVector(
51 vectorKey="sat_template_mask_fraction"
52 )
53 self.process.buildActions.streak_mask_fraction = LoadVector(vectorKey="streak_mask_fraction")
55 self.produce.plot = HistPlot()
57 self.produce.plot.panels["panel_flags"] = HistPanel()
58 self.produce.plot.panels["panel_flags"].label = "Flagged pixel fraction"
59 self.produce.plot.panels["panel_flags"].bins = 20
60 self.produce.plot.panels["panel_flags"].rangeType = "fixed"
61 self.produce.plot.panels["panel_flags"].lowerRange = 0
62 self.produce.plot.panels["panel_flags"].upperRange = 1.0
63 self.produce.plot.panels["panel_flags"].hists = dict(
64 no_data_mask_fraction="No data",
65 sat_mask_fraction="Saturated",
66 bad_mask_fraction="Bad",
67 cr_mask_fraction="Cosmic ray",
68 detected_mask_fraction="Detected",
69 detected_negative_mask_fraction="Detected negative",
70 intrp_mask_fraction="Interpolated",
71 sat_template_mask_fraction="Saturated template",
72 streak_mask_fraction="Streak",
73 )
76class DiffimSpatialMetricsInterpolatePlot(AnalysisTool):
77 """Interpolate spatially-sampled metric values and create low-resolution
78 images of the result.
79 """
81 metricName = Field[str](doc="Metric name to interpolate", optional=False)
82 parameterizedBand: bool = False
84 def setDefaults(self):
85 super().setDefaults()
87 self.produce.plot = InterpolateDetectorMetricPlot()
88 self.process.buildActions.x = LoadVector()
89 self.process.buildActions.x.vectorKey = "x"
90 self.process.buildActions.y = LoadVector()
91 self.process.buildActions.y.vectorKey = "y"
93 def finalize(self):
94 self.process.buildActions.metricValues = LoadVector()
95 self.process.buildActions.metricValues.vectorKey = self.metricName