27 from .
import SingleGaussianPsf
30 def plantSources(bbox, kwid, sky, coordList, addPoissonNoise=True):
31 """Make an exposure with stars (modelled as Gaussians)
33 @param bbox: parent bbox of exposure
34 @param kwid: kernel width (and height; kernel is square)
35 @param sky: amount of sky background (counts)
36 @param coordList: a list of [x, y, counts, sigma], where:
37 * x,y are relative to exposure origin
38 * counts is the integrated counts for the star
39 * sigma is the Gaussian sigma in pixels
40 @param addPoissonNoise: add Poisson noise to the exposure?
43 img = afwImage.ImageD(bbox)
45 for coord
in coordList:
46 x, y, counts, sigma = coord
50 psf = SingleGaussianPsf(kwid, kwid, sigma)
53 thisPsfImg = psf.computeImage(afwGeom.PointD(int(x), int(y)))
57 imgSeg = img.Factory(img, thisPsfImg.getBBox())
59 meanSigma /= len(coordList)
65 numpy.random.seed(seed=1)
66 imgArr = img.getArray()
67 imgArr[:] = numpy.random.poisson(imgArr)
70 mask = afwImage.Mask(bbox)
71 var = img.convertFloat()
73 mimg = afwImage.MaskedImageF(img.convertFloat(), mask, var)
74 exposure = afwImage.makeExposure(mimg)
77 psf = SingleGaussianPsf(kwid, kwid, meanSigma)