|
20 | 20 | # along with this program. If not, see <https://www.gnu.org/licenses/>. |
21 | 21 | from __future__ import annotations |
22 | 22 |
|
23 | | -__all__ = ("CalexpSummaryMetrics",) |
| 23 | +__all__ = ( |
| 24 | + "CalexpSummaryMetrics", |
| 25 | + "CalexpMetricHists", |
| 26 | +) |
24 | 27 |
|
| 28 | +from lsst.pex.config import DictField |
| 29 | + |
| 30 | +from ..actions.plot import HistPanel, HistPlot |
| 31 | +from ..actions.vector import BandSelector, LoadVector |
25 | 32 | from ..interfaces import AnalysisTool |
26 | 33 |
|
27 | 34 |
|
@@ -77,3 +84,24 @@ def setDefaults(self): |
77 | 84 |
|
78 | 85 | self.prep.keysToLoad = list(self._units.keys()) |
79 | 86 | self.produce.metric.units = self._units |
| 87 | + |
| 88 | + |
| 89 | +class CalexpMetricHists(AnalysisTool): |
| 90 | + """ |
| 91 | + Class to generate histograms of metrics extracted from a Metrics Table. |
| 92 | + One plot per band. |
| 93 | + """ |
| 94 | + |
| 95 | + parameterizedBand: bool = False |
| 96 | + metrics = DictField[str, str](doc="The metrics to plot and their respective labels.") |
| 97 | + |
| 98 | + def setDefaults(self): |
| 99 | + # Band is passed as a kwarg from the calling task. |
| 100 | + self.prep.selectors.bandSelector = BandSelector() |
| 101 | + self.produce.plot = HistPlot() |
| 102 | + |
| 103 | + def finalize(self): |
| 104 | + |
| 105 | + for metric, label in self.metrics.items(): |
| 106 | + setattr(self.process.buildActions, metric, LoadVector(vectorKey=metric)) |
| 107 | + self.produce.plot.panels[metric] = HistPanel(hists={metric: "Number of calexps"}, label=label) |
0 commit comments