centroid_com

photutils.centroids.centroid_com(data, mask=None)[source]

Calculate the centroid of an n-dimensional array as its “center of mass” determined from moments.

Non-finite values (e.g., NaN or inf) in the data array are automatically masked.

Parameters:
datandarray

The input n-dimensional array. The image should be a background-subtracted cutout image containing a single source.

maskbool ndarray, optional

A boolean mask, with the same shape as data, where a True value indicates the corresponding element of data is masked.

Returns:
centroidndarray

The coordinates of the centroid in pixel order (e.g., (x, y) or (x, y, z)), not numpy axis order.