make_psf_model#
- photutils.psf.make_psf_model(model, *, x_name=None, y_name=None, flux_name=None, normalize=True, dx=50, dy=50, subsample=100, use_dblquad=False)[source]#
Make a PSF model that can be used with the PSF photometry classes (
PSFPhotometryorIterativePSFPhotometry) from an Astropy fittable 2D model.If the
x_name,y_name, orflux_namekeywords are input, this function will map thosemodelparameter names tox_0,y_0, orflux, respectively.If any of the
x_name,y_name, orflux_namekeywords areNone, then a new parameter will be added to the model corresponding to the missing parameter. Any new position parameters will be set to a default value of 0, and any new flux parameter will be set to a default value of 1.The output PSF model will have
x_name,y_name, andflux_nameattributes that contain the name of the corresponding model parameter.Note
This function is needed only in cases where the 2D PSF model does not have
x_0,y_0, andfluxparameters.It is not needed for any of the PSF models provided by Photutils.
- Parameters:
- model
Fittable2DModel An Astropy fittable 2D model to use as a PSF.
- x_name
strorNone, optional The name of the
modelparameter that corresponds to the x center of the PSF. IfNone, the model will be assumed to be centered at x=0, and a new model parameter calledxpos_0will be added for the x position.- y_name
strorNone, optional The name of the
modelparameter that corresponds to the y center of the PSF. IfNone, the model will be assumed to be centered at y=0, and a new parameter calledypos_1will be added for the y position.- flux_name
strorNone, optional The name of the
modelparameter that corresponds to the total flux of a source. IfNone, a new model parameter calledflux_3will be added for model flux.- normalizebool, optional
If
True, the inputmodelwill be integrated and rescaled so that its sum integrates to 1. This normalization occurs only once for the inputmodel. If the total flux ofmodelsomehow depends on (x, y) position, then one will need to correct the fitted model fluxes for this effect.- dx, dyodd int, optional
The size of the integration grid in x and y for normalization. Must be odd. These keywords are ignored if
normalizeisFalseoruse_dblquadisTrue.- subsampleint, optional
The subsampling factor for the integration grid along each axis for normalization. Each pixel will be sampled
subsamplexsubsampletimes. This keyword is ignored ifnormalizeisFalseoruse_dblquadisTrue.- use_dblquadbool, optional
If
True, then usescipy.integrate.dblquadto integrate the model for normalization. This is much slower than the default integration of the evaluated model, but it is more accurate. This keyword is ignored ifnormalizeisFalse.
- model
- Returns:
- result
CompoundModel A PSF model that can be used with the PSF photometry classes. The returned model will always be an Astropy compound model.
- result
Notes
To normalize the model, by default it is discretized on a grid of size
dxxdyfrom the model center with a subsampling factor ofsubsample. The model is then integrated over the grid using trapezoidal integration.If the
use_dblquadkeyword is set toTrue, then the model is integrated usingscipy.integrate.dblquad. This is much slower than the default integration of the evaluated model, but it is more accurate. Also, note that thedblquadintegration can sometimes fail, e.g., return zero for a non-zero model. This can happen when the model function is sharply localized relative to the size of the integration interval.Examples
>>> from astropy.modeling.models import Gaussian2D >>> from photutils.psf import make_psf_model >>> model = Gaussian2D(x_stddev=2, y_stddev=2) >>> psf_model = make_psf_model(model, x_name='x_mean', y_name='y_mean') >>> print(psf_model.param_names) ('amplitude_2', 'x_mean_2', 'y_mean_2', 'x_stddev_2', 'y_stddev_2', 'theta_2', 'amplitude_3', 'amplitude_4')