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, the output table contains only the source
idand thex_0andy_0positions. Additional parameters can be specified as keyword arguments with their lower and upper bounds as 2-tuples. They are added as columns in the order given. The parameter values will be uniformly sampled from the half-open interval[lower, upper).- Parameters:
- shape2-tuple of int or int
The (ny, nx) shape of the image in which the sources will be placed. If a single integer is provided, it is used for both dimensions.
- n_sourcesint
The number of sources to generate. If
min_separationis too large, the requested number of sources may not fit within the givenshape. In that case, fewer thann_sourcessources are generated and anAstropyUserWarningis issued.- 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 in pixels between the centers of two sources. If the minimum separation is too large, fewer than
n_sourcessources are generated and a warning is issued.- 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. The x positions are uniformly sampled from the half-open interval
[nx_border, shape[1] - nx_border)and the y positions from[ny_border, shape[0] - ny_border).- seedint, optional
A seed to initialize the
numpy.random.BitGenerator. IfNone, 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 bounds must be numbers without units. The parameter values will be uniformly sampled from the half-open interval
[lower, upper). The namesid,x_name, andy_namecannot be used because they are the names of the ID and position columns.
- Returns:
- table
QTable A table containing the model parameters of the generated sources. The table will also contain an
'id'column with unique source IDs.
- table
- Raises:
- ValueError
If
n_sourcesis negative, ifborder_sizeleaves no room for sources within the givenshape, if a keyword argument value is not a 2-tuple, or if a keyword argument is namedidor has the same name asx_nameory_name.
- Warns:
AstropyUserWarningIf fewer than
n_sourcessources could be generated with the givenshapeandmin_separation.
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