Skip to content

Commit

Permalink
minor fixes to outlier detection tso unit test (#8623)
Browse files Browse the repository at this point in the history
  • Loading branch information
braingram authored Jul 3, 2024
2 parents 2b69c3a + d02ac25 commit c278ed8
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions jwst/outlier_detection/tests/test_outlier_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,18 +346,10 @@ def test_outlier_step_weak_cr_tso(exptype, tsovisit):
im = we_many_sci(
numsci=numsci, background=bkg, sigma=sig, signal=signal, exptype=exptype, tsovisit=tsovisit
)
cube_data = np.array([i.data for i in im])
cube_err = np.array([i.err for i in im])
cube_dq = np.array([i.dq for i in im])
cube_var_noise = np.array([i.var_rnoise for i in im])
cube = datamodels.CubeModel(data=cube_data, err=cube_err, dq=cube_dq, var_noise=cube_var_noise)

# update metadata of cube to match the first image
cube.meta = im[0].meta

# Drop a weak CR on the science array
cr_timestep = 5
cube.data[cr_timestep, 12, 12] = bkg + sig * 10
im[cr_timestep].data[12, 12] = bkg + sig * 10

# make time variability that has larger total amplitude than
# the CR signal but deviations frame-by-frame are smaller
Expand All @@ -366,10 +358,20 @@ def test_outlier_step_weak_cr_tso(exptype, tsovisit):
model.data[7, 7] += real_time_variability[i]
model.err[7, 7] = np.sqrt(sig ** 2 + model.data[7, 7])

cube_data = np.array([i.data for i in im])
cube_err = np.array([i.err for i in im])
cube_dq = np.array([i.dq for i in im])
cube_var_noise = np.array([i.var_rnoise for i in im])
cube = datamodels.CubeModel(data=cube_data, err=cube_err, dq=cube_dq, var_noise=cube_var_noise)

# update metadata of cube to match the first image
cube.meta = im[0].meta

result = OutlierDetectionStep.call(cube, rolling_window_width=rolling_window_width)

# Make sure nothing changed in SCI array
np.testing.assert_allclose(cube.data, result.data)
for i, model in enumerate(im):
np.testing.assert_allclose(model.data, result.data[i])

# Verify source is not flagged
assert np.all(result.dq[:, 7, 7] == datamodels.dqflags.pixel["GOOD"])
Expand Down

0 comments on commit c278ed8

Please sign in to comment.