63 def addNoise(galImage, detector, rand_gen=None):
65 adds noise to the the image and returns a variance plane
66 INPUT: image to add noise to
67 detector where the image will be located, this sets the gain
68 NOTE: this assumes float type images and will break if given doubles
69 RETURN: a MaskedImageF with the image with additional noise and the
71 giving the variance due to the object
74 varImage = galImage.Factory(galImage,
True)
77 scale = np.sqrt(np.abs(varImage.getArray())) + 1e-12
78 noiseArray = rand_gen.normal(loc=0.0,
80 size=(galImage.getHeight(),
82 noiseImage = lsst.afw.image.ImageF(noiseArray.astype(np.float32))
83 galImage += noiseImage
85 return lsst.afw.image.MaskedImageF(galImage,
None, varImage)