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