Skip to content

Commit

Permalink
Merge pull request #1705 from larrybradley/finder-tbl
Browse files Browse the repository at this point in the history
Return finder_results as a QTable
  • Loading branch information
larrybradley committed Feb 14, 2024
2 parents 3d0a4fe + 8c81dab commit 72be037
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ API Changes
backwards-incompatible change. If the previous behavior is desired,
set ``include_localbkg=True``. [#1703]

- The PSF photometry ``finder_results`` attribute is now returned as a
``QTable`` instead of a list of ``QTable``. [#1704]

- ``photutils.segmentation``

- The ``SourceCatalog`` ``get_label`` and ``get_labels`` methods now
Expand Down
14 changes: 7 additions & 7 deletions docs/psf.rst
Original file line number Diff line number Diff line change
Expand Up @@ -314,13 +314,13 @@ astropy table):

.. doctest-requires:: scipy

>>> psfphot.finder_results[0]['xcentroid'].info.format = '.4f' # optional format
>>> psfphot.finder_results[0]['ycentroid'].info.format = '.4f' # optional format
>>> psfphot.finder_results[0]['sharpness'].info.format = '.4f' # optional format
>>> psfphot.finder_results[0]['peak'].info.format = '.4f'
>>> psfphot.finder_results[0]['flux'].info.format = '.4f'
>>> psfphot.finder_results[0]['mag'].info.format = '.4f'
>>> print(psfphot.finder_results[0]) # doctest: +FLOAT_CMP
>>> psfphot.finder_results['xcentroid'].info.format = '.4f' # optional format
>>> psfphot.finder_results['ycentroid'].info.format = '.4f' # optional format
>>> psfphot.finder_results['sharpness'].info.format = '.4f' # optional format
>>> psfphot.finder_results['peak'].info.format = '.4f'
>>> psfphot.finder_results['flux'].info.format = '.4f'
>>> psfphot.finder_results['mag'].info.format = '.4f'
>>> print(psfphot.finder_results) # doctest: +FLOAT_CMP
id xcentroid ycentroid sharpness ... sky peak flux mag
--- --------- --------- --------- ... --- ------- ------- -------
1 54.5300 7.7508 0.5996 ... 0.0 67.0314 8.7012 -2.3490
Expand Down
6 changes: 3 additions & 3 deletions photutils/psf/photometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,13 @@ def __init__(self, psf_model, fit_shape, *, finder=None, grouper=None,
self.progress_bar = progress_bar

# reset these attributes for each __call__ (see _reset_results)
self.finder_results = []
self.finder_results = None
self.fit_results = defaultdict(list)
self._group_results = defaultdict(list)
self._fit_models = None

def _reset_results(self):
self.finder_results = []
self.finder_results = None
self.fit_results = defaultdict(list)
self._group_results = defaultdict(list)
self._fit_models = None
Expand Down Expand Up @@ -378,7 +378,7 @@ def _prepare_init_params(self, data, unit, mask, init_params):
'is not input')

sources = self.finder(data, mask=mask)
self.finder_results.append(sources)
self.finder_results = sources
if sources is None:
return None

Expand Down
1 change: 1 addition & 0 deletions photutils/psf/tests/test_photometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ def test_psf_photometry(test_data):
phot = psfphot(data, error=error)
resid_data = psfphot.make_residual_image(data, fit_shape)

assert isinstance(psfphot.finder_results, QTable)
assert isinstance(phot, QTable)
assert len(phot) == len(sources)
assert isinstance(resid_data, np.ndarray)
Expand Down

0 comments on commit 72be037

Please sign in to comment.