Coverage for python/lsst/cp/verify/verifyDark.py : 29%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
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
23from .verifyStats import CpVerifyStatsConfig, CpVerifyStatsTask, CpVerifyStatsConnections
26__all__ = ['CpVerifyDarkConfig', 'CpVerifyDarkTask']
29class CpVerifyDarkConfig(CpVerifyStatsConfig,
30 pipelineConnections=CpVerifyStatsConnections):
31 """Inherits from base CpVerifyStatsConfig.
32 """
34 def setDefaults(self):
35 super().setDefaults()
36 self.imageStatKeywords = {'MEAN': 'MEAN', # noqa F841
37 'NOISE': 'STDEVCLIP', }
38 self.crImageStatKeywords = {'CR_NOISE': 'STDEV', } # noqa F841
41class CpVerifyDarkTask(CpVerifyStatsTask):
42 """Dark verification sub-class, implementing the verify method.
43 """
44 ConfigClass = CpVerifyDarkConfig
45 _DefaultName = 'cpVerifyDark'
47 def verify(self, exposure, statisticsDict):
48 """Verify that the measured statistics meet the verification criteria.
50 Parameters
51 ----------
52 exposure : `lsst.afw.image.Exposure`
53 The exposure the statistics are from.
54 statisticsDictionary : `dict` [`str`, `dict` [`str`, scalar]],
55 Dictionary of measured statistics. The inner dictionary
56 should have keys that are statistic names (`str`) with
57 values that are some sort of scalar (`int` or `float` are
58 the mostly likely types).
60 Returns
61 -------
62 outputStatistics : `dict` [`str`, `dict` [`str`, `bool`]]
63 A dictionary indexed by the amplifier name, containing
64 dictionaries of the verification criteria.
65 success : `bool`
66 A boolean indicating if all tests have passed.
67 """
68 detector = exposure.getDetector()
69 ampStats = statisticsDict['AMP']
70 verifyStats = {}
71 success = True
72 for ampName, stats in ampStats.items():
73 verify = {}
75 # DMTN-101 Test 5.2: Mean is 0.0:
76 verify['MEAN'] = bool(np.abs(stats['MEAN']) < stats['NOISE'])
78 # DMTN-101 Test 5.3: Clipped mean matches readNoise
79 amp = detector[ampName]
80 verify['NOISE'] = bool(np.abs(stats['NOISE'] - amp.getReadNoise())/amp.getReadNoise() <= 0.05)
82 # DMTN-101 Test 5.4: CR rejection matches clipped mean
83 verify['CR_NOISE'] = bool(np.abs(stats['NOISE'] - stats['CR_NOISE'])/stats['CR_NOISE'] <= 0.05)
85 verify['SUCCESS'] = bool(np.all(list(verify.values())))
86 if verify['SUCCESS'] is False:
87 success = False
89 verifyStats[ampName] = verify
91 return {'AMP': verifyStats}, bool(success)