find_center#
- stellarphot.photometry.profiles.find_center(image, center_guess, cutout_size=30, max_iters=10, match_limit=3)[source]#
Find the centroid of a star from an initial guess of its position. Originally written to find star from a mouse click.
- Parameters:
- image
astropy.nddata.CCDDataor numpy array Image containing the star.
- center_guessarray or tuple
The position, in pixels, of the initial guess for the position of the star. The coordinates should be horizontal first, then vertical, i.e. opposite the usual Python convention for a numpy array.
- cutout_sizeint, optional
The default width of the cutout to use for finding the star.
- max_itersint, optional
Maximum number of iterations to go through in finding the center.
- match_limitint, optional
Maximum number of pixels to allow the COM centroid and Gaussian center to differ.
- image
- Returns:
- cenarray
The position of the star, in pixels, as found by the centroiding algorithm.
- Raises:
- RuntimeError
If the centroiding algorithm fails to converge on a star eitehr because a cutout has only
NaNvalues or because the centroiding algorithm fails to converge or because the centroid determined bycentroid_comandcentroid_2dgdiffer by more thanmatch_limitpixels.
Notes
This function tries to identify the centroid of a star in a small region around an image position. The original mtivation was to find the star near a mouse click on an image. The approach is to generate a cutout around the initial guess position, then use the centroid_com function from photutils to find the centroid of the star. A new cutout is then generated around the new centroid position, and the process is repeated until the centroid converges.
Convergence is determined by three criteria:
The centroid of the cutout must be within 3 pixels of the center of the cutout.
The centroid of the cutout must be within 0.1 pixels of the previous centroid.
The first two criteria must be met within the maximum number of iterations.
If the first two criteria are satisfied then the centroid is found by fitting a Gaussian to the cutout. If the two centroids differ by more than match_limit pixels then an error is raised.