From 296ce6d786a9eed5b398d013dc20b5e7e7e2f489 Mon Sep 17 00:00:00 2001 From: Nadia Dencheva Date: Fri, 10 May 2024 15:25:23 -0400 Subject: [PATCH 01/22] add a change log --- CHANGES.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 1041652782..83af028654 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -52,7 +52,7 @@ associations - Excluded nearby background candidates from NIRSpec fixed slit associations for S1600A1 with 5 point dithers, to reduce overlap between background nods and science exposure. [#8744] - + - Added association rule for level 3 image mosaic candidates. [#8798] badpix_selfcal @@ -283,7 +283,7 @@ pipeline optional `on_disk` parameter to govern whether models in the library should be stored in memory or on disk. [#8683] -- Updated ``calwebb_spec2`` to run ``nsclean`` on NIRSpec imprint and background +- Updated ``calwebb_spec2`` to run ``nsclean`` on NIRSpec imprint and background association members. [#8786, #8809] - Updated `calwebb_spec3` to not save the `pixel_replacement` output by default.[#8765] From f5c975d61ffd25800886848faa3e4a9dcfa29991 Mon Sep 17 00:00:00 2001 From: Nadia Dencheva Date: Mon, 20 May 2024 09:04:08 -0400 Subject: [PATCH 02/22] gwcs inverse fixes --- jwst/skymatch/skyimage.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jwst/skymatch/skyimage.py b/jwst/skymatch/skyimage.py index 65bc943bec..8a6ca6f3c8 100644 --- a/jwst/skymatch/skyimage.py +++ b/jwst/skymatch/skyimage.py @@ -619,7 +619,7 @@ def calc_sky(self, overlap=None, delta=True): continue # set pixels in 'fill_mask' that are inside a polygon to True: - x, y = self.wcs_inv(ra, dec) + x, y = self.wcs_inv(ra, dec, with_bounding_box=False) poly_vert = list(zip(*[x, y])) polygon = region.Polygon(True, poly_vert) From 45a4eacfc76e230d63e299ce0553e8fd5cbb339f Mon Sep 17 00:00:00 2001 From: Nadia Dencheva Date: Thu, 30 May 2024 17:17:12 -0400 Subject: [PATCH 03/22] make it backwards compatible --- jwst/assign_wcs/util.py | 2 +- jwst/resample/resample_utils.py | 34 +++++++++++++++++----- jwst/resample/tests/test_utils.py | 4 +-- jwst/tweakreg/tests/test_multichip_jwst.py | 8 +++-- 4 files changed, 35 insertions(+), 13 deletions(-) diff --git a/jwst/assign_wcs/util.py b/jwst/assign_wcs/util.py index d8e492587f..4a624543c3 100644 --- a/jwst/assign_wcs/util.py +++ b/jwst/assign_wcs/util.py @@ -127,7 +127,7 @@ def compute_scale(wcs: WCS, fiducial: Union[tuple, np.ndarray], if spectral and disp_axis is None: raise ValueError('If input WCS is spectral, a disp_axis must be given') - crpix = np.array(wcs.invert(*fiducial)) + crpix = np.array(wcs.invert(*fiducial, with_bounding_box=False)) delta = np.zeros_like(crpix) spatial_idx = np.where(np.array(wcs.output_frame.axes_type) == 'SPATIAL')[0] diff --git a/jwst/resample/resample_utils.py b/jwst/resample/resample_utils.py index 4d126ed28c..3348e021fc 100644 --- a/jwst/resample/resample_utils.py +++ b/jwst/resample/resample_utils.py @@ -4,6 +4,7 @@ import numpy as np from astropy import units as u +from astropy import wcs as fitswcs import gwcs from stdatamodels.dqflags import interpret_bit_flags @@ -162,21 +163,40 @@ def reproject(wcs1, wcs2): positions in ``wcs1`` and returns x, y positions in ``wcs2``. """ - try: - forward_transform = wcs1.pixel_to_world_values - backward_transform = wcs2.world_to_pixel_values - except AttributeError as err: - raise TypeError("Input should be a WCS") from err + # try: + # # forward_transform = wcs1.pixel_to_world_values + # # backward_transform = wcs2.world_to_pixel_values + # forward_transform = wcs1.forward_transform + # backward_transform = wcs2.backward_transform + # except AttributeError as err: + # raise TypeError("Input should be a WCS") from err + def _get_forward(wcs): + if isinstance(wcs, gwcs.WCS): + return wcs.forward_transform + elif isinstance(wcs, fitswcs.WCS): + return wcs.pixel_to_world + elif isinstance(wcs, Model): + return wcs + + def _get_backward(wcs): + if isinstance(wcs, gwcs.WCS): + return wcs.backward_transform + elif isinstance(wcs, fitswcs.WCS): + return wcs.world_to_pixel + elif isinstance(wcs, Model): + return wcs def _reproject(x, y): - sky = forward_transform(x, y) + #sky = forward_transform(x, y) + sky = _get_forward(wcs1)(x, y) flat_sky = [] for axis in sky: flat_sky.append(axis.flatten()) # Filter out RuntimeWarnings due to computed NaNs in the WCS with warnings.catch_warnings(): warnings.simplefilter("ignore", RuntimeWarning) - det = backward_transform(*tuple(flat_sky)) + #det = backward_transform(*tuple(flat_sky)) + det = _get_backward(wcs2)(*tuple(flat_sky)) det_reshaped = [] for axis in det: det_reshaped.append(axis.reshape(x.shape)) diff --git a/jwst/resample/tests/test_utils.py b/jwst/resample/tests/test_utils.py index 7e7deb3070..518fc61998 100644 --- a/jwst/resample/tests/test_utils.py +++ b/jwst/resample/tests/test_utils.py @@ -38,7 +38,7 @@ def wcs_gwcs(): crpix = (500.0, 500.0) shape = (1000, 1000) pscale = 0.06 / 3600 - + prj = astmodels.Pix2Sky_TAN() fiducial = np.array(crval) @@ -193,7 +193,7 @@ def test_reproject(wcs1, wcs2, offset, request): wcs1 = request.getfixturevalue(wcs1) wcs2 = request.getfixturevalue(wcs2) x = np.arange(150, 200) - + f = reproject(wcs1, wcs2) res = f(x, x) assert_allclose(x, res[0] + offset) diff --git a/jwst/tweakreg/tests/test_multichip_jwst.py b/jwst/tweakreg/tests/test_multichip_jwst.py index 4402f7b897..b8e2f1a08a 100644 --- a/jwst/tweakreg/tests/test_multichip_jwst.py +++ b/jwst/tweakreg/tests/test_multichip_jwst.py @@ -81,7 +81,7 @@ def _make_gwcs_wcs(fits_hdr): Mapping((1, 2), name='xtyt')) c2tan.name = 'Cartesian 3D to TAN' - tan2c = (Mapping((0, 0, 1), n_inputs=2, name='xtyt2xyz') | + tan2c = (Mapping((0, 0, 1), name='xtyt2xyz') | (Const1D(1, name='one') & Identity(2, name='I(2D)'))) tan2c.name = 'TAN to cartesian 3D' @@ -376,7 +376,8 @@ def test_multichip_alignment_step_rel(monkeypatch): format='ascii.ecsv', delimiter=' ', names=['RA', 'DEC'] ) - x, y = wr.world_to_pixel(refcat['RA'], refcat['DEC']) + #x, y = wr.world_to_pixel(refcat['RA'].value, refcat['DEC'].value) + x, y = wr.invert(refcat['RA'].value, refcat['DEC'].value, with_bounding_box=False) refcat['x'] = x refcat['y'] = y mr.tweakreg_catalog = refcat @@ -459,7 +460,8 @@ def test_multichip_alignment_step_abs(monkeypatch): format='ascii.ecsv', delimiter=' ', names=['RA', 'DEC'] ) - x, y = wr.world_to_pixel(refcat['RA'], refcat['DEC']) + #x, y = wr.world_to_pixel(refcat['RA'], refcat['DEC']) + x, y = wr.invert(refcat['RA'].value, refcat['DEC'].value, with_bounding_box=False) refcat['x'] = x refcat['y'] = y mr.tweakreg_catalog = refcat From 4d3278564ec20ba26a7af3c8593025a00e5ff2e5 Mon Sep 17 00:00:00 2001 From: Nadia Dencheva Date: Sat, 8 Jun 2024 08:59:54 -0400 Subject: [PATCH 04/22] add missing import --- jwst/resample/resample_utils.py | 1 + 1 file changed, 1 insertion(+) diff --git a/jwst/resample/resample_utils.py b/jwst/resample/resample_utils.py index 3348e021fc..e6a5613647 100644 --- a/jwst/resample/resample_utils.py +++ b/jwst/resample/resample_utils.py @@ -5,6 +5,7 @@ import numpy as np from astropy import units as u from astropy import wcs as fitswcs +from astropy.modeling import Model import gwcs from stdatamodels.dqflags import interpret_bit_flags From cdd0e6516ea68e34d65cbaedb1536099f0888137 Mon Sep 17 00:00:00 2001 From: Nadia Dencheva Date: Tue, 29 Oct 2024 16:07:36 -0400 Subject: [PATCH 05/22] fix reproject --- jwst/resample/resample_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jwst/resample/resample_utils.py b/jwst/resample/resample_utils.py index e6a5613647..26bc8e85de 100644 --- a/jwst/resample/resample_utils.py +++ b/jwst/resample/resample_utils.py @@ -175,7 +175,7 @@ def _get_forward(wcs): if isinstance(wcs, gwcs.WCS): return wcs.forward_transform elif isinstance(wcs, fitswcs.WCS): - return wcs.pixel_to_world + return wcs.pixel_to_world_values elif isinstance(wcs, Model): return wcs @@ -183,7 +183,7 @@ def _get_backward(wcs): if isinstance(wcs, gwcs.WCS): return wcs.backward_transform elif isinstance(wcs, fitswcs.WCS): - return wcs.world_to_pixel + return wcs.world_to_pixel_values elif isinstance(wcs, Model): return wcs From 99d927e3fb52f7faf42b70e986de41e05e8e628d Mon Sep 17 00:00:00 2001 From: Nadia Dencheva Date: Thu, 31 Oct 2024 08:12:37 -0400 Subject: [PATCH 06/22] fix resample's reproject --- jwst/resample/resample_utils.py | 40 ++++++++--------------- jwst/resample/tests/test_resample_step.py | 6 ++-- 2 files changed, 17 insertions(+), 29 deletions(-) diff --git a/jwst/resample/resample_utils.py b/jwst/resample/resample_utils.py index 26bc8e85de..8678b7335a 100644 --- a/jwst/resample/resample_utils.py +++ b/jwst/resample/resample_utils.py @@ -164,40 +164,28 @@ def reproject(wcs1, wcs2): positions in ``wcs1`` and returns x, y positions in ``wcs2``. """ - # try: - # # forward_transform = wcs1.pixel_to_world_values - # # backward_transform = wcs2.world_to_pixel_values - # forward_transform = wcs1.forward_transform - # backward_transform = wcs2.backward_transform - # except AttributeError as err: - # raise TypeError("Input should be a WCS") from err - def _get_forward(wcs): - if isinstance(wcs, gwcs.WCS): - return wcs.forward_transform - elif isinstance(wcs, fitswcs.WCS): - return wcs.pixel_to_world_values - elif isinstance(wcs, Model): - return wcs - - def _get_backward(wcs): - if isinstance(wcs, gwcs.WCS): - return wcs.backward_transform - elif isinstance(wcs, fitswcs.WCS): - return wcs.world_to_pixel_values - elif isinstance(wcs, Model): - return wcs + try: + # Here we want to use the WCS API functions so that a Sliced WCS + # will work as well. However, the API functions do not accept + # keyword arguments and `with_bounding_box=False` cannot be passsed. + # We delete the bounding box on a copy of the WCS - yes, inefficient. + forward_transform = wcs1.pixel_to_world_values + wcs_no_bbox = deepcopy(wcs2) + wcs_no_bbox.bounding_box = None + backward_transform = wcs_no_bbox.world_to_pixel_values + except AttributeError as err: + raise TypeError("Input should be a WCS") from err + def _reproject(x, y): - #sky = forward_transform(x, y) - sky = _get_forward(wcs1)(x, y) + sky = forward_transform(x, y) flat_sky = [] for axis in sky: flat_sky.append(axis.flatten()) # Filter out RuntimeWarnings due to computed NaNs in the WCS with warnings.catch_warnings(): warnings.simplefilter("ignore", RuntimeWarning) - #det = backward_transform(*tuple(flat_sky)) - det = _get_backward(wcs2)(*tuple(flat_sky)) + det = backward_transform(*tuple(flat_sky)) det_reshaped = [] for axis in det: det_reshaped.append(axis.reshape(x.shape)) diff --git a/jwst/resample/tests/test_resample_step.py b/jwst/resample/tests/test_resample_step.py index 75eddb8530..178340ccb4 100644 --- a/jwst/resample/tests/test_resample_step.py +++ b/jwst/resample/tests/test_resample_step.py @@ -831,9 +831,9 @@ def test_resample_undefined_variance(nircam_rate, shape): @pytest.mark.parametrize('ratio', [0.7, 1.2]) @pytest.mark.parametrize('rotation', [0, 15, 135]) -@pytest.mark.parametrize('crpix', [(256, 488), (700, 124)]) -@pytest.mark.parametrize('crval', [(50, 77), (20, -30)]) -@pytest.mark.parametrize('shape', [(1205, 1100)]) +@pytest.mark.parametrize('crpix', [(100, 101), (101, 101)]) +@pytest.mark.parametrize('crval', [(22.01, 12), (22.15, 12.01)]) +@pytest.mark.parametrize('shape', [(10205, 10100)]) def test_custom_wcs_resample_imaging(nircam_rate, ratio, rotation, crpix, crval, shape): im = AssignWcsStep.call(nircam_rate, sip_approx=False) im.data += 5 From f7bfbf19cc3baff4001e3d54a72732d5e74b0ce1 Mon Sep 17 00:00:00 2001 From: Nadia Dencheva Date: Tue, 10 Dec 2024 16:50:26 -0500 Subject: [PATCH 07/22] point to gwcs branch --- pyproject.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index ef138c0999..9d4cda53fb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,7 +23,8 @@ dependencies = [ "BayesicFitting>=3.0.1", "crds>=12.0.3", "drizzle>=2.0.0", - "gwcs>=0.21.0,<0.23.0", + #"gwcs>=0.21.0,<0.23.0", + "gwcs @ git+https://github.com/nden/gwcs.git@inverse-bbox", "numpy>=1.22,<2.0", "opencv-python-headless>=4.6.0.66", "photutils>=1.5.0", From 4308b577f2b2170868ac704a4e7d0715afbb97d0 Mon Sep 17 00:00:00 2001 From: Nadia Dencheva Date: Thu, 12 Dec 2024 17:13:59 -0500 Subject: [PATCH 08/22] point to stcal branch --- pyproject.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 9d4cda53fb..c4f2e4172d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,7 +34,8 @@ dependencies = [ "scikit-image>=0.19", "scipy>=1.9.3", "spherical-geometry>=1.2.22", - "stcal @ git+https://github.com/spacetelescope/stcal.git@main", + #"stcal @ git+https://github.com/spacetelescope/stcal.git@main", + "stcal @ git+https://github.com/nden/stcal.git@inverse-wcs-bbox", "stdatamodels @ git+https://github.com/spacetelescope/stdatamodels.git@main", "stpipe @ git+https://github.com/spacetelescope/stpipe.git@main", "stsci.imagestats>=1.6.3", From 6a05b4a8e9e7121bad68b30f381b426300410082 Mon Sep 17 00:00:00 2001 From: Ned Molter Date: Mon, 16 Dec 2024 13:26:46 -0500 Subject: [PATCH 09/22] Update pyproject.toml --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index acca8fea3c..5ee35d19f9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,7 +23,7 @@ dependencies = [ "BayesicFitting>=3.0.1", "crds>=12.0.3", "drizzle>=2.0.0", - "gwcs @ git+https://github.com/nden/gwcs.git@master", + "gwcs @ git+https://github.com/spacetelescope/gwcs.git@master", "numpy>=1.22,<2.0", "opencv-python-headless>=4.6.0.66", "photutils>=1.5.0", From eb202395c3ca138fe6ed97252c12f67b5261a62f Mon Sep 17 00:00:00 2001 From: Ned Molter Date: Mon, 16 Dec 2024 16:09:36 -0500 Subject: [PATCH 10/22] fixed outlier test failures --- .../tests/test_outlier_detection.py | 48 ++++++++++++------- jwst/resample/resample_utils.py | 2 - pyproject.toml | 2 +- 3 files changed, 31 insertions(+), 21 deletions(-) diff --git a/jwst/outlier_detection/tests/test_outlier_detection.py b/jwst/outlier_detection/tests/test_outlier_detection.py index 008ae19c64..7a079b8940 100644 --- a/jwst/outlier_detection/tests/test_outlier_detection.py +++ b/jwst/outlier_detection/tests/test_outlier_detection.py @@ -108,21 +108,17 @@ def test_flag_cr(sci_blot_image_pair): assert sci.dq[10, 10] == datamodels.dqflags.pixel["GOOD"] -# not a fixture - now has options -def we_many_sci( - numsci=3, sigma=0.02, background=1.5, signal=7, exptype="MIR_IMAGE", tsovisit=False -): - """Provide numsci science images with different noise but identical source - and same background level""" - shape = (21, 20) +def make_sci1(shape): + """Needs to be a fixture because we want to change exposure.type + in the subsequent tests without rerunning AssignWCS""" sci1 = datamodels.ImageModel(shape) # Populate keywords sci1.meta.instrument.name = "MIRI" sci1.meta.instrument.detector = "MIRIMAGE" - sci1.meta.exposure.type = exptype - sci1.meta.visit.tsovisit = tsovisit + sci1.meta.exposure.type = "MIR_IMAGE" + sci1.meta.visit.tsovisit = False sci1.meta.observation.date = "2020-01-01" sci1.meta.observation.time = "00:00:00" sci1.meta.telescope = "JWST" @@ -135,6 +131,8 @@ def we_many_sci( sci1.meta.wcsinfo.roll_ref = 0 sci1.meta.wcsinfo.ra_ref = 1.5e-5 sci1.meta.wcsinfo.dec_ref = 1.5e-5 + sci1.meta.wcsinfo.v2_ref = 0 + sci1.meta.wcsinfo.v3_ref = 0 sci1.meta.wcsinfo.v3yangle = 0 sci1.meta.wcsinfo.vparity = -1 sci1.meta.wcsinfo.pc1_1 = 1 @@ -148,11 +146,29 @@ def we_many_sci( sci1.meta.wcsinfo.cunit1 = "deg" sci1.meta.wcsinfo.cunit2 = "deg" sci1.meta.background.subtracted = False - sci1.meta.background.level = background + sci1.meta.background.level = 1.5 + + sci1 = AssignWcsStep.call(sci1) + + sci1.meta.filename = "foo1_cal.fits" + + # add pixel areas + sci1.meta.photometry.pixelarea_steradians = 1.0 + sci1.meta.photometry.pixelarea_arcsecsq = 1.0 + return sci1 + + +# not a fixture - now has options +def we_many_sci( + numsci=3, sigma=0.02, background=1.5, signal=7, exptype="MIR_IMAGE", tsovisit=False +): + """Provide numsci science images with different noise but identical source + and same background level""" + shape = (21,20) + sci1 = make_sci1(shape) + sci1.meta.exposure.type = exptype + sci1.meta.visit.tsovisit = tsovisit - # Replace the FITS-type WCS with an Identity WCS - sci1.meta.wcs = create_fitswcs(sci1) - sci1.meta.wcsinfo.s_region = compute_s_region_imaging(sci1.meta.wcs, shape=shape, center=False) rng = np.random.default_rng(720) sci1.data = rng.normal(loc=background, size=shape, scale=sigma) sci1.err = np.zeros(shape) + sigma @@ -160,11 +176,7 @@ def we_many_sci( # update the noise for this source to include the photon/measurement noise sci1.err[7, 7] = np.sqrt(sigma ** 2 + signal) sci1.var_rnoise = np.zeros(shape) + 1.0 - sci1.meta.filename = "foo1_cal.fits" - # add pixel areas - sci1.meta.photometry.pixelarea_steradians = 1.0 - sci1.meta.photometry.pixelarea_arcsecsq = 1.0 # Make copies with different noise all_sci = [sci1] @@ -650,7 +662,7 @@ def test_drizzle_and_median_with_resample(three_sci_as_asn, tmp_cwd): 0.7) assert isinstance(wcs, WCS) - assert median.shape == (21,20) + assert median.shape == (34,34) resamp.single = False with pytest.raises(ValueError): diff --git a/jwst/resample/resample_utils.py b/jwst/resample/resample_utils.py index 8678b7335a..da917d7e41 100644 --- a/jwst/resample/resample_utils.py +++ b/jwst/resample/resample_utils.py @@ -4,8 +4,6 @@ import numpy as np from astropy import units as u -from astropy import wcs as fitswcs -from astropy.modeling import Model import gwcs from stdatamodels.dqflags import interpret_bit_flags diff --git a/pyproject.toml b/pyproject.toml index acca8fea3c..5ee35d19f9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,7 +23,7 @@ dependencies = [ "BayesicFitting>=3.0.1", "crds>=12.0.3", "drizzle>=2.0.0", - "gwcs @ git+https://github.com/nden/gwcs.git@master", + "gwcs @ git+https://github.com/spacetelescope/gwcs.git@master", "numpy>=1.22,<2.0", "opencv-python-headless>=4.6.0.66", "photutils>=1.5.0", From b356370465bf0b61950d6fcba28eed4639386795 Mon Sep 17 00:00:00 2001 From: Nadia Dencheva Date: Wed, 18 Dec 2024 12:58:52 -0500 Subject: [PATCH 11/22] change MIRI LRS bbox to match the interpolation model 'points' range. Bump min version of asdf. Fix tweakreg step test. --- jwst/assign_wcs/miri.py | 2 ++ jwst/tweakreg/tests/test_multichip_jwst.py | 2 -- pyproject.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/jwst/assign_wcs/miri.py b/jwst/assign_wcs/miri.py index 59ec01d959..f15938ce88 100644 --- a/jwst/assign_wcs/miri.py +++ b/jwst/assign_wcs/miri.py @@ -310,6 +310,8 @@ def lrs_xytoabl(input_model, reference_files): dxmodel = models.Tabular1D(lookup_table=xshiftref, points=ycen_subarray, name='xshiftref', bounds_error=False, fill_value=np.nan) + if input_model.meta.exposure.type.lower() == 'mir_lrs-fixedslit': + bb_sub = (bb_sub[0], (dxmodel.points[0].min(), dxmodel.points[0].max())) # Fit for the wavelength as a function of Y # Reverse the vectors so that yinv is increasing (needed for spline fitting function) # Spline fit with enforced smoothness diff --git a/jwst/tweakreg/tests/test_multichip_jwst.py b/jwst/tweakreg/tests/test_multichip_jwst.py index b8e2f1a08a..352d089e5a 100644 --- a/jwst/tweakreg/tests/test_multichip_jwst.py +++ b/jwst/tweakreg/tests/test_multichip_jwst.py @@ -376,7 +376,6 @@ def test_multichip_alignment_step_rel(monkeypatch): format='ascii.ecsv', delimiter=' ', names=['RA', 'DEC'] ) - #x, y = wr.world_to_pixel(refcat['RA'].value, refcat['DEC'].value) x, y = wr.invert(refcat['RA'].value, refcat['DEC'].value, with_bounding_box=False) refcat['x'] = x refcat['y'] = y @@ -460,7 +459,6 @@ def test_multichip_alignment_step_abs(monkeypatch): format='ascii.ecsv', delimiter=' ', names=['RA', 'DEC'] ) - #x, y = wr.world_to_pixel(refcat['RA'], refcat['DEC']) x, y = wr.invert(refcat['RA'].value, refcat['DEC'].value, with_bounding_box=False) refcat['x'] = x refcat['y'] = y diff --git a/pyproject.toml b/pyproject.toml index 5ee35d19f9..ab1a148b07 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,7 +18,7 @@ classifiers = [ "Programming Language :: Python :: 3.12", ] dependencies = [ - "asdf>=3.1.0,<5", + "asdf>=3.3,<5", "astropy>=5.3", "BayesicFitting>=3.0.1", "crds>=12.0.3", From 10a823fb4e33f8a9dd84c7212ea83e6fb97aef1f Mon Sep 17 00:00:00 2001 From: Nadia Dencheva Date: Wed, 18 Dec 2024 13:13:30 -0500 Subject: [PATCH 12/22] add changelog, remove unused imports --- changes/8554.assign_wcs.rst | 2 ++ changes/8554.resample.rst | 1 + changes/8554.skyimage.rst | 1 + jwst/outlier_detection/tests/test_outlier_detection.py | 2 -- 4 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 changes/8554.assign_wcs.rst create mode 100644 changes/8554.resample.rst create mode 100644 changes/8554.skyimage.rst diff --git a/changes/8554.assign_wcs.rst b/changes/8554.assign_wcs.rst new file mode 100644 index 0000000000..1d530a9caa --- /dev/null +++ b/changes/8554.assign_wcs.rst @@ -0,0 +1,2 @@ +Use the range of points in the TabularModel to adjust the bounding_box in a MIRIR LRS FIXEDSLIT observation. +Ignore the bounding_box in running the inverse WCS transform when computing crpix. diff --git a/changes/8554.resample.rst b/changes/8554.resample.rst new file mode 100644 index 0000000000..bda0397ae8 --- /dev/null +++ b/changes/8554.resample.rst @@ -0,0 +1 @@ +Ignore the bounding_box in the inverse WCS transform in reproject. diff --git a/changes/8554.skyimage.rst b/changes/8554.skyimage.rst new file mode 100644 index 0000000000..1561af36b6 --- /dev/null +++ b/changes/8554.skyimage.rst @@ -0,0 +1 @@ +Ignore the bounding_box of an observation when computing sky statistics. diff --git a/jwst/outlier_detection/tests/test_outlier_detection.py b/jwst/outlier_detection/tests/test_outlier_detection.py index 7a079b8940..7e03300422 100644 --- a/jwst/outlier_detection/tests/test_outlier_detection.py +++ b/jwst/outlier_detection/tests/test_outlier_detection.py @@ -6,11 +6,9 @@ from gwcs.wcs import WCS from stdatamodels.jwst import datamodels -from stcal.alignment.util import compute_s_region_imaging from jwst.datamodels import ModelContainer, ModelLibrary from jwst.assign_wcs import AssignWcsStep -from jwst.assign_wcs.pointing import create_fitswcs from jwst.outlier_detection import OutlierDetectionStep from jwst.outlier_detection.utils import _flag_resampled_model_crs from jwst.outlier_detection.outlier_detection_step import ( From e2440f5c0d82d7230e46e1babf431d71592ed740 Mon Sep 17 00:00:00 2001 From: Nadia Dencheva Date: Wed, 18 Dec 2024 13:15:02 -0500 Subject: [PATCH 13/22] bump min version of astropy to 6.0 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index ab1a148b07..e114c36fd3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,7 +19,7 @@ classifiers = [ ] dependencies = [ "asdf>=3.3,<5", - "astropy>=5.3", + "astropy>=6.0", "BayesicFitting>=3.0.1", "crds>=12.0.3", "drizzle>=2.0.0", From 588187d68823b899066e69d6150e6da6db3868f7 Mon Sep 17 00:00:00 2001 From: Nadia Dencheva Date: Wed, 18 Dec 2024 14:23:45 -0500 Subject: [PATCH 14/22] change change fragmet name --- changes/{8554.skyimage.rst => 8554.skymatch.rst} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename changes/{8554.skyimage.rst => 8554.skymatch.rst} (100%) diff --git a/changes/8554.skyimage.rst b/changes/8554.skymatch.rst similarity index 100% rename from changes/8554.skyimage.rst rename to changes/8554.skymatch.rst From 6f3e96534924237b889359d6911c74571df25dbb Mon Sep 17 00:00:00 2001 From: Nadia Dencheva Date: Wed, 18 Dec 2024 16:45:01 -0500 Subject: [PATCH 15/22] bump versions of astropy and asdf-astropy --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index e114c36fd3..4351005b34 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,7 +19,7 @@ classifiers = [ ] dependencies = [ "asdf>=3.3,<5", - "astropy>=6.0", + "astropy>=6.1", "BayesicFitting>=3.0.1", "crds>=12.0.3", "drizzle>=2.0.0", @@ -39,7 +39,7 @@ dependencies = [ "stsci.imagestats>=1.6.3", "synphot>=1.2", "tweakwcs>=0.8.8", - "asdf-astropy>=0.3.0", + "asdf-astropy>=0.5.0", "wiimatch>=0.2.1", "packaging>20.0", "importlib-metadata>=4.11.4", From 780fbdb219150799c5ad065e27c18bdfbf5e8600 Mon Sep 17 00:00:00 2001 From: Melanie Clarke Date: Thu, 19 Dec 2024 10:13:11 -0500 Subject: [PATCH 16/22] Reverting formatting changes to CHANGES.rst --- CHANGES.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 83af028654..1041652782 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -52,7 +52,7 @@ associations - Excluded nearby background candidates from NIRSpec fixed slit associations for S1600A1 with 5 point dithers, to reduce overlap between background nods and science exposure. [#8744] - + - Added association rule for level 3 image mosaic candidates. [#8798] badpix_selfcal @@ -283,7 +283,7 @@ pipeline optional `on_disk` parameter to govern whether models in the library should be stored in memory or on disk. [#8683] -- Updated ``calwebb_spec2`` to run ``nsclean`` on NIRSpec imprint and background +- Updated ``calwebb_spec2`` to run ``nsclean`` on NIRSpec imprint and background association members. [#8786, #8809] - Updated `calwebb_spec3` to not save the `pixel_replacement` output by default.[#8765] From 5bb0328b42137f29eaba2bd4afc62d599280e28d Mon Sep 17 00:00:00 2001 From: Melanie Clarke Date: Thu, 19 Dec 2024 10:19:16 -0500 Subject: [PATCH 17/22] Fix typo in change note --- changes/8554.assign_wcs.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changes/8554.assign_wcs.rst b/changes/8554.assign_wcs.rst index 1d530a9caa..c36dd9d167 100644 --- a/changes/8554.assign_wcs.rst +++ b/changes/8554.assign_wcs.rst @@ -1,2 +1,2 @@ -Use the range of points in the TabularModel to adjust the bounding_box in a MIRIR LRS FIXEDSLIT observation. +Use the range of points in the TabularModel to adjust the bounding_box in a MIRI LRS FIXEDSLIT observation. Ignore the bounding_box in running the inverse WCS transform when computing crpix. From e3e8ab2079b0eaaf5f234d94e359f30042185b0b Mon Sep 17 00:00:00 2001 From: Melanie Clarke Date: Thu, 19 Dec 2024 10:32:34 -0500 Subject: [PATCH 18/22] Bump minimum numpy to 1.23 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 4351005b34..6d9f5dc60e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,7 +24,7 @@ dependencies = [ "crds>=12.0.3", "drizzle>=2.0.0", "gwcs @ git+https://github.com/spacetelescope/gwcs.git@master", - "numpy>=1.22,<2.0", + "numpy>=1.23,<2.0", "opencv-python-headless>=4.6.0.66", "photutils>=1.5.0", "poppy>=1.0.2", From 28967960e032d1b43b06854da25789ab95371801 Mon Sep 17 00:00:00 2001 From: Melanie Clarke Date: Thu, 19 Dec 2024 11:37:31 -0500 Subject: [PATCH 19/22] Bump minimum numpy to 1.24 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 6d9f5dc60e..b05b96f557 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,7 +24,7 @@ dependencies = [ "crds>=12.0.3", "drizzle>=2.0.0", "gwcs @ git+https://github.com/spacetelescope/gwcs.git@master", - "numpy>=1.23,<2.0", + "numpy>=1.24,<2.0", "opencv-python-headless>=4.6.0.66", "photutils>=1.5.0", "poppy>=1.0.2", From 046a0306ea8cc762b8bd4a702c2bb8dc5368c478 Mon Sep 17 00:00:00 2001 From: Melanie Clarke Date: Thu, 19 Dec 2024 11:43:21 -0500 Subject: [PATCH 20/22] Bump minimum scipy to 1.14.1 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index b05b96f557..84f544d54f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,7 +31,7 @@ dependencies = [ "pyparsing>=2.2.1", "requests>=2.22", "scikit-image>=0.19", - "scipy>=1.9.3", + "scipy>=1.14.1", "spherical-geometry>=1.2.22", "stcal @ git+https://github.com/spacetelescope/stcal.git@main", "stdatamodels @ git+https://github.com/spacetelescope/stdatamodels.git@main", From 5f4367b40c6a51d0729cb0d683c2f7b5aa060dfa Mon Sep 17 00:00:00 2001 From: Melanie Clarke Date: Thu, 19 Dec 2024 12:25:42 -0500 Subject: [PATCH 21/22] Fix for custom wcs test --- jwst/resample/tests/test_resample_step.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/jwst/resample/tests/test_resample_step.py b/jwst/resample/tests/test_resample_step.py index 178340ccb4..c9eb4ec1b5 100644 --- a/jwst/resample/tests/test_resample_step.py +++ b/jwst/resample/tests/test_resample_step.py @@ -831,9 +831,9 @@ def test_resample_undefined_variance(nircam_rate, shape): @pytest.mark.parametrize('ratio', [0.7, 1.2]) @pytest.mark.parametrize('rotation', [0, 15, 135]) -@pytest.mark.parametrize('crpix', [(100, 101), (101, 101)]) -@pytest.mark.parametrize('crval', [(22.01, 12), (22.15, 12.01)]) -@pytest.mark.parametrize('shape', [(10205, 10100)]) +@pytest.mark.parametrize('crpix', [(600, 550), (601, 551)]) +@pytest.mark.parametrize('crval', [(22.04, 11.98), (22.041, 11.981)]) +@pytest.mark.parametrize('shape', [(1205, 1100)]) def test_custom_wcs_resample_imaging(nircam_rate, ratio, rotation, crpix, crval, shape): im = AssignWcsStep.call(nircam_rate, sip_approx=False) im.data += 5 @@ -848,6 +848,9 @@ def test_custom_wcs_resample_imaging(nircam_rate, ratio, rotation, crpix, crval, t = result.meta.wcs.forward_transform + # make sure results are nontrivial + assert not np.all(np.isnan(result.data)) + # test rotation pc = t['pc_rotation_matrix'].matrix.value orientation = np.rad2deg(np.arctan2(pc[0, 1], pc[1, 1])) From a2128165b741736a58fc1f19df1e75bc0372d537 Mon Sep 17 00:00:00 2001 From: Tyler Pauly Date: Thu, 19 Dec 2024 15:46:02 -0500 Subject: [PATCH 22/22] Update gwcs pin after release --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 84f544d54f..2d7907ed2d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,7 +23,7 @@ dependencies = [ "BayesicFitting>=3.0.1", "crds>=12.0.3", "drizzle>=2.0.0", - "gwcs @ git+https://github.com/spacetelescope/gwcs.git@master", + "gwcs>=0.22.0,<0.23.0", "numpy>=1.24,<2.0", "opencv-python-headless>=4.6.0.66", "photutils>=1.5.0",