diff --git a/python/lsst/pipe/tasks/calibrateImage.py b/python/lsst/pipe/tasks/calibrateImage.py index a5d926a43..7616cfb7a 100644 --- a/python/lsst/pipe/tasks/calibrateImage.py +++ b/python/lsst/pipe/tasks/calibrateImage.py @@ -391,6 +391,9 @@ def setDefaults(self): # Keep sky sources in the output catalog, even though they aren't # wanted for calibration. self.star_selector["science"].doSkySources = True + # Set the flux and error fields + self.star_selector["science"].signalToNoise.fluxField = "slot_CalibFlux_instFlux" + self.star_selector["science"].signalToNoise.errField = "slot_CalibFlux_instFluxErr" # Use the affine WCS fitter (assumes we have a good camera geometry). self.astrometry.wcsFitter.retarget(lsst.meas.astrom.FitAffineWcsTask) @@ -986,6 +989,9 @@ def _fit_photometry(self, exposure, stars): unchanged. stars : `lsst.afw.table.SourceCatalog` Good stars selected for use in calibration. + background : `lsst.afw.math.BackgroundList` + Background that was fit to the exposure during detection of the + above stars. Returns ------- diff --git a/python/lsst/pipe/tasks/photoCal.py b/python/lsst/pipe/tasks/photoCal.py index 57118e426..b79fdae59 100644 --- a/python/lsst/pipe/tasks/photoCal.py +++ b/python/lsst/pipe/tasks/photoCal.py @@ -103,6 +103,12 @@ def validate(self): raise RuntimeError("applyColorTerms=True requires photoCatName is non-None") if self.applyColorTerms and len(self.colorterms.data) == 0: raise RuntimeError("applyColorTerms=True requires colorterms be provided") + if self.fluxField != self.match.sourceSelection.signalToNoise.fluxField: + raise RuntimeError("Configured flux field %s does not match source selector field %s", + self.fluxField, self.match.sourceSelection.signalToNoise.fluxField) + if self.fluxField + "Err" != self.match.sourceSelection.signalToNoise.errField: + raise RuntimeError("Configured flux field %sErr does not match source selector error field %s", + self.fluxField, self.match.sourceSelection.signalToNoise.errField) def setDefaults(self): pexConf.Config.setDefaults(self) @@ -114,6 +120,10 @@ def setDefaults(self): "base_PixelFlags_flag_saturated", ] self.match.sourceSelection.doUnresolved = True + self.match.sourceSelection.doSignalToNoise = True + self.match.sourceSelection.signalToNoise.minimum = 10.0 + self.match.sourceSelection.signalToNoise.fluxField = self.fluxField + self.match.sourceSelection.signalToNoise.errField = self.fluxField + "Err" class PhotoCalTask(pipeBase.Task): @@ -322,12 +332,8 @@ def run(self, exposure, sourceCat, expId=0): ---------- exposure : `lsst.afw.image.Exposure` Exposure upon which the sources in the matches were detected. - sourceCat : `lsst.afw.image.SourceCatalog` - A catalog of sources to use in the calibration - (i.e. a `list` of `lsst.afw.table.Match` with - first being of type `lsst.afw.table.SimpleRecord` and second type `lsst.afw.table.SourceRecord` - the reference object and matched object respectively). - Will not be modified except to set the outputField if requested. + sourceCat : `lsst.afw.table.SourceCatalog` + Good stars selected for use in calibration. expId : `int`, optional Exposure ID. diff --git a/tests/test_calibrateImage.py b/tests/test_calibrateImage.py index 3dad0b3c4..4bf941fd8 100644 --- a/tests/test_calibrateImage.py +++ b/tests/test_calibrateImage.py @@ -189,7 +189,7 @@ def _check_run(self, calibrate, result, expect_calibrated_pixels: bool = True): self.assertEqual(result.stars["slot_PsfFlux_mag"].unit, u.ABmag) # Should have detected all S/N >= 10 sources plus 2 sky sources, whether 1 or 2 snaps. - self.assertEqual(len(result.stars), 7) + self.assertEqual(len(result.stars), 6) # Did the psf flags get propagated from the psf_stars catalog? self.assertEqual(result.stars["calib_psf_used"].sum(), 3) @@ -319,7 +319,7 @@ def test_find_stars(self): # Only 5 psf-like sources with S/N>10 should be in the output catalog, # plus two sky sources. - self.assertEqual(len(stars), 7) + self.assertEqual(len(stars), 6) self.assertTrue(stars.isContiguous()) # Sort in order of brightness, to easily compare with expected positions. stars.sort(stars.getPsfFluxSlot().getMeasKey()) @@ -420,8 +420,8 @@ def test_match_psf_stars(self): # sort() above leaves the catalog non-contiguous. stars = stars.copy(deep=True) np.testing.assert_array_equal(stars["calib_psf_candidate"], - [False, False, False, False, True, True, True]) - np.testing.assert_array_equal(stars["calib_psf_used"], [False, False, False, False, True, True, True]) + [False, False, False, True, True, True]) + np.testing.assert_array_equal(stars["calib_psf_used"], [False, False, False, True, True, True]) # Too few sources to reserve any in these tests. self.assertEqual(stars["calib_psf_reserved"].sum(), 0) diff --git a/tests/test_photoCal.py b/tests/test_photoCal.py index c3d694836..08965f746 100755 --- a/tests/test_photoCal.py +++ b/tests/test_photoCal.py @@ -100,6 +100,8 @@ def setUp(self): # The test and associated data have been prepared on the basis that we # use the PsfFlux to perform photometry. self.config.fluxField = "base_PsfFlux_instFlux" + self.config.match.sourceSelection.signalToNoise.fluxField = "base_PsfFlux_instFlux" + self.config.match.sourceSelection.signalToNoise.errField = "base_PsfFlux_instFluxErr" def tearDown(self): del self.srcCat