make_model_params#

photutils.datasets.make_model_params(shape, n_sources, *, x_name='x_0', y_name='y_0', min_separation=1, border_size=(0, 0), seed=0, **kwargs)[source]#

Make a table of randomly generated model positions and additional parameters for simulated sources.

By default, this function computes only a table of x_0 and y_0 values. Additional parameters can be specified as keyword arguments with their lower and upper bounds as 2-tuples. The parameter values will be uniformly distributed between the lower and upper bounds, inclusively.

Parameters:
shape2-tuple of int

The shape of the output image.

n_sourcesint

The number of sources to generate. If min_separation is too large, the number of requested sources may not fit within the given shape and therefore the number of sources generated may be less than n_sources.

x_namestr, optional

The name of the model parameter that corresponds to the x position of the sources. This will be the column name in the output table.

y_namestr, optional

The name of the model parameter that corresponds to the y position of the sources. This will be the column name in the output table.

min_separationfloat, optional

The minimum separation between the centers of two sources. Note that if the minimum separation is too large, the number of sources generated may be less than n_sources.

border_sizetuple of 2 int or int, optional

The (ny, nx) size of the border around the image where no sources will be generated (i.e., the source center will not be located within the border). If a single integer is provided, it will be used for both dimensions.

seedint, optional

A seed to initialize the numpy.random.BitGenerator. If None, then fresh, unpredictable entropy will be pulled from the OS.

**kwargs

Keyword arguments are accepted for additional model parameters. The values should be 2-tuples of the lower and upper bounds for the parameter range. The parameter values will be uniformly distributed between the lower and upper bounds, inclusively.

Returns:
tableQTable

A table containing the model parameters of the generated sources. The table will also contain an 'id' column with unique source IDs.

Examples

>>> from photutils.datasets import make_model_params
>>> params = make_model_params((100, 100), 5, flux=(100, 500),
...                            min_separation=3, border_size=10, seed=0)
>>> for col in params.colnames:
...     params[col].info.format = '%.8g'  # for consistent table output
>>> print(params)
 id    x_0       y_0       flux
--- --------- --------- ---------
  1 60.956935 72.967865 291.99517
  2 31.582937 29.149555 192.94917
  3 13.277882 80.118738 420.75223
  4 11.322211 14.685443 469.41206
  5 75.061619 36.889365 206.45211
>>> params = make_model_params((100, 100), 5, flux=(100, 500),
...                            x_name='x_mean', y_name='y_mean',
...                            min_separation=3, border_size=10, seed=0)
>>> for col in params.colnames:
...     params[col].info.format = '%.8g'  # for consistent table output
>>> print(params)
 id   x_mean    y_mean     flux
--- --------- --------- ---------
  1 60.956935 72.967865 291.99517
  2 31.582937 29.149555 192.94917
  3 13.277882 80.118738 420.75223
  4 11.322211 14.685443 469.41206
  5 75.061619 36.889365 206.45211
>>> params = make_model_params((100, 100), 5, flux=(100, 500),
...                            sigma=(1, 2), alpha=(0, 1),
...                            min_separation=3, border_size=10, seed=0)
>>> for col in params.colnames:
...     params[col].info.format = '%.5g'  # for consistent table output
>>> print(params)
 id  x_0    y_0    flux  sigma   alpha
--- ------ ------ ------ ------ --------
  1 60.957 72.968    292 1.5389  0.61437
  2 31.583  29.15 192.95 1.4428 0.028365
  3 13.278 80.119 420.75  1.931  0.71922
  4 11.322 14.685 469.41 1.0405 0.015992
  5 75.062 36.889 206.45  1.732  0.75795