23 from __future__
import absolute_import, division
25 __all__ = [
"GaussianPsfFactory",
"SigmaPerFwhm"]
29 from lsst.pex.config
import Config, Field, ConfigurableField
30 from .singleGaussianPsf
import SingleGaussianPsf
31 from .doubleGaussianPsf
import DoubleGaussianPsf
33 SigmaPerFwhm = 1.0 / (2.0 * math.sqrt(2.0 * math.log(2.0)))
41 """Factory for simple Gaussian PSF models 43 Provides a high-level interface to DoubleGaussianPsf and SingleGaussianPsf 44 by specifying Gaussian PSF model width in FWHM instead of sigma, 45 and supporting computing kernel size as a multiple of PSF width. 46 This makes it suitable for tasks where PSF width is not known in advance. 49 doc=
"Kernel size (width and height) (pixels); if None then sizeFactor is used",
56 doc=
"Kernel size as a factor of fwhm (dimensionless); " 57 +
"size = sizeFactor * fwhm; ignored if size is not None",
64 doc=
"Minimum kernel size if using sizeFactor (pixels); ignored if size is not None",
71 doc=
"Maximum kernel size if using sizeFactor (pixels); ignored if size is not None",
78 doc=
"Default FWHM of Gaussian model of core of star (pixels)",
84 doc=
"Add a Gaussian to represent wings?",
89 wingFwhmFactor = Field(
90 doc=
"wing width, as a multiple of core width (dimensionless); ignored if addWing false",
96 wingAmplitude = Field(
97 doc=
"wing amplitude, as a multiple of core amplitude (dimensionless); ignored if addWing false",
105 """Compute kernel size and star width as sigma 107 kernel size will be odd unless minSize or maxSize is used and that value is even. 109 @param[in] fwhm: FWHM of core star (pixels); if None then defaultFwhm is used 111 - kernel size (width == height) in pixels 112 - sigma equivalent to supplied fwhm, assuming a Gaussian (pixels) 114 @warning assumes a valid config 119 if self.
size is not None:
122 desSize = (int(self.
sizeFactor * fwhm) // 2) * 2 + 1
130 return size, fwhm * SigmaPerFwhm
133 Config.validate(self)
135 raise RuntimeError(
"minSize=%s > maxSize=%s" % (self.
minSize, self.
maxSize))
138 """Construct a GaussianPsf 140 @param[in] self: an instance of ConfigClass 141 @param[in] fwhm: FWHM of core of star (pixels); if None then self.defaultFwhm is used 142 @return a DoubleGaussianPsf if self.addWing is True, else a SingleGaussianPsf 147 return DoubleGaussianPsf(kernelSize, kernelSize, sigma, wingsSigma, self.
wingAmplitude)
149 return SingleGaussianPsf(kernelSize, kernelSize, sigma)
153 """Make an lsst.pex.config.ConfigurableField 155 def applyWrapper(config, **kwargs):
156 """Construct a Gaussian PSF 158 @param[in] config: an instance of GaussianPsfFactory 160 return config.apply(**kwargs)
161 return ConfigurableField(
def apply(self, fwhm=None)
def computeSizeAndSigma(self, fwhm=None)