Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-42159: eo_pipe/cp_verify parity: bias #38

Merged
merged 5 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions pipelines/_ingredients/VerifyBias.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
36 changes: 35 additions & 1 deletion python/lsst/cp/verify/verifyBias.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
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']

Expand All @@ -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
Expand All @@ -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.

Expand Down
1 change: 1 addition & 0 deletions tests/test_verifyStats.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down