Wednesday, June 19, 2013

Use 'fake' function to generate image with Poisson noise


I often get a question whether it is possible to generate simulated image data in Sherpa. It is really easy to do it using fake() function. This function will use the specified model expression and add a Poisson noise to that model and generate an image.

Here are the simple steps in Sherpa interactive session:

dataspace2d( [256, 256 ])                   # set the size of the image data
set_model( beta2d.bb +const2d.cc )    # define model expression 
                                                         # in Sherpa - beta2d and constant 
set_par(bb.xpos, 128.)                        # x coordinate for  the beta2d model
set_par(bb.ypos, 128.)                        # y coordinates for the beta2d model
set_par(bb.ampl, 10.)                          # amplitude of the beta2d model
fake()                                                # generate the counts data from the model
                                                        #  with Poisson noise
image_fit()                                         # display simulated data, model and 
                                                        # residual images


ds9 image below shows the simulated data
on the left and model image on the right
the residual image on the bottom.