Skip to content

Commit

Permalink
Add hist plotting to calexpMetrics
Browse files Browse the repository at this point in the history
  • Loading branch information
jrmullaney committed Dec 10, 2024
1 parent 51d5383 commit 8bb16c7
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion python/lsst/analysis/tools/atools/calexpMetrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,15 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
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


Expand Down Expand Up @@ -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)

0 comments on commit 8bb16c7

Please sign in to comment.