24 __all__ = [
"GaussianPsfFactory", 
"SigmaPerFwhm"]
 
   28 from lsst.pex.config 
import Config, Field, ConfigurableField
 
   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 
  106         kernel size will be odd unless minSize or maxSize is used and that value is even. 
  108         @param[in] fwhm: FWHM of core star (pixels); if None then defaultFwhm is used 
  110         - kernel size (width == height) in pixels 
  111         - sigma equivalent to supplied fwhm, assuming a Gaussian (pixels) 
  113         @warning assumes a valid config 
  118         if self.
size is not None:
 
  121             desSize = (int(self.
sizeFactor * fwhm) // 2) * 2 + 1  
 
  129         return size, fwhm * SigmaPerFwhm
 
  132         Config.validate(self)
 
  134             raise RuntimeError(
"minSize=%s > maxSize=%s" % (self.
minSize, self.
maxSize))
 
  137         """Construct a GaussianPsf 
  139         @param[in] self: an instance of ConfigClass 
  140         @param[in] fwhm: FWHM of core of star (pixels); if None then self.defaultFwhm is used 
  141         @return a DoubleGaussianPsf if self.addWing is True, else a SingleGaussianPsf 
  146             return DoubleGaussianPsf(kernelSize, kernelSize, sigma, wingsSigma, self.
wingAmplitude)
 
  148             return SingleGaussianPsf(kernelSize, kernelSize, sigma)
 
  152         """Make an lsst.pex.config.ConfigurableField 
  154         def applyWrapper(config, **kwargs):
 
  155             """Construct a Gaussian PSF 
  157             @param[in] config: an instance of GaussianPsfFactory 
  159             return config.apply(**kwargs)
 
  160         return ConfigurableField(