Coverage for python/lsst/analysis/tools/atools/calibration.py: 41%
64 statements
« prev ^ index » next coverage.py v7.4.4, created at 2024-03-28 04:17 -0700
« prev ^ index » next coverage.py v7.4.4, created at 2024-03-28 04:17 -0700
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 "CalibStatisticFocalPlanePlot",
25 "PtcGainFP",
26 "PtcNoiseFP",
27 "PtcA00FP",
28 "PtcTurnoffFP",
29 "PtcMaxRawMeansFP",
30 "PtcRowMeanVarianceSlopeFP",
31)
33from lsst.pex.config import Field
35from ..actions.plot.focalPlanePlot import FocalPlaneGeometryPlot
36from ..actions.vector import LoadVector
37from ..interfaces import AnalysisTool
40class CalibrationTool(AnalysisTool):
41 """Class to generate common calibration metrics for value/scatter
42 quantities.
43 """
45 parameterizedBand: bool = False
47 def setDefaults(self):
48 self.process.buildActions.x = LoadVector(vectorKey="detector")
49 self.process.buildActions.y = LoadVector(vectorKey="amplifier")
50 self.process.buildActions.detector = LoadVector(vectorKey="detector")
51 self.process.buildActions.amplifier = LoadVector(vectorKey="amplifier")
52 self.process.buildActions.z = LoadVector()
54 self.produce.plot = FocalPlaneGeometryPlot()
55 self.produce.plot.statistic = "median"
58class CalibStatisticFocalPlanePlot(CalibrationTool):
59 """Generates a plot of the focal plane, color-coded according to the
60 median of a given measurement (default: "biasMean") on a per-amp basis.
61 The median is across multiple bias exposures.
62 """
64 quantityKey = Field[str](
65 default="biasMean", doc="VectorKey to perform the statistic on and to plot per amp and per detector."
66 )
67 unit = Field[str](default="ADU", doc="Unit of quantity for including on z-axis label.")
69 def setDefaults(self):
70 super().setDefaults()
72 self.process.buildActions.z.vectorKey = "biasMean"
74 self.produce.plot.statistic = "median"
75 self.produce.plot.zAxisLabel = "Median of biasMean"
77 def finalize(self):
78 self.process.buildActions.z.vectorKey = self.quantityKey
79 zAxislabel = f"{self.produce.plot.statistic} of {self.quantityKey} ({self.unit})"
80 self.produce.plot.zAxisLabel = zAxislabel.capitalize()
83class PtcGainFP(CalibrationTool):
84 def setDefaults(self):
85 super().setDefaults()
86 self.process.buildActions.z.vectorKey = "ptcGain"
87 self.produce.plot.zAxisLabel = "PTC Gain (e-/ADU)"
88 self.produce.metric.newNames = {"z": "PTC_GAIN"}
91class PtcNoiseFP(CalibrationTool):
92 def setDefaults(self):
93 super().setDefaults()
94 self.process.buildActions.z.vectorKey = "ptcNoise"
95 self.produce.plot.zAxisLabel = "PTC Readout Noise (ADU^2)"
96 self.produce.metric.newNames = {"z": "PTC_NOISE"}
99class PtcA00FP(CalibrationTool):
100 def setDefaults(self):
101 super().setDefaults()
102 self.process.buildActions.z.vectorKey = "ptcBfeA00"
103 self.produce.plot.zAxisLabel = "PTC BFE A00 (1/e-)"
104 self.produce.metric.newNames = {"z": "PTC_BFE_A00"}
107class PtcTurnoffFP(CalibrationTool):
108 def setDefaults(self):
109 super().setDefaults()
110 self.process.buildActions.z.vectorKey = "ptcTurnoff"
111 self.produce.plot.zAxisLabel = "PTC turnoff (ADU)"
112 self.produce.metric.newNames = {"z": "PTC_TURNOFF"}
115class PtcMaxRawMeansFP(CalibrationTool):
116 def setDefaults(self):
117 super().setDefaults()
118 self.process.buildActions.z.vectorKey = "ptcMaxRawMeans"
119 self.produce.plot.zAxisLabel = "PTC Maximum of Raw Mean Flux (ADU)"
120 self.produce.metric.newNames = {"z": "PTC_MAX_RAW_MEANS"}
123class PtcRowMeanVarianceSlopeFP(CalibrationTool):
124 def setDefaults(self):
125 super().setDefaults()
126 self.process.buildActions.z.vectorKey = "ptcRowMeanVarianceSlope"
127 self.produce.plot.zAxisLabel = "PTC slope of row means vs variance (e-)"
128 self.produce.metric.newNames = {"z": "PTC_ROW_MEAN_VARIANCE_SLOPE"}