Skip to content

Commit 6d8b4de

Browse files
authored
Requre photutils 3+ (#10471)
1 parent d6ad0c4 commit 6d8b4de

11 files changed

Lines changed: 62 additions & 302 deletions

File tree

changes/10471.other.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Numpy >= 2.0, Astropy >= 6.1.4, and Photutils >= 3.0 are now required.

jwst/extract_1d/ifu.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22
import warnings
33

44
import numpy as np
5-
import photutils
65
from astropy import stats
76
from astropy.stats import sigma_clipped_stats as sigclip
8-
from astropy.utils import minversion
97
from photutils.aperture import (
108
CircularAnnulus,
119
CircularAperture,
@@ -662,10 +660,7 @@ def extract_ifu(input_model, source_type, extract_params):
662660
# Identify brightest source as the target
663661
indx = np.argmax(vals)
664662

665-
if minversion(photutils, "2.3.1.dev"):
666-
x_center, y_center = sources[indx]["x_centroid"], sources[indx]["y_centroid"]
667-
else:
668-
x_center, y_center = sources[indx]["xcentroid"], sources[indx]["ycentroid"]
663+
x_center, y_center = sources[indx]["x_centroid"], sources[indx]["y_centroid"]
669664
locn = None
670665
log.info("Auto source detection success.")
671666
log.info("Using x_center = %g, y_center = %g", x_center, y_center)

jwst/regtest/test_niriss_sourcefind.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ def test_tweakreg_catalog_starfinder_alternatives(rtdata, starfinder):
2727
bkg_boxsize=10.0,
2828
starfinder_name=starfinder,
2929
starfinder_kwargs={
30-
"brightest": None,
31-
"sharphi": 3.0,
32-
"minsep_fwhm": 2.5,
30+
"n_brightest": None,
31+
"sharpness_range": (0.5, 3.0),
32+
"min_separation": max(2, int(2.5 * 2.5 + 0.5)),
3333
"sigma_radius": 2.5,
3434
},
3535
)

jwst/source_catalog/source_catalog.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@
55

66
import astropy.units as u
77
import numpy as np
8-
import photutils
98
from astropy.convolution import Gaussian2DKernel
109
from astropy.nddata.utils import NoOverlapError, extract_array
1110
from astropy.stats import SigmaClip, gaussian_fwhm_to_sigma
1211
from astropy.table import QTable
13-
from astropy.utils import lazyproperty, minversion
12+
from astropy.utils import lazyproperty
1413
from astropy.utils.exceptions import AstropyUserWarning
1514
from photutils.aperture import CircularAnnulus, CircularAperture, aperture_photometry
1615
from scipy import ndimage
@@ -24,8 +23,6 @@
2423

2524
__all__ = ["JWSTSourceCatalog"]
2625

27-
PHOTUTILS_GE_3 = minversion(photutils, "2.3.1.dev")
28-
2926

3027
class JWSTSourceCatalog:
3128
"""
@@ -241,16 +238,11 @@ def set_segment_properties(self):
241238
rename_map = {
242239
"label": "id",
243240
"isophotal_flux": "flux",
244-
"isophotal_flux_err": "segment_fluxerr",
245241
"isophotal_area": "area",
242+
"semimajor_sigma": "semimajor_axis",
243+
"semiminor_sigma": "semiminor_axis",
244+
"isophotal_flux_err": "segment_flux_err",
246245
}
247-
if PHOTUTILS_GE_3:
248-
rename_new = {
249-
"semimajor_sigma": "semimajor_axis",
250-
"semiminor_sigma": "semiminor_axis",
251-
"isophotal_flux_err": "segment_flux_err",
252-
}
253-
rename_map.update(rename_new)
254246

255247
for column in self.segment_colnames:
256248
# define the property name

jwst/source_catalog/source_catalog_step.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -109,20 +109,18 @@ def process(self, input_data):
109109

110110
starfinder_kwargs = {
111111
"sigma_radius": self.sigma_radius,
112-
"minsep_fwhm": self.minsep_fwhm,
113-
"sharplo": self.sharplo,
114-
"sharphi": self.sharphi,
115-
"roundlo": self.roundlo,
116-
"roundhi": self.roundhi,
117-
"peakmax": self.peakmax,
118-
"brightest": self.brightest,
119-
"npixels": self.npixels,
112+
"min_separation": max(2, int(self.minsep_fwhm * self.kernel_fwhm + 0.5)),
113+
"sharpness_range": (self.sharplo, self.sharphi),
114+
"roundness_range": (self.roundlo, self.roundhi),
115+
"peak_max": self.peakmax,
116+
"n_brightest": self.brightest,
117+
"n_pixels": self.npixels,
120118
"connectivity": int(self.connectivity), # option returns a string, so cast to int
121-
"nlevels": self.nlevels,
119+
"n_levels": self.nlevels,
122120
"contrast": self.contrast,
123121
"mode": self.multithresh_mode,
124-
"localbkg_width": self.localbkg_width,
125-
"apermask_method": self.apermask_method,
122+
"local_bkg_width": self.localbkg_width,
123+
"aperture_mask_method": self.apermask_method,
126124
"kron_params": self.kron_params,
127125
"deblend": self.deblend,
128126
"error": output_model.err,

jwst/source_catalog/tests/test_source_catalog.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from pathlib import Path
22

3+
import astropy.units as u
34
import numpy as np
45
import pytest
56
import stdatamodels.jwst.datamodels as dm
@@ -63,7 +64,10 @@ def test_source_catalog(nircam_model, npixels, nsources):
6364
assert np.isclose(cat["isophotal_abmag"][1], 19.150, atol=0.001)
6465
assert np.isclose(cat["semimajor_sigma"][1].value, 18.844, atol=0.001)
6566
assert np.isclose(cat["semiminor_sigma"][1].value, 7.025, atol=0.001)
66-
assert np.isclose(cat["ellipticity"][1].value, 0.627, atol=0.001)
67+
ellipticity = cat["ellipticity"][1]
68+
if isinstance(ellipticity, u.Quantity):
69+
ellipticity = ellipticity.value
70+
assert np.isclose(ellipticity, 0.627, atol=0.001)
6771
assert np.isclose(cat["orientation"][1].value, -72.783, atol=0.001) or np.isclose(
6872
cat["orientation"][1].value, 287.217, atol=0.001
6973
)

jwst/tweakreg/tests/test_tweakreg.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@
33

44
import asdf
55
import numpy as np
6-
import photutils
76
import pytest
87
from astropy.table import QTable, Table
9-
from astropy.utils import minversion
108
from astropy.utils.data import get_pkg_data_filename
119
from astropy.wcs import WCS
1210
from gwcs.wcstools import grid_from_bounding_box
@@ -22,17 +20,12 @@
2220
N_EXAMPLE_SOURCES = 21
2321
N_CUSTOM_SOURCES = 15
2422
REFCAT = "GAIADR3"
25-
PHOTUTILS_GE_3 = minversion(photutils, "2.3.1.dev")
2623

2724
# The tweakreg catalog output always uses 'xcentroid'/'ycentroid',
2825
# but _rename_catalog_columns and user-supplied catalogs may use
2926
# either the old or new photutils column names.
30-
if PHOTUTILS_GE_3:
31-
X_NAME = "x_centroid"
32-
Y_NAME = "y_centroid"
33-
else:
34-
X_NAME = "xcentroid"
35-
Y_NAME = "ycentroid"
27+
X_NAME = "x_centroid"
28+
Y_NAME = "y_centroid"
3629

3730

3831
@pytest.fixture

0 commit comments

Comments
 (0)