data_properties#

photutils.morphology.data_properties(data, mask=None, background=None, wcs=None)[source]#

Calculate the morphological properties (and centroid) of a 2D array (e.g., an image cutout of an object) using image moments.

Parameters:
dataarray_like or Quantity

The 2D array of the image. Nonfinite values (NaN and inf) are automatically masked. If data is a MaskedArray, its mask is combined with the input mask.

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. Masked data are excluded from all calculations.

backgroundfloat, array_like, or Quantity, optional

The background level previously present in the input data. background may be a scalar value or a 2D array with the same shape as data. If data is a Quantity, then background must have the same units. The input background is not subtracted from data, which should already be background-subtracted. Providing it only enables background-related properties to be measured. If None, then all background properties will be NaN.

wcsWCS object or None, optional

A world coordinate system (WCS) transformation that supports the astropy shared interface for WCS (e.g., astropy.wcs.WCS, gwcs.wcs.WCS). If None, then all sky-based properties will be set to None.

Returns:
resultSourceCatalog instance

A scalar SourceCatalog object (single source) containing the morphological properties.

Raises:
ValueError

If data is not a 2D array.

ValueError

If data is empty.

ValueError

If mask is provided and does not have the same shape as data.

ValueError

If mask is provided and all pixels are masked.

ValueError

If background is provided and is not a scalar or a 2D array with the same shape as data.