photutils.centroids.centroid_com(data, mask=None, oversampling=1)[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.


The input n-dimensional array.

maskarray_like (bool), optional

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

oversamplingint or tuple of two int, optional

Oversampling factors of pixel indices. If oversampling is a scalar this is treated as both x and y directions having the same oversampling factor; otherwise it is treated as (x_oversamp, y_oversamp).


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