Skip to content

Commit

Permalink
Add deferrecCharge test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex-Broughton committed Jan 10, 2025
1 parent 6cac926 commit 6fbf70c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pipelines/_ingredients/cpCti.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ tasks:
class: lsst.cp.pipe.CpCtiSolveTask
config:
connections.inputMeasurements: "cpCtiStatistics"
connections.outputCalib: "cpCtiCalib"
connections.outputCalib: "cpCti"
contracts:
- cpCtiSolve.connections.inputMeasurements == cpCtiIsr.connections.outputStatistics
2 changes: 1 addition & 1 deletion pipelines/_ingredients/cpCtiLSST.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ tasks:
class: lsst.cp.pipe.CpCtiSolveTask
config:
connections.inputMeasurements: "cpCtiStatistics"
connections.outputCalib: "cpCtiCalib"
connections.outputCalib: "cpCti"
contracts:
- cpCtiSolve.connections.inputMeasurements == cpCtiIsr.connections.outputStatistics
11 changes: 7 additions & 4 deletions python/lsst/cp/pipe/cpCtiSolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -867,8 +867,11 @@ def calcTurnoff(self, signalVec, dataVec, ctiRange, amp):
Returns
-------
turnoff : `float`
the turnoff point in the same units as the
The turnoff point in the same units as the
input signals
turnoffSamplingError : `float`
The sampling error of the turnoff point, equals
turnoff when not enough data points.
Notes
------
Expand All @@ -886,13 +889,13 @@ def calcTurnoff(self, signalVec, dataVec, ctiRange, amp):
# Check for remaining data points
if dataVec.size == 0:
self.log.warning("No data points after cti range cut to compute turnoff "
f" for amplifier {amp.getName()}. Setting turnoff point "
f"for amplifier {amp.getName()}. Setting turnoff point "
"to 0 el.")
return 0.0, 0.0

if dataVec.size < 2:
self.log.warning("Insufficient data points after cti range cut to compute turnoff "
f" for amplifier {amp.getName()}. Setting turnoff point "
f"for amplifier {amp.getName()}. Setting turnoff point "
"to the maximum signal value.")
return signalVec[-1], signalVec[-1]

Expand Down Expand Up @@ -947,4 +950,4 @@ def calcTurnoff(self, signalVec, dataVec, ctiRange, amp):
else:
samplingError = (signalVec[turnoffIdx+1] - signalVec[turnoffIdx-1]) / 2.0

return turnoff, np.abs(samplingError)
return turnoff, np.abs(np.float64(samplingError))
16 changes: 16 additions & 0 deletions tests/test_deferredCharge.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"""Test cases for lsst.cp.pipe.deferredCharge."""

import unittest
import numpy

import lsst.utils
import lsst.utils.tests
Expand Down Expand Up @@ -277,6 +278,11 @@ def test_task(self):
results = self.task.run(self.inputMeasurements, self.camera, self.inputDims)

calib = results.outputCalib

# Check that the signals array is sorted
for ampName in calib.signals.keys():
assert numpy.all(numpy.diff(calib.signals[ampName]) > 0)

# Check that the result matches expectation.
self.assertAlmostEqual(calib.globalCti['C:0,0'], 1.0e-7, 4)
self.assertAlmostEqual(calib.driftScale['C:0,0'], 1.8105e-4, 4)
Expand All @@ -287,6 +293,16 @@ def test_task(self):
self.assertEqual(calib.globalCti['C:0,0'], calib.globalCti[ampName])
self.assertEqual(calib.driftScale['C:0,0'], calib.driftScale[ampName])
self.assertEqual(calib.decayTime['C:0,0'], calib.decayTime[ampName])
self.assertEqual(calib.signals[ampName][-2], calib.serialCtiTurnoff[ampName])
self.assertEqual(calib.signals[ampName][-1], calib.parallelCtiTurnoff[ampName])
self.assertEqual(
(calib.signals[ampName][-1] - calib.signals[ampName][-3]) / 2.0,
calib.serialCtiTurnoffSamplingErr[ampName],
)
self.assertEqual(
calib.signals[ampName][-1] - calib.signals[ampName][-2],
calib.parallelCtiTurnoffSamplingErr[ampName],
)


class TestMemory(lsst.utils.tests.MemoryTestCase):
Expand Down

0 comments on commit 6fbf70c

Please sign in to comment.