Coverage for python/lsst/cp/verify/verifyBias.py: 29%
Shortcuts 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
Shortcuts 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__ = ['CpVerifyBiasConfig', 'CpVerifyBiasTask']
29class CpVerifyBiasConfig(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', }
39 self.crImageStatKeywords = {'CR_NOISE': 'STDEV', } # noqa F841
42class CpVerifyBiasTask(CpVerifyStatsTask):
43 """Bias verification sub-class, implementing the verify method.
44 """
45 ConfigClass = CpVerifyBiasConfig
46 _DefaultName = 'cpVerifyBias'
48 def verify(self, exposure, statisticsDict):
49 """Verify that the measured statistics meet the verification criteria.
51 Parameters
52 ----------
53 exposure : `lsst.afw.image.Exposure`
54 The exposure the statistics are from.
55 statisticsDictionary : `dict` [`str`, `dict` [`str`, scalar]],
56 Dictionary of measured statistics. The inner dictionary
57 should have keys that are statistic names (`str`) with
58 values that are some sort of scalar (`int` or `float` are
59 the mostly likely types).
61 Returns
62 -------
63 outputStatistics : `dict` [`str`, `dict` [`str`, `bool`]]
64 A dictionary indexed by the amplifier name, containing
65 dictionaries of the verification criteria.
66 success : `bool`
67 A boolean indicating if all tests have passed.
68 """
69 detector = exposure.getDetector()
70 ampStats = statisticsDict['AMP']
72 verifyStats = {}
73 success = True
74 for ampName, stats in ampStats.items():
75 verify = {}
77 # DMTN-101 Test 4.2: Mean is 0.0 within noise.
78 verify['MEAN'] = bool(np.abs(stats['MEAN']) < stats['NOISE'])
80 # DMTN-101 Test 4.3: Clipped mean matches readNoise.
81 amp = detector[ampName]
82 verify['NOISE'] = bool(np.abs(stats['NOISE'] - amp.getReadNoise())/amp.getReadNoise() <= 0.05)
84 # DMTN-101 Test 4.4: CR rejection matches clipped mean.
85 verify['CR_NOISE'] = bool(np.abs(stats['NOISE'] - stats['CR_NOISE'])/stats['CR_NOISE'] <= 0.05)
87 verify['SUCCESS'] = bool(np.all(list(verify.values())))
88 if verify['SUCCESS'] is False:
89 success = False
91 verifyStats[ampName] = verify
93 return {'AMP': verifyStats}, bool(success)