make_random_gaussians_table

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

Make a QTable containing randomly generated parameters for 2D Gaussian sources.

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

The output table can be input into make_gaussian_sources_image() to create an image containing the 2D Gaussian sources.

Parameters
n_sourcesfloat

The number of random Gaussian sources to generate.

param_rangesdict

The lower and upper boundaries for each of the Gaussian2D parameters as a dictionary mapping the parameter name to its (lower, upper) bounds. The dictionary keys must be valid Gaussian2D parameter names or 'flux'. If 'flux' is specified, but not 'amplitude' then the 2D Gaussian amplitudes will be calculated and placed in the output table. If both 'flux' and 'amplitude' are specified, then 'flux' will be ignored. Model parameters not defined in param_ranges will be set to the default value.

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 Gaussian sources. Each row of the table corresponds to a Gaussian source whose parameters are defined by the column names.

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_gaussians_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]}
>>> sources = make_random_gaussians_table(n_sources, param_ranges,
...                                       seed=0)
>>> for col in sources.colnames:
...     sources[col].info.format = '%.8g'  # for consistent table output
>>> print(sources)
amplitude   x_mean    y_mean    x_stddev  y_stddev   theta
--------- --------- ---------- --------- --------- ---------
818.48084 456.37779  244.75607 1.7026225 1.1132787 1.2053586
634.89336 303.31789 0.82155005 4.4527157 1.4971331 3.1328274
520.48676 364.74828  257.22128 3.1658449 3.6824977 3.0813851
508.26382  271.8125  10.075673 2.1988476  3.588758 2.1536937
906.63512 467.53621  218.89663 2.6907489 3.4615404 2.0434781

To specifying the flux range instead of the amplitude range:

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

Note that in this case the output table contains both a flux and amplitude column. The flux column will be ignored when generating an image of the models using make_gaussian_sources_image().