@@ -2085,6 +2085,99 @@ def test_overrideMaskBadAmp(self):
2085
2085
mask_array = result .exposure .mask .array
2086
2086
self .assertFalse (np .all ((mask_array & bad_mask ) > 0 ))
2087
2087
2088
+ def test_hvBiasChecks (self ):
2089
+ """Test the HVBIAS checks."""
2090
+ # We use a flat frame for this test for convenience.
2091
+ mock_config = self .get_mock_config_no_signal ()
2092
+ mock_config .doAddDark = True
2093
+ mock_config .doAddFlat = True
2094
+ # The doAddSky option adds the equivalent of flat-field flux.
2095
+ mock_config .doAddSky = True
2096
+
2097
+ mock = isrMockLSST .IsrMockLSST (config = mock_config )
2098
+ input_exp = mock .run ()
2099
+
2100
+ isr_config = self .get_isr_config_electronic_corrections ()
2101
+ isr_config .doBias = True
2102
+ isr_config .doDark = True
2103
+ isr_config .doFlat = False
2104
+ isr_config .doDefect = True
2105
+
2106
+ # Set the voltage.
2107
+ input_exp .metadata ["HVBIAS" ] = "OFF"
2108
+
2109
+ # Check that processing runs with checks turned off.
2110
+ isr_config .doCheckUnprocessableData = False
2111
+
2112
+ isr_task = IsrTaskLSST (config = isr_config )
2113
+ with self .assertNoLogs (level = logging .WARNING ):
2114
+ _ = isr_task .run (
2115
+ input_exp .clone (),
2116
+ bias = self .bias ,
2117
+ dark = self .dark ,
2118
+ crosstalk = self .crosstalk ,
2119
+ ptc = self .ptc ,
2120
+ linearizer = self .linearizer ,
2121
+ defects = self .defects ,
2122
+ deferredChargeCalib = self .cti ,
2123
+ )
2124
+
2125
+ # Check that processing runs with other way of turning checks off.
2126
+ isr_config .doCheckUnprocessableData = True
2127
+ isr_config .bssVoltageMinimum = 0.0
2128
+
2129
+ isr_task = IsrTaskLSST (config = isr_config )
2130
+ with self .assertNoLogs (level = logging .WARNING ):
2131
+ _ = isr_task .run (
2132
+ input_exp .clone (),
2133
+ bias = self .bias ,
2134
+ dark = self .dark ,
2135
+ crosstalk = self .crosstalk ,
2136
+ ptc = self .ptc ,
2137
+ linearizer = self .linearizer ,
2138
+ defects = self .defects ,
2139
+ deferredChargeCalib = self .cti ,
2140
+ )
2141
+
2142
+ # Check that processing runs but warns if header keyword is None.
2143
+ isr_config .doCheckUnprocessableData = True
2144
+ isr_config .bssVoltageMinimum = 10.0
2145
+
2146
+ input_exp2 = input_exp .clone ()
2147
+ input_exp2 .metadata ["HVBIAS" ] = None
2148
+
2149
+ isr_task = IsrTaskLSST (config = isr_config )
2150
+ with self .assertLogs (level = logging .WARNING ) as cm :
2151
+ _ = isr_task .run (
2152
+ input_exp2 ,
2153
+ bias = self .bias ,
2154
+ dark = self .dark ,
2155
+ crosstalk = self .crosstalk ,
2156
+ ptc = self .ptc ,
2157
+ linearizer = self .linearizer ,
2158
+ defects = self .defects ,
2159
+ deferredChargeCalib = self .cti ,
2160
+ )
2161
+ self .assertEqual (len (cm .output ), 1 )
2162
+ self .assertIn ("HV bias on HVBIAS not found in metadata" , cm .output [0 ])
2163
+
2164
+ # Check that it raises.
2165
+ isr_config .doCheckUnprocessableData = True
2166
+ isr_config .bssVoltageMinimum = 10.0
2167
+
2168
+ isr_task = IsrTaskLSST (config = isr_config )
2169
+ with self .assertRaises (UnprocessableDataError ):
2170
+ _ = isr_task .run (
2171
+ input_exp .clone (),
2172
+ bias = self .bias ,
2173
+ dark = self .dark ,
2174
+ crosstalk = self .crosstalk ,
2175
+ ptc = self .ptc ,
2176
+ linearizer = self .linearizer ,
2177
+ defects = self .defects ,
2178
+ deferredChargeCalib = self .cti ,
2179
+ )
2180
+
2088
2181
def get_mock_config_no_signal (self ):
2089
2182
"""Get an IsrMockLSSTConfig with all signal set to False.
2090
2183
0 commit comments