photutils.datasets.make_model_sources_image(shape, model, source_table, oversample=1)[source]

Make an image containing sources generated from a user-specified model.

shape2-tuple of int

The shape of the output 2D image.

model2D astropy.modeling.models object

The model to be used for rendering the sources.


Table of parameters for the sources. Each row of the table corresponds to a source whose model parameters are defined by the column names, which must match the model parameter names. Column names that do not match model parameters will be ignored. Model parameters not defined in the table will be set to the model default value.

oversamplefloat, optional

The sampling factor used to discretize the models on a pixel grid. If the value is 1.0 (the default), then the models will be discretized by taking the value at the center of the pixel bin. Note that this method will not preserve the total flux of very small sources. Otherwise, the models will be discretized by taking the average over an oversampled grid. The pixels will be oversampled by the oversample factor.

image2D ndarray

Image containing model sources.


import matplotlib.pyplot as plt
from astropy.modeling.models import Moffat2D
from photutils.datasets import (make_model_sources_image,

model = Moffat2D()
n_sources = 10
shape = (100, 100)
param_ranges = {'amplitude': [100, 200],
                'x_0': [0, shape[1]],
                'y_0': [0, shape[0]],
                'gamma': [5, 10],
                'alpha': [1, 2]}
sources = make_random_models_table(n_sources, param_ranges,

data = make_model_sources_image(shape, model, sources)

(Source code, png, hires.png, pdf, svg)