diff --git a/pipelines/_ingredients/VerifyBias.yaml b/pipelines/_ingredients/VerifyBias.yaml index bec3205..dd84fac 100644 --- a/pipelines/_ingredients/VerifyBias.yaml +++ b/pipelines/_ingredients/VerifyBias.yaml @@ -21,6 +21,8 @@ tasks: doCalculateStatistics: true isrStats.doCopyCalibDistributionStatistics: true isrStats.doProjectionStatistics: true + isrStats.doBiasShiftStatistics: true + isrStats.doAmplifierCorrelationStatistics: true verifyMeasureStats: class: lsst.cp.verify.CpVerifyBiasTask config: diff --git a/python/lsst/cp/verify/verifyBias.py b/python/lsst/cp/verify/verifyBias.py index 81095c7..d27bde8 100644 --- a/python/lsst/cp/verify/verifyBias.py +++ b/python/lsst/cp/verify/verifyBias.py @@ -20,8 +20,11 @@ # along with this program. If not, see . import numpy as np -from .verifyStats import CpVerifyStatsConfig, CpVerifyStatsTask, CpVerifyStatsConnections +import lsst.afw.math as afwMath +from lsst.geom import Point2I, Extent2I, Box2I +from lsst.pex.config import Field +from .verifyStats import CpVerifyStatsConfig, CpVerifyStatsTask, CpVerifyStatsConnections __all__ = ['CpVerifyBiasConfig', 'CpVerifyBiasTask'] @@ -31,6 +34,12 @@ class CpVerifyBiasConfig(CpVerifyStatsConfig, """Inherits from base CpVerifyStatsConfig. """ + ampCornerBoxSize = Field( + dtype=int, + doc="Size of box to use for measure corner signal.", + default=200, + ) + def setDefaults(self): super().setDefaults() self.imageStatKeywords = {'MEAN': 'MEAN', # noqa F841 @@ -45,6 +54,31 @@ class CpVerifyBiasTask(CpVerifyStatsTask): ConfigClass = CpVerifyBiasConfig _DefaultName = 'cpVerifyBias' + def imageStatistics(self, exposure, uncorrectedExposure, statControl): + # Docstring inherited + outputStatistics = super().imageStatistics(exposure, uncorrectedExposure, statControl) + + boxSize = self.config.ampCornerBoxSize + statisticToRun = afwMath.stringToStatisticsProperty("MEAN") + + for ampIdx, amp in enumerate(exposure.getDetector()): + ampName = amp.getName() + + bbox = amp.getBBox() + xmin = bbox.getMaxX() - boxSize if amp.getRawFlipX() else bbox.getMinX() + ymin = bbox.getMaxY() - boxSize if amp.getRawFlipY() else bbox.getMinY() + llc = Point2I(xmin, ymin) + extent = Extent2I(boxSize, boxSize) + cornerBox = Box2I(llc, extent) + cornerExp = exposure[cornerBox] + + stats = afwMath.makeStatistics( + cornerExp.getMaskedImage(), statisticToRun, statControl + ) + outputStatistics[ampName]['AMP_CORNER'] = stats.getValue() + + return outputStatistics + def verify(self, exposure, statisticsDict): """Verify that the measured statistics meet the verification criteria. diff --git a/tests/test_verifyStats.py b/tests/test_verifyStats.py index d76f7c3..82b8aaa 100644 --- a/tests/test_verifyStats.py +++ b/tests/test_verifyStats.py @@ -154,6 +154,7 @@ def test_bias(self): """ config = cpVerify.CpVerifyBiasConfig() config.numSigmaClip = 3.0 + config.ampCornerBoxSize = 15 task = cpVerify.CpVerifyBiasTask(config=config) results = task.run(self.inputExp, self.camera) biasStats = results.outputStats