Coverage for python / lsst / analysis / tools / atools / calexpMetrics.py: 58%
24 statements
« prev ^ index » next coverage.py v7.12.0, created at 2025-12-13 01:20 -0800
« prev ^ index » next coverage.py v7.12.0, created at 2025-12-13 01:20 -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 "CalexpSummaryMetrics",
25 "CalexpMetricHists",
26)
28from lsst.pex.config import DictField
30from ..actions.plot import HistPanel, HistPlot
31from ..actions.vector import BandSelector, LoadVector
32from ..interfaces import AnalysisTool
35class CalexpSummaryMetrics(AnalysisTool):
36 """
37 Class to load statistics from the summary stats contained with a calexp's
38 metadata and write them to metrics.
39 """
41 propagateData: bool = True
43 # raCorners and decCorners statistics cannot be written to a metric,
44 # as metrics can only be single-valued (i.e., scalars).
45 # Units in comments are to indicate compound units, which are currently
46 # unsupported.
47 _units = {
48 "psfSigma": "pixel",
49 "psfArea": "", # pixel**2
50 "psfIxx": "", # pixel**2
51 "psfIyy": "", # pixel**2
52 "psfIxy": "", # pixel**2
53 "ra": "degree",
54 "dec": "degree",
55 "pixelScale": "", # arcsec/pixel.
56 "zenithDistance": "degree",
57 "expTime": "s",
58 "zeroPoint": "mag",
59 "skyBg": "electron",
60 "skyNoise": "electron",
61 "meanVar": "", # electron**2
62 "astromOffsetMean": "arcsec",
63 "astromOffsetStd": "arcsec",
64 "nPsfStar": "ct",
65 "psfStarDeltaE1Median": "",
66 "psfStarDeltaE2Median": "",
67 "psfStarDeltaE1Scatter": "",
68 "psfStarDeltaE2Scatter": "",
69 "psfStarDeltaSizeMedian": "pixel",
70 "psfStarDeltaSizeScatter": "pixel",
71 "psfStarScaledDeltaSizeScatter": "",
72 "psfTraceRadiusDelta": "pixel",
73 "psfApFluxDelta": "",
74 "psfApCorrSigmaScaledDelta": "",
75 "maxDistToNearestPsf": "pixel",
76 "effTime": "s",
77 "effTimePsfSigmaScale": "",
78 "effTimeSkyBgScale": "",
79 "effTimeZeroPointScale": "",
80 "magLim": "mag",
81 }
83 def setDefaults(self):
84 super().setDefaults()
86 self.prep.keysToLoad = list(self._units.keys())
87 self.produce.metric.units = self._units
90class CalexpMetricHists(AnalysisTool):
91 """
92 Class to generate histograms of metrics extracted from a Metrics Table.
93 One plot per band.
94 """
96 parameterizedBand: bool = False
97 metrics = DictField[str, str](doc="The metrics to plot and their respective labels.")
99 def setDefaults(self):
100 super().setDefaults()
102 # Band is passed as a kwarg from the calling task.
103 self.prep.selectors.bandSelector = BandSelector()
104 self.produce.plot = HistPlot()
106 def finalize(self):
108 for metric, label in self.metrics.items():
109 setattr(self.process.buildActions, metric, LoadVector(vectorKey=metric))
110 self.produce.plot.panels[metric] = HistPanel(hists={metric: "Number of calexps"}, label=label)