Skip to content

Commit 10d8b5d

Browse files
authored
Merge pull request #412 from lsst/tickets/DM-50838
DM-50838: Add monitoring of HVBIAS keyword for IsrTaskLSST.
2 parents 81e1046 + 8fe0006 commit 10d8b5d

File tree

3 files changed

+109
-1
lines changed

3 files changed

+109
-1
lines changed

python/lsst/ip/isr/isrMockLSST.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -820,6 +820,7 @@ def makeImage(self):
820820
exposure.variance.array[:, :] = np.abs(np.median(exposure.image.array)/10.)
821821

822822
exposure.metadata["BSSVBS"] = 50.0
823+
exposure.metadata["HVBIAS"] = "ON"
823824

824825
if self.config.doGenerateAmpDict:
825826
expDict = dict()

python/lsst/ip/isr/isrTaskLSST.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,12 @@ class IsrTaskLSSTConfig(pipeBase.PipelineTaskConfig,
271271
doc="Back-side bias voltage header keyword. Only checked if doCheckUnprocessableData is True "
272272
"and bssVoltageMinimum is greater than 0.",
273273
)
274+
hvBiasKeyword = pexConfig.Field(
275+
dtype=str,
276+
default="HVBIAS",
277+
doc="Back-side bias voltage on/off header keyword. Only checked if doCheckUnprocessableData is True "
278+
"and bssVoltageMinimum is greater than 0.",
279+
)
274280

275281
# Amplifier to CCD assembly configuration.
276282
doAssembleCcd = pexConfig.Field(
@@ -1748,7 +1754,15 @@ def checkBssVoltage(self, exposure):
17481754
)
17491755
return
17501756

1751-
if voltage < self.config.bssVoltageMinimum:
1757+
hv = exposure.metadata.get(self.config.hvBiasKeyword, None)
1758+
if hv is None:
1759+
self.log.warning(
1760+
"HV bias on %s not found in metadata.",
1761+
self.config.hvBiasKeyword,
1762+
)
1763+
return
1764+
1765+
if voltage < self.config.bssVoltageMinimum or hv == "OFF":
17521766
detector = exposure.getDetector()
17531767
raise UnprocessableDataError(
17541768
f"Back-side bias voltage is turned off for {detector.getName()}; skipping ISR.",

tests/test_isrTaskLSST.py

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2085,6 +2085,99 @@ def test_overrideMaskBadAmp(self):
20852085
mask_array = result.exposure.mask.array
20862086
self.assertFalse(np.all((mask_array & bad_mask) > 0))
20872087

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+
20882181
def get_mock_config_no_signal(self):
20892182
"""Get an IsrMockLSSTConfig with all signal set to False.
20902183

0 commit comments

Comments
 (0)