diff --git a/python/lsst/pipe/tasks/calibrateImage.py b/python/lsst/pipe/tasks/calibrateImage.py index 98ff57621..3cf8dd3de 100644 --- a/python/lsst/pipe/tasks/calibrateImage.py +++ b/python/lsst/pipe/tasks/calibrateImage.py @@ -19,6 +19,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +import numpy as np + import lsst.afw.table as afwTable import lsst.afw.image as afwImage import lsst.meas.algorithms @@ -463,10 +465,23 @@ def _compute_psf(self, exposure, guess_psf=True): cell_set : `lsst.afw.math.SpatialCellSet` PSF candidates returned by the psf determiner. """ - self.log.info("First pass detection with Guassian PSF FWHM=%s", self.config.install_simple_psf.fwhm) + def log_psf(msg): + """Log the parameters of the psf and background, with a prepended + message. + """ + position = exposure.psf.getAveragePosition() + sigma = exposure.psf.computeShape(position).getDeterminantRadius() + dimensions = exposure.psf.computeImage(position).getDimensions() + median_background = np.median(background.getImage().array) + self.log.info("%s sigma=%0.4f, dimensions=%s; median background=%0.2f", + msg, sigma, dimensions, median_background) + + self.log.info("First pass detection with Guassian PSF FWHM=%s pixels", + self.config.install_simple_psf.fwhm) self.install_simple_psf.run(exposure=exposure) background = self.psf_subtract_background.run(exposure=exposure).background + log_psf("Initial PSF:") self.psf_repair.run(exposure=exposure, keepCRs=True) table = afwTable.SourceTable.make(self.psf_schema) @@ -479,7 +494,7 @@ def _compute_psf(self, exposure, guess_psf=True): # repair/detect/measure/measure_psf step: this can help it converge. self.install_simple_psf.run(exposure=exposure) - self.log.info("Re-running repair, detection, and PSF measurement using new simple PSF.") + log_psf("Rerunning with simple PSF:") # TODO investigation: Should we only re-run repair here, to use the # new PSF? Maybe we *do* need to re-run measurement with PsfFlux, to # use the fitted PSF? @@ -494,6 +509,8 @@ def _compute_psf(self, exposure, guess_psf=True): self.psf_source_measurement.run(detections.sources, exposure) psf_result = self.psf_measure_psf.run(exposure=exposure, sources=detections.sources) + log_psf("Final PSF:") + # Final repair with final PSF, removing cosmic rays this time. self.psf_repair.run(exposure=exposure) # Final measurement with the CRs removed.