Skip to content

Commit

Permalink
Switch to calibrateImage
Browse files Browse the repository at this point in the history
Update test values to reflect the changed outputs.
The image and background mean and std values went up by a factor of ~2,
because the CalibrateImage output (`initial_pvi`) is photometrically
calibrated, and the fitted calibration is ~2.18.
  • Loading branch information
parejkoj committed Sep 16, 2024
1 parent e18f075 commit e7ef711
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 41 deletions.
10 changes: 3 additions & 7 deletions tests/test_butler.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import unittest

from lsst.daf.butler import Butler
from lsst.daf.base import PropertySet
from lsst.pipe.base import TaskMetadata

TESTDIR = os.path.abspath(os.path.dirname(__file__))
Expand Down Expand Up @@ -70,20 +69,17 @@ def testMetadata(self):
dataId = {"instrument": "HSC", "visit": 903342, "detector": 10}
collection = "demo_collection"

cal = self.butler.get("calibrate_metadata", dataId=dataId, collections=collection)
cal = self.butler.get("calibrateImage_metadata", dataId=dataId, collections=collection)
isr = self.butler.get("isr_metadata", dataId=dataId, collections=collection, exposure=903342)
charImage = self.butler.get("characterizeImage_metadata", dataId=dataId, collections=collection)

# Confirm only calibrate task uses PropertySet.
self.assertIsInstance(cal, PropertySet)
self.assertIsInstance(cal, TaskMetadata)
self.assertIsInstance(isr, TaskMetadata)
self.assertIsInstance(charImage, TaskMetadata)

# Check that they both have a quantum entry.
self.assertIn("quantum.startUtc", isr)

# PropertySet.__contains__ does not support "."
self.assertIn("quantum.startUtc", cal.names(topLevelOnly=False))
self.assertIn("quantum.startUtc", cal)

def testExecutionButler(self):
"""Check outputs match in both runs."""
Expand Down
69 changes: 35 additions & 34 deletions tests/test_validate_outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ def setUp(self):
self.detector = 10
self.visit = 903342

def test_calexp(self):
"""Test quantities in the calexp."""
exposure = self.butler.get("calexp", detector=self.detector, visit=self.visit)
def test_exposure(self):
"""Test quantities in the output exposure."""
exposure = self.butler.get("initial_pvi", detector=self.detector, visit=self.visit)

self.assertEqual(exposure.getBBox(),
geom.Box2I(geom.Point2I(0, 0), geom.Extent2I(2048, 4176)))
Expand Down Expand Up @@ -77,26 +77,27 @@ def test_calexp(self):
# running the test to determine the updated values.
expected_places = 6
for name, var, val in [
("im_mean", im_mean, 4.3885845565891),
("im_std", im_std, 163.46922027517536),
("var_mean", var_mean, 51.764979094464934),
("var_std", var_std, 48.19498276625069),
("num_good_pix", num_good_pix, 7725755.00000000000000),
("psf_ixx", psf_ixx, 4.253191896391297),
("psf_iyy", psf_iyy, 4.687397483153177),
("psf_ixy", psf_ixy, -0.57911628487574),
("summary.psfSigma", summary.psfSigma, 2.11203591780044),
("summary.psfIxx", summary.psfIxx, 4.272794013403168),
("summary.psfIyy", summary.psfIyy, 4.735316824053334),
("summary.psfIxy", summary.psfIxy, -0.57899030354606),
("summary.psfArea", summary.psfArea, 82.65495879853161),
("summary.ra", summary.ra, 320.75894004802291),
("summary.dec", summary.dec, -0.23498192412129),
("summary.zenithDistance", summary.zenithDistance, 21.04574864469552),
("summary.zeroPoint", summary.zeroPoint, 30.548692694925332),
("summary.skyBg", summary.skyBg, 179.06974010169506),
("summary.skyNoise", summary.skyNoise, 7.379652920569057),
("summary.meanVar", summary.meanVar, 47.65954782565453),
# TODO: mean and stddev went up by ~2x: why?
("im_mean", im_mean, 9.570312903430354),
("im_std", im_std, 358.0813767518804),
("var_mean", var_mean, 258.7046967471461),
("var_std", var_std, 253.90647669885348),
("num_good_pix", num_good_pix, 7755316),
("psf_ixx", psf_ixx, 4.266612709669518),
("psf_iyy", psf_iyy, 4.683723243116094),
("psf_ixy", psf_ixy, -0.5839513515277733),
("summary.psfSigma", summary.psfSigma, 2.1140426108341264),
("summary.psfIxx", summary.psfIxx, 4.2881403687668715),
("summary.psfIyy", summary.psfIyy, 4.737163525163974),
("summary.psfIxy", summary.psfIxy, -0.5831694374862149),
("summary.psfArea", summary.psfArea, 82.34258460422038),
("summary.ra", summary.ra, 320.7589334460734),
("summary.dec", summary.dec, -0.23498074547048764),
("summary.zenithDistance", summary.zenithDistance, 21.045745454754197),
("summary.zeroPoint", summary.zeroPoint, 31.4),
("summary.skyBg", summary.skyBg, 392.2961827814579),
("summary.skyNoise", summary.skyNoise, 16.165210151318202),
("summary.meanVar", summary.meanVar, 239.16944416399647),
]:
# Uncomment following line to get replacement code when
# values need updating.
Expand All @@ -106,28 +107,28 @@ def test_calexp(self):

def test_background(self):
"""Test background level."""
bkg = self.butler.get("calexpBackground", detector=self.detector, visit=self.visit)
bkg = self.butler.get("initial_pvi_background", detector=self.detector, visit=self.visit)

bg0_arr = bkg.getImage().array
bg_mean = bg0_arr.mean(dtype=np.float64)
bg_std = bg0_arr.std(dtype=np.float64)

for name, var, val in (
("calexpBackground mean", bg_mean, 179.2836464883374),
("calexpBackground stddev", bg_std, 0.8296105383233686),
("initial_pvi_background mean", bg_mean, 392.7657501819754),
("initial_pvi_background stddev", bg_std, 1.8123588443639238),
):
with self.subTest(name):
self.assertAlmostEqual(var, val, places=7, msg=name)

def test_ic_src(self):
"""Test icSrc catalog."""
ic_src = self.butler.get("icSrc", detector=self.detector, visit=self.visit)
self.assertEqual(len(ic_src), 266)
def test_initial_psf_stars(self):
initial_psf_stars = self.butler.get("initial_psf_stars_detector",
detector=self.detector, visit=self.visit)
self.assertEqual(len(initial_psf_stars), 266)

def test_src(self):
"""Test src catalog."""
src = self.butler.get("src", detector=self.detector, visit=self.visit)
self.assertEqual(len(src), 1363)
def test_initial_stars(self):
initial_stars = self.butler.get("initial_stars_detector",
detector=self.detector, visit=self.visit)
self.assertEqual(len(initial_stars), 445)


def setup_module(module):
Expand Down

0 comments on commit e7ef711

Please sign in to comment.