Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/10471.other.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Numpy >= 2.0, Astropy >= 6.1.4, and Photutils >= 3.0 are now required.
7 changes: 1 addition & 6 deletions jwst/extract_1d/ifu.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
import warnings

import numpy as np
import photutils
from astropy import stats
from astropy.stats import sigma_clipped_stats as sigclip
from astropy.utils import minversion
from photutils.aperture import (
CircularAnnulus,
CircularAperture,
Expand Down Expand Up @@ -662,10 +660,7 @@ def extract_ifu(input_model, source_type, extract_params):
# Identify brightest source as the target
indx = np.argmax(vals)

if minversion(photutils, "2.3.1.dev"):
x_center, y_center = sources[indx]["x_centroid"], sources[indx]["y_centroid"]
else:
x_center, y_center = sources[indx]["xcentroid"], sources[indx]["ycentroid"]
x_center, y_center = sources[indx]["x_centroid"], sources[indx]["y_centroid"]
locn = None
log.info("Auto source detection success.")
log.info("Using x_center = %g, y_center = %g", x_center, y_center)
Expand Down
6 changes: 3 additions & 3 deletions jwst/regtest/test_niriss_sourcefind.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ def test_tweakreg_catalog_starfinder_alternatives(rtdata, starfinder):
bkg_boxsize=10.0,
starfinder_name=starfinder,
starfinder_kwargs={
"brightest": None,
"sharphi": 3.0,
"minsep_fwhm": 2.5,
"n_brightest": None,
"sharpness_range": (0.5, 3.0),
"min_separation": max(2, int(2.5 * 2.5 + 0.5)),
"sigma_radius": 2.5,
},
)
Expand Down
16 changes: 4 additions & 12 deletions jwst/source_catalog/source_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@

import astropy.units as u
import numpy as np
import photutils
from astropy.convolution import Gaussian2DKernel
from astropy.nddata.utils import NoOverlapError, extract_array
from astropy.stats import SigmaClip, gaussian_fwhm_to_sigma
from astropy.table import QTable
from astropy.utils import lazyproperty, minversion
from astropy.utils import lazyproperty
from astropy.utils.exceptions import AstropyUserWarning
from photutils.aperture import CircularAnnulus, CircularAperture, aperture_photometry
from scipy import ndimage
Expand All @@ -24,8 +23,6 @@

__all__ = ["JWSTSourceCatalog"]

PHOTUTILS_GE_3 = minversion(photutils, "2.3.1.dev")


class JWSTSourceCatalog:
"""
Expand Down Expand Up @@ -241,16 +238,11 @@ def set_segment_properties(self):
rename_map = {
"label": "id",
"isophotal_flux": "flux",
"isophotal_flux_err": "segment_fluxerr",
"isophotal_area": "area",
"semimajor_sigma": "semimajor_axis",
"semiminor_sigma": "semiminor_axis",
"isophotal_flux_err": "segment_flux_err",
}
if PHOTUTILS_GE_3:
rename_new = {
"semimajor_sigma": "semimajor_axis",
"semiminor_sigma": "semiminor_axis",
"isophotal_flux_err": "segment_flux_err",
}
rename_map.update(rename_new)

for column in self.segment_colnames:
# define the property name
Expand Down
23 changes: 12 additions & 11 deletions jwst/source_catalog/source_catalog_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,22 +107,23 @@ def process(self, input_data):
# convert to Jy before calling make_tweakreg_catalog so the outputs end up in Jy
JWSTSourceCatalog.convert_mjysr_to_jy(output_model)

min_separation = (
max(2, int(self.minsep_fwhm * self.kernel_fwhm + 0.5)) if self.minsep_fwhm else None
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't self.minsep_fwhm always be set as an attribute since it's in the spec, so there's no need for the None setting if undefined?

)
starfinder_kwargs = {
"sigma_radius": self.sigma_radius,
"minsep_fwhm": self.minsep_fwhm,
"sharplo": self.sharplo,
"sharphi": self.sharphi,
"roundlo": self.roundlo,
"roundhi": self.roundhi,
"peakmax": self.peakmax,
"brightest": self.brightest,
"npixels": self.npixels,
"min_separation": min_separation,
"sharpness_range": (self.sharplo, self.sharphi),
"roundness_range": (self.roundlo, self.roundhi),
"peak_max": self.peakmax,
"n_brightest": self.brightest,
"n_pixels": self.npixels,
"connectivity": int(self.connectivity), # option returns a string, so cast to int
"nlevels": self.nlevels,
"n_levels": self.nlevels,
"contrast": self.contrast,
"mode": self.multithresh_mode,
"localbkg_width": self.localbkg_width,
"apermask_method": self.apermask_method,
"local_bkg_width": self.localbkg_width,
"aperture_mask_method": self.apermask_method,
"kron_params": self.kron_params,
"deblend": self.deblend,
"error": output_model.err,
Expand Down
6 changes: 5 additions & 1 deletion jwst/source_catalog/tests/test_source_catalog.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from pathlib import Path

import astropy.units as u
import numpy as np
import pytest
import stdatamodels.jwst.datamodels as dm
Expand Down Expand Up @@ -63,7 +64,10 @@ def test_source_catalog(nircam_model, npixels, nsources):
assert np.isclose(cat["isophotal_abmag"][1], 19.150, atol=0.001)
assert np.isclose(cat["semimajor_sigma"][1].value, 18.844, atol=0.001)
assert np.isclose(cat["semiminor_sigma"][1].value, 7.025, atol=0.001)
assert np.isclose(cat["ellipticity"][1].value, 0.627, atol=0.001)
ellipticity = cat["ellipticity"][1]
if isinstance(ellipticity, u.Quantity):
ellipticity = ellipticity.value
Comment on lines +68 to +69
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is an if...else necessary here? Shouldn't it always be one or the other, a Quantity or not?

assert np.isclose(ellipticity, 0.627, atol=0.001)
assert np.isclose(cat["orientation"][1].value, -72.783, atol=0.001) or np.isclose(
cat["orientation"][1].value, 287.217, atol=0.001
)
Expand Down
11 changes: 2 additions & 9 deletions jwst/tweakreg/tests/test_tweakreg.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@

import asdf
import numpy as np
import photutils
import pytest
from astropy.table import QTable, Table
from astropy.utils import minversion
from astropy.utils.data import get_pkg_data_filename
from astropy.wcs import WCS
from gwcs.wcstools import grid_from_bounding_box
Expand All @@ -22,17 +20,12 @@
N_EXAMPLE_SOURCES = 21
N_CUSTOM_SOURCES = 15
REFCAT = "GAIADR3"
PHOTUTILS_GE_3 = minversion(photutils, "2.3.1.dev")

# The tweakreg catalog output always uses 'xcentroid'/'ycentroid',
# but _rename_catalog_columns and user-supplied catalogs may use
# either the old or new photutils column names.
Comment on lines 24 to 26
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this comment still relevant?

if PHOTUTILS_GE_3:
X_NAME = "x_centroid"
Y_NAME = "y_centroid"
else:
X_NAME = "xcentroid"
Y_NAME = "ycentroid"
X_NAME = "x_centroid"
Y_NAME = "y_centroid"


@pytest.fixture
Expand Down
Loading
Loading