Coverage for python/lsst/analysis/tools/atools/calibration.py: 45%
33 statements
« prev ^ index » next coverage.py v7.5.1, created at 2024-05-15 09:59 +0000
« prev ^ index » next coverage.py v7.5.1, created at 2024-05-15 09:59 +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/>.
21from __future__ import annotations
23__all__ = ("CalibStatisticFocalPlanePlot",)
25from lsst.pex.config import Field
27from ..actions.plot.focalPlanePlot import FocalPlaneGeometryPlot
28from ..actions.scalar.scalarActions import MedianAction
29from ..actions.vector import LoadVector
30from ..interfaces import AnalysisTool
33class CalibrationTool(AnalysisTool):
34 """Class to generate common calibration metrics for value/scatter
35 quantities.
36 """
38 parameterizedBand: bool = False
40 def setDefaults(self):
41 self.process.buildActions.x = LoadVector(vectorKey="detector")
42 self.process.buildActions.y = LoadVector(vectorKey="amplifier")
43 self.process.buildActions.detector = LoadVector(vectorKey="detector")
44 self.process.buildActions.amplifier = LoadVector(vectorKey="amplifier")
45 self.process.buildActions.z = LoadVector()
47 self.produce.plot = FocalPlaneGeometryPlot()
48 self.produce.plot.statistic = "median"
51class CalibStatisticFocalPlanePlot(CalibrationTool):
52 """Generates a plot of the focal plane, color-coded according to the
53 median of a given measurement (default: "biasMean") on a per-amp basis.
54 The median is across multiple bias exposures.
55 """
57 quantityKey = Field[str](
58 default="biasMean", doc="VectorKey to perform the statistic on and to plot per amp and per detector."
59 )
60 unit = Field[str](default="ADU", doc="Unit of quantity for including on z-axis label.")
62 def setDefaults(self):
63 super().setDefaults()
65 self.process.buildActions.z.vectorKey = "biasMean"
67 self.process.calculateActions.median = MedianAction()
68 self.process.calculateActions.median.vectorKey = "biasMean"
70 self.produce.plot.statistic = "median"
71 self.produce.plot.zAxisLabel = "Median of biasMean"
73 def finalize(self):
74 self.process.buildActions.z.vectorKey = self.quantityKey
75 self.process.calculateActions.median.vectorKey = self.quantityKey
76 self.produce.metric.units = {"median": "adu"}
77 zAxislabel = f"{self.produce.plot.statistic} of {self.quantityKey} ({self.unit})"
78 self.produce.plot.zAxisLabel = zAxislabel.capitalize()