Coverage for python/lsst/cp/verify/verifyCrosstalk.py: 45%
27 statements
« prev ^ index » next coverage.py v6.5.0, created at 2022-11-06 22:17 +0000
« prev ^ index » next coverage.py v6.5.0, created at 2022-11-06 22:17 +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):
58 """Calculate detector level statistics from the calibration.
60 Parameters
61 ----------
62 inputCalib : `lsst.ip.isr.IsrCalib`
63 The calibration to verify.
65 Returns
66 -------
67 outputStatistics : `dict` [`str`, scalar]
68 A dictionary of the statistics measured and their values.
69 """
70 outputStatistics = {}
71 outputStatistics['N_VALID'] = int(np.sum(inputCalib.coeffValid))
72 outputStatistics['N_AMP'] = inputCalib.nAmp
74 return outputStatistics
76 def verify(self, calib, statisticsDict):
77 """Verify that the calibration meets the verification criteria.
79 Parameters
80 ----------
81 inputCalib : `lsst.ip.isr.IsrCalib`
82 The calibration to verify.
83 statisticsDictionary : `dict` [`str`, `dict` [`str`, scalar]],
84 Dictionary of measured statistics. The inner dictionary
85 should have keys that are statistic names (`str`) with
86 values that are some sort of scalar (`int` or `float` are
87 the mostly likely types).
89 Returns
90 -------
91 outputStatistics : `dict` [`str`, `dict` [`str`, `bool`]]
92 A dictionary indexed by the amplifier name, containing
93 dictionaries of the verification criteria.
94 success : `bool`
95 A boolean indicating whether all tests have passed.
96 """
97 verifyStats = {}
98 detectorStats = statisticsDict['DET']
99 success = True
100 verifyStats['NO_SIGNIFICANT_DETECTION'] = True
102 if detectorStats['N_VALID'] > 0:
103 verifyStats['NO_SIGNIFICANT_DETECTION'] = False
104 success = False
106 return verifyStats, success