23 __all__ = [
"InstallGaussianPsfConfig",
"InstallGaussianPsfTask"]
31 FwhmPerSigma = 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 r"""Install a Gaussian PSF model in an exposure.
57 If the exposure already has a PSF model then the new model
58 has the same sigma and size (width and height in pixels) of the existing model.
60 ConfigClass = InstallGaussianPsfConfig
61 _DefaultName =
"installSimplePsfModel"
63 def run(self, exposure):
64 """Set exposure's PSF to a simple PSF model
66 The sigma and width of the new simple PSF model matches the sigma and width of the current model,
67 if any, else the config parameters are used.
71 exposure : `lsst.afw.image.Exposure`
72 Exposure in which to replace or add the PSF model.
75 psfModel = exposure.getPsf()
76 psfSigma = psfModel.computeShape().getDeterminantRadius()
77 width, height = psfModel.computeImage().getDimensions()
79 psfSigma = self.config.fwhm / FwhmPerSigma
80 width = height = self.config.width
83 raise RuntimeError(
"psfSigma = %s <= 0" % (psfSigma,))
85 self.log.debug(
"installing a simple Gaussian PSF model with width=%s, height=%s, FWHM=%0.3f",
86 width, height, psfSigma*FwhmPerSigma)
88 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.