Repository: astropy/photutils

Issue:
Add wcs parameter to photutils.morphology.data_properties()
Hi, a small suggestion to the morphology functionality.

It would be great to allow `data_properties` to take a WCS convention/header, since `data_properties()` returns a `source_catalogue()` with SkyCoordinate attributes. This would allow the user to apply `data_properties` across a known list of objects in a crowded field, and quickly return the morphology of objects, but with the sky coordinates of the centroids returned for tracebacks.

Discussion:

Patch:
diff --git a/CHANGES.rst b/CHANGES.rst
index 1666af8e..90954215 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -9,6 +9,10 @@ General
 New Features
 ^^^^^^^^^^^^
 
+- ``photutils.morphology``
+
+  - Added a ``wcs`` keyword to ``data_properties``. [#1648]
+
 - ``photutils.segmentation``
 
   - The ``SegmentationImage`` ``make_source_mask`` method now uses a
diff --git a/photutils/morphology/core.py b/photutils/morphology/core.py
index 976b98a7..fdc5788b 100644
--- a/photutils/morphology/core.py
+++ b/photutils/morphology/core.py
@@ -9,7 +9,7 @@ import numpy as np
 __all__ = ['data_properties']
 
 
-def data_properties(data, mask=None, background=None):
+def data_properties(data, mask=None, background=None, wcs=None):
     """
     Calculate the morphological properties (and centroid) of a 2D array
     (e.g., an image cutout of an object) using image moments.
@@ -33,6 +33,13 @@ def data_properties(data, mask=None, background=None):
         get subtracted from the input ``data``, which should already be
         background-subtracted.
 
+    wcs : WCS object or `None`, optional
+        A world coordinate system (WCS) transformation that
+        supports the `astropy shared interface for WCS
+        <https://docs.astropy.org/en/stable/wcs/wcsapi.html>`_ (e.g.,
+        `astropy.wcs.WCS`, `gwcs.wcs.WCS`). If `None`, then all
+        sky-based properties will be set to `None`.
+
     Returns
     -------
     result : `~photutils.segmentation.SourceCatalog` instance
@@ -49,4 +56,4 @@ def data_properties(data, mask=None, background=None):
             background = np.zeros(data.shape) + background
 
     return SourceCatalog(data, segment_image, mask=mask,
-                         background=background)[0]
+                         background=background, wcs=wcs)[0]


Test patch:
diff --git a/photutils/morphology/tests/test_core.py b/photutils/morphology/tests/test_core.py
index 26d2b0e9..1a6c5372 100644
--- a/photutils/morphology/tests/test_core.py
+++ b/photutils/morphology/tests/test_core.py
@@ -7,7 +7,8 @@ import numpy as np
 import pytest
 from numpy.testing import assert_allclose
 
-from photutils.morphology.core import data_properties
+from photutils.datasets import make_wcs
+from photutils.morphology import data_properties
 from photutils.utils._optional_deps import HAS_SKIMAGE
 
 XCS = [25.7]
@@ -35,6 +36,10 @@ def test_data_properties():
     assert props.area.value == 4.0
     assert props2.area.value == 2.0
 
+    wcs = make_wcs(data.shape)
+    props = data_properties(data, mask=None, wcs=wcs)
+    assert props.sky_centroid is not None
+
 
 @pytest.mark.skipif(not HAS_SKIMAGE, reason='skimage is required')
 def test_data_properties_bkg():