Coverage for python/lsst/cp/verify/verifyCrosstalk.py: 45%
29 statements
« prev ^ index » next coverage.py v7.3.2, created at 2023-11-11 11:18 +0000
« prev ^ index » next coverage.py v7.3.2, created at 2023-11-11 11:18 +0000
1# This file is part of cp_verify.
2#
3# Developed for the LSST Data Management System.
4# This product includes software developed by the LSST Project
5# (http://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 <http://www.gnu.org/licenses/>.
21import numpy as np
23import lsst.pipe.base.connectionTypes as cT
24from .verifyCalib import CpVerifyCalibConfig, CpVerifyCalibTask, CpVerifyCalibConnections
27__all__ = ['CpVerifyCrosstalkConfig', 'CpVerifyCrosstalkTask']
30class CpVerifyCrosstalkConnections(CpVerifyCalibConnections,
31 dimensions={"instrument", "detector"},
32 defaultTemplates={}):
33 inputCalib = cT.Input(
34 name="calib",
35 doc="Input calib to calculate statistics for.",
36 storageClass="CrosstalkCalib",
37 dimensions=["instrument", "detector"],
38 isCalibration=True
39 )
42class CpVerifyCrosstalkConfig(CpVerifyCalibConfig,
43 pipelineConnections=CpVerifyCrosstalkConnections):
44 """Inherits from base CpVerifyCalibConfig."""
46 def setDefaults(self):
47 super().setDefaults()
48 self.calibStatKeywords = {'SNR': ''} # noqa F841
51class CpVerifyCrosstalkTask(CpVerifyCalibTask):
52 """Crosstalk verification sub-class, implementing the verify method.
53 """
54 ConfigClass = CpVerifyCrosstalkConfig
55 _DefaultName = 'cpVerifyCrosstalk'
57 def detectorStatistics(self, inputCalib, camera=None):
58 """Calculate detector level statistics from the calibration.
60 Parameters
61 ----------
62 inputCalib : `lsst.ip.isr.IsrCalib`
63 The calibration to verify.
64 camera : `lsst.afw.cameraGeom.Camera`, optional
65 Input camera.
67 Returns
68 -------
69 outputStatistics : `dict` [`str`, scalar]
70 A dictionary of the statistics measured and their values.
71 """
72 outputStatistics = {}
73 outputStatistics['N_VALID'] = int(np.sum(inputCalib.coeffValid))
74 outputStatistics['N_AMP'] = inputCalib.nAmp
76 return outputStatistics
78 def amplifierStatistics(self, inputCalib, camera=None):
79 """Calculate amplifier level statistics from the calibration.
81 Parameters
82 ----------
83 inputCalib : `lsst.ip.isr.IsrCalib`
84 The calibration to verify.
85 camera : `lsst.afw.cameraGeom.Camera`, optional
86 Input camera.
88 Returns
89 -------
90 outputStatistics : `dict` [`str`, scalar]
91 A dictionary of the statistics measured and their values.
92 """
94 pass
96 def verify(self, calib, statisticsDict, camera=None):
97 """Verify that the calibration meets the verification criteria.
99 Parameters
100 ----------
101 inputCalib : `lsst.ip.isr.IsrCalib`
102 The calibration to verify.
103 statisticsDictionary : `dict` [`str`, `dict` [`str`, scalar]],
104 Dictionary of measured statistics. The inner dictionary
105 should have keys that are statistic names (`str`) with
106 values that are some sort of scalar (`int` or `float` are
107 the mostly likely types).
108 camera : `lsst.afw.cameraGeom.Camera`, optional
109 Input camera.
111 Returns
112 -------
113 outputStatistics : `dict` [`str`, `dict` [`str`, `bool`]]
114 A dictionary indexed by the amplifier name, containing
115 dictionaries of the verification criteria.
116 success : `bool`
117 A boolean indicating whether all tests have passed.
118 """
119 verifyStats = {}
120 detectorStats = statisticsDict['DET']
121 success = True
122 verifyStats['NO_SIGNIFICANT_DETECTION'] = True
124 if detectorStats['N_VALID'] > 0:
125 verifyStats['NO_SIGNIFICANT_DETECTION'] = False
126 success = False
128 return verifyStats, success