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.
widthwidth % 2 == 0:
52 raise RuntimeError(
"width=%s must be odd" % (self.
widthwidth,))
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 model.
61 ConfigClass = InstallGaussianPsfConfig
62 _DefaultName = "installSimplePsfModel"
64 def run(self, exposure):
65 """Set exposure's PSF to a simple PSF model
67 The sigma and width of the new simple PSF model matches the sigma
and width of the current model,
68 if any,
else the config parameters are used.
73 Exposure
in which to replace
or add the PSF model.
76 psfModel = exposure.getPsf()
77 psfSigma = psfModel.computeShape().getDeterminantRadius()
78 width, height = psfModel.computeImage().getDimensions()
80 psfSigma = self.config.fwhm / FwhmPerSigma
81 width = height = self.config.width
84 raise RuntimeError(
"psfSigma = %s <= 0" % (psfSigma,))
86 self.log.debug(
"installing a simple Gaussian PSF model with width=%s, height=%s, FWHM=%0.3f",
87 width, height, psfSigma*FwhmPerSigma)
89 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.