24 __all__ = [
"GaussianPsfFactory",
"SigmaPerFwhm"]
29 from .singleGaussianPsf
import SingleGaussianPsf
30 from .doubleGaussianPsf
import DoubleGaussianPsf
32 SigmaPerFwhm = 1.0 / (2.0 * math.sqrt(2.0 * math.log(2.0)))
40 """Factory for simple Gaussian PSF models
42 Provides a high-level interface to DoubleGaussianPsf and SingleGaussianPsf
43 by specifying Gaussian PSF model width in FWHM instead of sigma,
44 and supporting computing kernel size as a multiple of PSF width.
45 This makes it suitable for tasks where PSF width is not known in advance.
48 doc=
"Kernel size (width and height) (pixels); if None then sizeFactor is used",
55 doc=
"Kernel size as a factor of fwhm (dimensionless); "
56 "size = sizeFactor * fwhm; ignored if size is not None",
63 doc=
"Minimum kernel size if using sizeFactor (pixels); ignored if size is not None",
70 doc=
"Maximum kernel size if using sizeFactor (pixels); ignored if size is not None",
77 doc=
"Default FWHM of Gaussian model of core of star (pixels)",
83 doc=
"Add a Gaussian to represent wings?",
88 wingFwhmFactor = Field(
89 doc=
"wing width, as a multiple of core width (dimensionless); ignored if addWing false",
95 wingAmplitude = Field(
96 doc=
"wing amplitude, as a multiple of core amplitude (dimensionless); ignored if addWing false",
104 """Compute kernel size and star width as sigma. The kernel size will be
105 odd unless minSize or maxSize is used and that value is even. Assumes
111 FWHM of core star (pixels); if None then defaultFwhm is used
116 Kernel size (width == height) in pixels
118 Sigma equivalent to supplied FWHM, assuming a Gaussian (pixels)
123 if self.
sizesize
is not None:
126 desSize = (int(self.
sizeFactorsizeFactor * fwhm) // 2) * 2 + 1
134 return size, fwhm * SigmaPerFwhm
137 Config.validate(self)
139 raise RuntimeError(
"minSize=%s > maxSize=%s" % (self.
minSizeminSize, self.
maxSizemaxSize))
142 """Construct a GaussianPsf
147 FWHM of core of star (pixels); if None then self.defaultFwhm is used
151 DoubleGaussianPsf : ``lsst.meas.algorithms.DoubleGaussianPsf``
152 Returns if self.addWing is True
153 SingleGaussianPsf : ``lsst.meas.algorithms.SingleGaussianPsf``
154 Returns if self.addWing is False
159 return DoubleGaussianPsf(kernelSize, kernelSize, sigma, wingsSigma, self.
wingAmplitudewingAmplitude)
161 return SingleGaussianPsf(kernelSize, kernelSize, sigma)
165 """Make an lsst.pex.config.ConfigurableField
167 def applyWrapper(config, **kwargs):
168 """Construct a Gaussian PSF
172 config : instance of ``GaussianPsfFactory``
174 return config.apply(**kwargs)
175 return ConfigurableField(
def apply(self, fwhm=None)
def computeSizeAndSigma(self, fwhm=None)