photutils icon indicating copy to clipboard operation
photutils copied to clipboard

make_gaussian_source_image example docs doesn't add source noise

Open hcferguson opened this issue 6 years ago • 2 comments

The example in the docs on make_gaussian_sources_image is adding Poisson (or Gaussian) noise only to the background. It's not including the Poisson noise of the sources themselves.

https://photutils.readthedocs.io/en/stable/api/photutils.datasets.make_gaussian_sources_image.html

image3 = image1 + make_noise_image(shape, distribution='poisson',
                                   mean=5.)

One way to add the Poisson noise for the sources would be to use the scipy.stats.poisson function (but of course this doesn't use photutils make_noise_image):

# Add a background of 5 counts and draw from a Poisson distribution 
image3 = stats.poisson(image1 + 5.).rvs() 

hcferguson avatar Oct 18 '19 17:10 hcferguson

This is also odd considering the photutils function apply_poisson_noise function which calls something very similar; could the example use apply_poisson_noise(image + 5), keeping the example "in house"?

Onoddil avatar Oct 21 '19 01:10 Onoddil

@hcferguson The apply_poisson_noise function does what you want. The make_noise_image is intended to create only background noise images. Its only required input is the output array shape -- it doesn't know anything about your data/sources. This should be made clearer in the documentation with a link to apply_poisson_noise.

larrybradley avatar Oct 21 '19 18:10 larrybradley