Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed outlier test failures #1

Merged
merged 1 commit into from
Dec 16, 2024
Merged
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
48 changes: 30 additions & 18 deletions jwst/outlier_detection/tests/test_outlier_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Copy link
Owner

Choose a reason for hiding this comment

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

These can't be zero. They need to be populated with the values from the SIAF

sci1.meta.wcsinfo.v3yangle = 0
sci1.meta.wcsinfo.vparity = -1
sci1.meta.wcsinfo.pc1_1 = 1
Expand All @@ -148,23 +146,37 @@ 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
sci1.data[7, 7] += signal
# 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]
Expand Down Expand Up @@ -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):
Expand Down
2 changes: 0 additions & 2 deletions jwst/resample/resample_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading