Skip to content

Commit

Permalink
Add unittest for disabling summary stats updates
Browse files Browse the repository at this point in the history
  • Loading branch information
laurenam committed Sep 29, 2024
1 parent 6364231 commit 6d2c471
Showing 1 changed file with 39 additions and 1 deletion.
40 changes: 39 additions & 1 deletion tests/test_computeExposureSummaryStats.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,50 @@ def testComputeExposureSummary(self):
background.append(backobj)

# Configure and run the task
expSummaryTaskNoUpdates = ComputeExposureSummaryStatsTask()
expSummaryTask = ComputeExposureSummaryStatsTask()
# Configure nominal values for effective time calculation
expSummaryTask.config.fiducialZeroPoint = {band: float(zp)}
expSummaryTask.config.fiducialPsfSigma = {band: float(psfSize)}
expSummaryTask.config.fiducialSkyBackground = {band: float(skyMean)}
# Run the task

# Run the task with optianal updates turned off
expSummaryTaskNoUpdates.config.doUpdatePsfModelStats = False
expSummaryTaskNoUpdates.config.doUpdateApCorrModelStats = False
expSummaryTaskNoUpdates.config.doUpdateMaxDistToNearestPsfStats = False
expSummaryTaskNoUpdates.config.doUpdateWcsStats = False
expSummaryTaskNoUpdates.config.doUpdatePhotoCalibStats = False
expSummaryTaskNoUpdates.config.doUpdateBackgroundStats = False
expSummaryTaskNoUpdates.config.doUpdateMaskedImageStats = False
expSummaryTaskNoUpdates.config.doUpdateEffectiveTimeStats = False

summary = expSummaryTaskNoUpdates.run(exposure, None, background)
# Test the outputs
self.assertTrue(np.isnan(summary.ra))
self.assertTrue(np.isnan(summary.dec))

# The following PSF metrics are always updated
self.assertFloatsAlmostEqual(summary.expTime, expTime)
self.assertFloatsAlmostEqual(summary.psfSigma, psfSize)
self.assertFloatsAlmostEqual(summary.psfIxx, psfSize**2.)
self.assertFloatsAlmostEqual(summary.psfIyy, psfSize**2.)
self.assertFloatsAlmostEqual(summary.psfIxy, 0.0)
self.assertFloatsAlmostEqual(summary.psfArea, 23.088975164455444)

# The following should not have been updated (i.e. set to nan)
self.assertTrue(np.isnan(summary.psfTraceRadiusDelta))
self.assertTrue(np.isnan(summary.psfApFluxDelta))
self.assertTrue(np.isnan(summary.psfApCorrSigmaScaledDelta))
self.assertTrue(np.isnan(summary.maxDistToNearestPsf))
self.assertTrue(np.isnan(summary.pixelScale))

self.assertTrue(np.isnan(summary.zenithDistance))
self.assertTrue(np.isnan(summary.skyBg))
self.assertTrue(np.isnan(summary.skyNoise))
self.assertTrue(np.isnan(summary.meanVar))
self.assertTrue(np.isnan(summary.zeroPoint))

# Run the task with updates
summary = expSummaryTask.run(exposure, None, background)

# Test the outputs
Expand Down

0 comments on commit 6d2c471

Please sign in to comment.