23__all__ = [
"InstallGaussianPsfConfig",
"InstallGaussianPsfTask"]
28import lsst.pipe.base
as pipeBase
31FwhmPerSigma = 2.0*math.sqrt(2.0*math.log(2.0))
35 """Config for InstallGaussianPsfTask
37 fwhm = pexConfig.Field(
39 default=1.5 * FwhmPerSigma,
40 doc="Estimated FWHM of simple Gaussian PSF model, in pixels. "
41 "Ignored if input exposure has a PSF model."
43 width = pexConfig.RangeField(
45 doc=
"Width and height of PSF model, in pixels. Must be odd.",
51 if self.
width % 2 == 0:
52 raise RuntimeError(
"width=%s must be odd" % (self.
width,))
56 """Install a Gaussian PSF model in an exposure.
58 If the exposure already has a PSF model then the new model
59 has the same sigma and size (width
and height
in pixels) of the existing
62 ConfigClass = InstallGaussianPsfConfig
63 _DefaultName = "installSimplePsfModel"
65 def run(self, exposure):
66 """Set exposure's PSF to a simple PSF model
68 The sigma and width of the new simple PSF model matches the sigma
and
69 width of the current model,
if any,
else the config parameters are used.
74 Exposure
in which to replace
or add the PSF model.
77 psfModel = exposure.getPsf()
78 psfSigma = psfModel.computeShape(psfModel.getAveragePosition()).getDeterminantRadius()
79 width, height = psfModel.computeImage(psfModel.getAveragePosition()).getDimensions()
81 psfSigma = self.config.fwhm / FwhmPerSigma
82 width = height = self.config.width
85 raise RuntimeError(
"psfSigma = %s <= 0" % (psfSigma,))
87 self.log.debug(
"installing a simple Gaussian PSF model with width=%s, height=%s, FWHM=%0.3f",
88 width, height, psfSigma*FwhmPerSigma)
90 exposure.setPsf(psfModel)
Represent a PSF as a circularly symmetrical Gaussian.
Fit spatial kernel using approximate fluxes for candidates, and solving a linear system of equations.