From eb202395c3ca138fe6ed97252c12f67b5261a62f Mon Sep 17 00:00:00 2001 From: Ned Molter Date: Mon, 16 Dec 2024 16:09:36 -0500 Subject: [PATCH] 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",