def test_outlier_step_image_weak_CR_nodither(exptype, tsovisit): """Test whole step with an outlier for TSO & coronagraphic modes""" bkg = 1.5 sig = 0.02 container = datamodels.ModelContainer( we_many_sci(background=bkg, sigma=sig, signal=7.0, exptype=exptype, tsovisit=tsovisit)) # Drop a weak CR on the science array # no noise so it should always be above the default threshold of 5 container[0].data[12, 12] = bkg + sig * 10 result = OutlierDetectionStep.call(container) # Make sure nothing changed in SCI array for image, corrected in zip(container, result): np.testing.assert_allclose(image.data, corrected.data) # Verify source is not flagged for r in result: assert r.dq[7, 7] == datamodels.dqflags.pixel["GOOD"] # Verify CR is flagged assert result[0].dq[12, 12] == OUTLIER_DO_NOT_USE
def test_outlier_step_no_outliers(we_three_sci): """Test whole step, no outliers""" container = datamodels.ModelContainer(list(we_three_sci)) pristine = container.copy() result = OutlierDetectionStep.call(container) # Make sure nothing changed in SCI and DQ arrays for image, uncorrected in zip(pristine, container): np.testing.assert_allclose(image.data, uncorrected.data) np.testing.assert_allclose(image.dq, uncorrected.dq) # Make sure nothing changed in SCI and DQ arrays for image, corrected in zip(container, result): np.testing.assert_allclose(image.data, corrected.data) np.testing.assert_allclose(image.dq, corrected.dq)
def test_outlier_step(we_three_sci): """Test whole step with an outlier""" container = datamodels.ModelContainer(list(we_three_sci)) # Drop a CR on the science array container[0].data[12, 12] += 1e3 result = OutlierDetectionStep.call(container) # Make sure nothing changed in SCI array for image, corrected in zip(container, result): np.testing.assert_allclose(image.data, corrected.data) # Verify source is not flagged for r in result: assert r.dq[7, 7] == datamodels.dqflags.pixel["GOOD"] # Verify CR is flagged assert result[0].dq[12, 12] == OUTLIER_DO_NOT_USE
def test_outlier_step_square_source_no_outliers(we_three_sci): """Test whole step with square source with sharp edges, no outliers""" container = datamodels.ModelContainer(list(we_three_sci)) # put a square source in all three exposures for ccont in container: ccont.data[5:15, 5:15] += 1e3 pristine = container.copy() result = OutlierDetectionStep.call(container) # Make sure nothing changed in SCI and DQ arrays for image, uncorrected in zip(pristine, container): np.testing.assert_allclose(image.data, uncorrected.data) np.testing.assert_allclose(image.dq, uncorrected.dq) # Make sure nothing changed in SCI and DQ arrays for image, corrected in zip(container, result): np.testing.assert_allclose(image.data, corrected.data) np.testing.assert_allclose(image.dq, corrected.dq)