Skip to content

Commit

Permalink
Make meta data flexible for photutils changes (#8066)
Browse files Browse the repository at this point in the history
  • Loading branch information
larrybradley authored Nov 16, 2023
1 parent d600185 commit 5b63bda
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ resample
- Improved compatibility with upcoming ``numpy 2.0`` that was affecting
decoding of context images and creation of masks. [#8059]

source_catalog
--------------

- Made meta data flexible for photutils changes. [#8066]

tweakreg
--------

Expand Down
17 changes: 14 additions & 3 deletions jwst/source_catalog/source_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,6 @@ def set_segment_properties(self):
self._ypeak = segm_cat.maxval_yindex

self.meta.update(segm_cat.meta)
for key in ('sklearn', 'matplotlib'):
self.meta['version'].pop(key)

# rename some columns in the output catalog
prop_names = {}
Expand Down Expand Up @@ -966,7 +964,20 @@ def catalog(self):
catalog = self.format_columns(catalog)

# update metadata
self.meta['version']['jwst'] = jwst_version
# photutils 1.11.0 will change the meta dict key name from
# version to versions; can remove this check when we require
# photutils >= 1.11.0
verkeys = ('versions', 'version')
verkey = set(self.meta.keys()).intersection(verkeys).pop()
verdict = self.meta.get(verkey, None)

if verdict is not None:
verdict['jwst'] = jwst_version
packages = ['Python', 'numpy', 'scipy', 'astropy', 'photutils',
'gwcs', 'jwst']
verdict = {key: verdict[key] for key in packages if key in verdict}
self.meta[verkey] = verdict

self.meta['aperture_params'] = self.aperture_params
self.meta['abvega_offset'] = self.abvega_offset
catalog.meta.update(self.meta)
Expand Down

0 comments on commit 5b63bda

Please sign in to comment.