params_table_to_models#

photutils.datasets.params_table_to_models(params_table, model)[source]#

Create a list of models from a table of model parameters.

Parameters:
params_tableTable

A table containing the model parameters for each source. Each row of the table corresponds to a different model whose parameters are defined by the column names. Model parameters not defined in the table keep the values of the input model. Columns whose names do not match a model parameter name are ignored. At least one column name must match a parameter name of model. To attach units to model parameters, params_table must be input as a QTable. A column named 'name' can also be included in the table to assign a name to each model.

modelastropy.modeling.Model instance

The model to copy for each row of params_table. The parameters of each copy are set from the table. The input model is not modified.

Returns:
modelslist of astropy.modeling.Model

A list of models created from the input table of model parameters.

Raises:
TypeError

If model is not an astropy.modeling.Model instance.

ValueError

If no column name in params_table matches a parameter name of model.

Examples

>>> from astropy.table import QTable
>>> from photutils.datasets import params_table_to_models
>>> from photutils.psf import CircularGaussianPSF
>>> tbl = QTable()
>>> tbl['x_0'] = [1, 2, 3]
>>> tbl['y_0'] = [4, 5, 6]
>>> tbl['flux'] = [100, 200, 300]
>>> model = CircularGaussianPSF()
>>> models = params_table_to_models(tbl, model)
>>> models
[<CircularGaussianPSF(flux=100., x_0=1., y_0=4., fwhm=1.)>,
 <CircularGaussianPSF(flux=200., x_0=2., y_0=5., fwhm=1.)>,
 <CircularGaussianPSF(flux=300., x_0=3., y_0=6., fwhm=1.)>]