make_random_models_table#

photutils.datasets.make_random_models_table(n_sources, param_ranges, seed=None)[source]#

Make a QTable containing randomly generated parameters for an Astropy model to simulate a set of sources.

Each row of the table corresponds to a source whose parameters are defined by the column names. The parameters are drawn from a uniform distribution over the specified input ranges, inclusively.

The output table can be input into make_model_image() to create an image containing the model sources.

Parameters:
n_sourcesfloat

The number of random model sources to generate.

param_rangesdict

The lower and upper boundaries for each of the model parameters as a dictionary mapping the parameter name to its (lower, upper) bounds. The parameter values will be uniformly distributed between these bounds, inclusively.

seedint, optional

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

Returns:
tableQTable

A table of parameters for the randomly generated sources. Each row of the table corresponds to a source whose model parameters are defined by the column names. The column names will be the keys of the dictionary param_ranges. The table will also contain an 'id' column with unique source IDs.

Notes

To generate identical parameter values from separate function calls, param_ranges must have the same parameter ranges and the seed must be the same.

Examples

>>> from photutils.datasets import make_random_models_table
>>> n_sources = 5
>>> param_ranges = {'amplitude': [500, 1000],
...                 'x_mean': [0, 500],
...                 'y_mean': [0, 300],
...                 'x_stddev': [1, 5],
...                 'y_stddev': [1, 5],
...                 'theta': [0, np.pi]}
>>> params = make_random_models_table(n_sources, param_ranges, seed=0)
>>> for col in params.colnames:
...     params[col].info.format = '%.8g'  # for consistent table output
>>> print(params)
 id amplitude   x_mean    y_mean    x_stddev  y_stddev   theta
--- --------- --------- ---------- --------- --------- ---------
  1 818.48084 456.37779  244.75607 1.7026225 1.1132787 1.2053586
  2 634.89336 303.31789 0.82155005 4.4527157 1.4971331 3.1328274
  3 520.48676 364.74828  257.22128 3.1658449 3.6824977 3.0813851
  4 508.26382  271.8125  10.075673 2.1988476  3.588758 2.1536937
  5 906.63512 467.53621  218.89663 2.6907489 3.4615404 2.0434781