IterativelySubtractedPSFPhotometry¶
- class photutils.psf.IterativelySubtractedPSFPhotometry(group_maker, bkg_estimator, psf_model, fitshape, finder, *, fitter=<astropy.modeling.fitting.LevMarLSQFitter object>, niters=3, aperture_radius=None, extra_output_cols=None, subshape=None)[source]¶
Bases:
BasicPSFPhotometry
Deprecated since version 1.9.0: The IterativelySubtractedPSFPhotometry class is deprecated and may be removed in a future version. Use
photutils.psf.IterativePSFPhotometry
instead.This class implements an iterative algorithm to perform point spread function photometry in crowded fields. This consists of applying a loop of find sources, make groups, fit groups, subtract groups, and then repeat until no more stars are detected or a given number of iterations is reached.
- Parameters:
- group_makercallable or
GroupStarsBase
group_maker
should be able to decide whether a given star overlaps with any other and label them as belonging to the same group.group_maker
receives as input anTable
object with columns named asid
,x_0
,y_0
, in whichx_0
andy_0
have the same meaning ofxcentroid
andycentroid
. This callable must return anTable
with columnsid
,x_0
,y_0
, andgroup_id
. The columngroup_id
should contain integers starting from1
that indicate which group a given source belongs to. See, e.g.,DAOGroup
.- bkg_estimatorcallable, instance of any
BackgroundBase
subclass, or None bkg_estimator
should be able to compute either a scalar background or a 2D background of a given 2D image. See, e.g.,MedianBackground
. If None, no background subtraction is performed.- psf_model
astropy.modeling.Fittable2DModel
instance PSF or PRF model to fit the data. Could be one of the models in this package like
IntegratedGaussianPRF
or any other suitable 2D model. This object needs to identify three parameters (position of center in x and y coordinates and the flux) in order to set them to suitable starting values for each fit. The names of these parameters should be given asx_0
,y_0
andflux
.prepare_psf_model
can be used to prepare any 2D model to match this assumption.- fitshapeint or length-2 array_like
Rectangular shape around the center of a star that will be used to define the PSF-fitting region. If
fitshape
is a scalar then a square shape of sizefitshape
will be used. Iffitshape
has two elements, they must be in(ny, nx)
order. Each element offitshape
must be an odd number.- findercallable or instance of any
StarFinderBase
subclasses finder
should be able to identify stars, i.e., compute a rough estimate of the centroids, in a given 2D image.finder
receives as input a 2D image and returns anTable
object which contains columns with names:id
,xcentroid
,ycentroid
, andflux
. In whichid
is an integer-valued column starting from1
,xcentroid
andycentroid
are center position estimates of the sources andflux
contains flux estimates of the sources. See, e.g.,DAOStarFinder
orIRAFStarFinder
.- fitter
Fitter
instance Fitter object used to compute the optimized centroid positions and/or flux of the identified sources. See
fitting
for more details on fitters.- aperture_radiusfloat
The radius (in units of pixels) used to compute initial estimates for the fluxes of sources. If
None
, one FWHM will be used if it can be determined from the`psf_model
.- nitersint or None
Number of iterations to perform of the loop FIND, GROUP, SUBTRACT, NSTAR. If None, iterations will proceed until no more stars remain. Note that in this case it is possible that the loop will never end if the PSF has structure that causes subtraction to create new sources infinitely.
- extra_output_colslist of str, optional
List of additional columns for parameters derived by any of the intermediate fitting steps (e.g.,
finder
), such as roundness or sharpness.- subshape
None
, int, or length-2 array_like Rectangular shape around the center of a star that will be used to define the PSF-subtraction region. If
None
, thenfitshape
will be used. Ifsubshape
is a scalar then a square shape of sizesubshape
will be used. Ifsubshape
has two elements, they must be in(ny, nx)
order. Each element ofsubshape
must be an odd number.
- group_makercallable or
Notes
If there are problems with fitting large groups, change the parameters of the grouping algorithm to reduce the number of sources in each group or input a
star_groups
table that only includes the groups that are relevant (e.g., manually remove all entries that coincide with artifacts).References
- [1] Stetson, Astronomical Society of the Pacific, Publications,
(ISSN 0004-6280), vol. 99, March 1987, p. 191-222. Available at: https://ui.adsabs.harvard.edu/abs/1987PASP…99..191S/abstract
Deprecated since version 1.9.0: The IterativelySubtractedPSFPhotometry class is deprecated and may be removed in a future version. Use
photutils.psf.IterativePSFPhotometry
instead.Attributes Summary
Methods Summary
do_photometry
(image, *[, mask, ...])Perform PSF photometry in
image
.Attributes Documentation
- finder¶
- niters¶
Methods Documentation
- do_photometry(image, *, mask=None, init_guesses=None, progress_bar=False, uncertainty=None)[source]¶
Perform PSF photometry in
image
.This method assumes that
psf_model
has centroids and flux parameters which will be fitted to the data provided inimage
. A compound model, in fact a sum ofpsf_model
, will be fitted to groups of stars automatically identified bygroup_maker
. Also,image
is not assumed to be background subtracted. Ifinit_guesses
are notNone
then this method usesinit_guesses
as initial guesses for the centroids. If the centroid positions are set asfixed
in the PSF modelpsf_model
, then the optimizer will only consider the flux as a variable.- Parameters:
- image2D
ndarray
Image to perform photometry. Invalid data values (i.e., NaN or inf) are automatically ignored.
- init_guesses
Table
Table which contains the initial guesses (estimates) for the set of parameters. Columns ‘x_0’ and ‘y_0’ which represent the positions (in pixel coordinates) for each object must be present. ‘flux_0’ can also be provided to set initial fluxes. If ‘flux_0’ is not provided, aperture photometry is used to estimate initial values for the fluxes. Additional columns of the form ‘<parametername>_0’ will be used to set the initial guess for any parameters of the
psf_model
model that are not fixed. Ifinit_guesses
supplied withextra_output_cols
the initial values are used; if the columns specified inextra_output_cols
are not given ininit_guesses
then NaNs will be returned.- mask2D bool
ndarray
, optional A boolean mask with the same shape as
image
, where aTrue
value indicates the corresponding element ofimage
is masked.- uncertainty2D
ndarray
, optional Stddev uncertainty for each element in
image
.
- image2D
- Returns:
- output_table
Table
or None A table with the photometry results, i.e., centroids and fluxes estimations and the initial estimates used to start the fitting process. Uncertainties on the fitted parameters are reported as columns called
<paramname>_unc
provided that the fitter object contains a dictionary calledfit_info
with the keyparam_cov
, which contains the covariance matrix.
- output_table