phot.center.find_centroid

phot.center.find_centroid(
    ccd,
    position_xy,
    centroider=centroid_com,
    maxiters=5,
    cbox_size=5.0,
    csigma=0,
    msky=None,
    error=0,
    tol_shift=0.0001,
    max_shift=1,
    max_shift_step=None,
    full=False,
)

Find the intensity-weighted centroid iteratively.

Notes

Cut out small box region (cbox_size) around the initial position, use pixels above certain threshold, and find the intensity-weighted centroid of the box after subtracting “background”:

  • csigma=0 (or < 1.e-6): Use pixels only above the mean of the box. Ignore msky and error. (IRAF default?)
  • csigma=None: Use pixels only above the minimum of the box. Ignore msky and error.
  • csigma is a positive number: Use pixels above msky + csigma*error.
  • If msky is not given, use the minimum pixel value within the box.

Simply run _centroiding_iteration function iteratively for maxiters times. Given the initial guess of centroid position in image xy coordinate, it finds the intensity-weighted centroid (center of mass) after rejecting pixels by sigma-clipping.

https://iraf.readthedocs.io/en/latest/tasks/noao/digiphot/daophot/centerpars.html

Parameters

ccd : CCDData or ndarray

The whole image which the position_xy is calculated.

position_xy : array - like

The position of the initial guess in image XY coordinate. It is assumed that the position_xy is already quite close to the centroid, so both msky and ssky are not needed to be updated at every iteration.

centroider : callable = centroid_com

The centroider function (default uses photutils.centroid_com).

cbox_size : float or int = 5.0

The size of the box to find the centroid. Recommended to use 2.5 to 4.0 times the seeing FWHM. Minimally about 5 pixel is recommended. If extended source (e.g., comet), recommend larger cbox. See: https://iraf.readthedocs.io/en/latest/tasks/noao/digiphot/apphot/centerpars.html

csigma : float or int = 0

The parameter to use in sigma-clipping. If None, pixels ABOVE (not equal to) the minimum pixel value within the cbox_size will be used. If 0 (actually if < 1.e-6), pixels ABOVE the “mean pixel value within the cbox_size” will be used (IRAF default?). Otherwise, pixels above msky + csigma*error will be used. Default is 0

msky : float = None

The approximate value of the sky or background. If None (default), it is the minimum pixel value within the cbox_size.

error : (float, ndarray) = 0

The 1-sigma error-bar for each pixel. If float, a constant error-bar (e.g., sample standard deviation of sky) is assumed. If array-like, it should be in the shape of ccd. Ignored if csigma is None or 0. Default is 0.

tol_shift : float = 0.0001

The absolute tolerance for the shift. If the shift in centroid after iteration is smaller than this, iteration stops. Default is 1.0e-4.

max_shift : = 1

The maximum acceptable shift. If shift is larger than this, raises warning. Default is 1.

max_shift_step : (float, None) = None

The maximum acceptable shift for each iteration. If the shift (call it shift_raw) is larger than this, the actual shift will be max_shift_step towards the direction identical to shift_raw. If None (default), no such truncation is done.

full : bool = False

Whether to return the original and final cutout images.

Returns

com_xy : list

The iteratively found centroid position.