From 858b6d6e33b013a7967fc83e26fb7e67911a2553 Mon Sep 17 00:00:00 2001 From: jrmullaney Date: Thu, 21 Nov 2024 05:27:47 -0800 Subject: [PATCH] Add hist plotting to calexpMetrics --- .../analysis/tools/atools/calexpMetrics.py | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/python/lsst/analysis/tools/atools/calexpMetrics.py b/python/lsst/analysis/tools/atools/calexpMetrics.py index d1f18c16d..e92145f10 100644 --- a/python/lsst/analysis/tools/atools/calexpMetrics.py +++ b/python/lsst/analysis/tools/atools/calexpMetrics.py @@ -20,8 +20,15 @@ # along with this program. If not, see . from __future__ import annotations -__all__ = ("CalexpSummaryMetrics",) +__all__ = ( + "CalexpSummaryMetrics", + "CalexpMetricHists", +) +from lsst.pex.config import DictField + +from ..actions.plot import HistPanel, HistPlot +from ..actions.vector import BandSelector, LoadVector from ..interfaces import AnalysisTool @@ -77,3 +84,24 @@ def setDefaults(self): self.prep.keysToLoad = list(self._units.keys()) self.produce.metric.units = self._units + + +class CalexpMetricHists(AnalysisTool): + """ + Class to generate histograms of metrics extracted from a Metrics Table. + One plot per band. + """ + + parameterizedBand: bool = False + metrics = DictField[str, str](doc="The metrics to plot and their respective labels.") + + def setDefaults(self): + # Band is passed as a kwarg from the calling task. + self.prep.selectors.bandSelector = BandSelector() + self.produce.plot = HistPlot() + + def finalize(self): + + for metric, label in self.metrics.items(): + setattr(self.process.buildActions, metric, LoadVector(vectorKey=metric)) + self.produce.plot.panels[metric] = HistPanel(hists={metric: "Number of calexps"}, label=label)