Skip to content

Commit

Permalink
Refactor classes
Browse files Browse the repository at this point in the history
  • Loading branch information
plazas committed Feb 8, 2024
1 parent 090b03e commit 3bd5367
Showing 1 changed file with 22 additions and 42 deletions.
64 changes: 22 additions & 42 deletions python/lsst/analysis/tools/atools/calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,40 +37,22 @@

class CalibrationTool(AnalysisTool):
"""Class to generate common calibration metrics for value/scatter
quantities (from python/lsst/analysis/tools/atools/cpMetrics.py
in DM-40473)
quantities.
"""

parameterizedBand: bool = False

def __init_subclass__(cls, **kwargs):
super().__init_subclass__(**kwargs)

cls.units = {}
cls.newNames = {}

def addFpPlot(self, vectorKey, statistic, label):
"""Add focal plan geometry plot.
Parameters
----------
vectorKey : `str`
Name of the catalog key to load.
statistic : `str`
Statistic to use in binning per-amplifier data points.
label : `str`
Label to apply to the output z-axis.
"""
def setDefaults(self):
self.process.buildActions.x = LoadVector(vectorKey="detector")
self.process.buildActions.y = LoadVector(vectorKey="amplifier")
self.process.buildActions.detector = LoadVector(vectorKey="detector")
self.process.buildActions.amplifier = LoadVector(vectorKey="amplifier")
self.process.buildActions.z = LoadVector(vectorKey=vectorKey)
self.process.buildActions.z = LoadVector()

self.produce.plot = FocalPlaneGeometryPlot()
self.produce.plot.statistic = statistic
self.produce.plot.statistic = "median"
self.produce.plot.xAxisLabel = "x (focal plane)"
self.produce.plot.yAxisLabel = "y (focal plane)"
self.produce.plot.zAxisLabel = label


class MedReadNoiseFocalPlanePlot(AnalysisTool):
Expand All @@ -90,8 +72,6 @@ def setDefaults(self):
self.process.buildActions.amplifier.vectorKey = "amplifier"

self.produce.plot = FocalPlaneGeometryPlot()
# TO DO: In anticipation of the addHistogram option
# self.produce.plot.addHistogram = True
self.produce.plot.xAxisLabel = "x (mm)"
self.produce.plot.yAxisLabel = "y (mm)"
self.produce.plot.zAxisLabel = "Med. Readnoise"
Expand All @@ -101,46 +81,46 @@ def setDefaults(self):
class PtcGainFP(CalibrationTool):
def setDefaults(self):
super().setDefaults()
# This should only have one entry, so the statistic doesn't
# matter much.
self.addFpPlot("ptcGain", "median", "PTC gain")
self.process.buildActions.z.vectorKey = "ptcGain"
self.produce.plot.zAxisLabel = "PTC Gain (ADU)"
self.produce.metric.newNames = {"z": "PTC_GAIN"}


class PtcNoiseFP(CalibrationTool):
def setDefaults(self):
super().setDefaults()
# This should only have one entry, so the statistic doesn't
# matter much.
self.addFpPlot("ptcNoise", "median", "PTC read noise")
self.process.buildActions.z.vectorKey = "ptcNoise"
self.produce.plot.zAxisLabel = "PTC Readout Noise (ADU^2)"
self.produce.metric.newNames = {"z": "PTC_NOISE"}


class PtcA00FP(CalibrationTool):
def setDefaults(self):
super().setDefaults()
# This should only have one entry, so the statistic doesn't
# matter much.
self.addFpPlot("ptcBfeA00", "median", "PTC BFE A00")
self.process.buildActions.z.vectorKey = "ptcBfeA00"
self.produce.plot.zAxisLabel = "PTC BFE A00 (1/e-)"
self.produce.metric.newNames = {"z": "PTC_BFE_A00"}


class PtcTurnoffFP(CalibrationTool):
def setDefaults(self):
super().setDefaults()
# This should only have one entry, so the statistic doesn't
# matter much.
self.addFpPlot("ptcTurnoff", "median", "PTC turnoff")
self.process.buildActions.z.vectorKey = "ptcTurnoff"
self.produce.plot.zAxisLabel = "PTC turnoff (ADU)"
self.produce.metric.newNames = {"z": "PTC_TURNOFF"}


class PtcMaxRawMeansFP(CalibrationTool):
def setDefaults(self):
super().setDefaults()
# This should only have one entry, so the statistic doesn't
# matter much.
self.addFpPlot("ptcMaxRawMeans", "median", "PTC max of raw means")
self.process.buildActions.z.vectorKey = "ptcMaxRawMeans"
self.produce.plot.zAxisLabel = "PTC Maximum of Raw Mean Flux (ADU)"
self.produce.metric.newNames = {"z": "PTC_MAX_RAW_MEANS"}


class PtcRowMeanVarianceSlopeFP(CalibrationTool):
def setDefaults(self):
super().setDefaults()
# This should only have one entry, so the statistic doesn't
# matter much.
self.addFpPlot("ptcRowMeanVarianceSlope", "median", "PTC slope of row means vs variance")
self.process.buildActions.z.vectorKey = "ptcRowMeanVarianceSlope"
self.produce.plot.zAxisLabel = "PTC slope of row means vs variance (e-)"
self.produce.metric.newNames = {"z": "PTC_ROW_MEAN_VARIANCE_SLOPE"}

0 comments on commit 3bd5367

Please sign in to comment.