def test_varclip(): # Confirm rejection of high pixel and correct output DQ data = np.array([1., 1., 2., 2., 2., 100.]).reshape(6, 1) ndd = NDAstroData(data) ndd.mask = np.zeros_like(data, dtype=DQ.datatype) ndd.mask[5, 0] = DQ.saturated ndd.variance = np.ones_like(data) stackit = NDStacker(combine="mean", reject="varclip") result = stackit(ndd) np.testing.assert_array_almost_equal(result.data, [1.6]) np.testing.assert_array_equal(result.mask, [0])
def test_varclip(): # Confirm rejection of high pixel and correct output DQ data = np.array([1., 1., 2., 2., 2., 100.]).reshape(6, 1) ndd = NDAstroData(data) ndd.mask = np.zeros_like(data, dtype=DQ.datatype) ndd.mask[5, 0] = DQ.saturated ndd.variance = np.ones_like(data) stackit = NDStacker(combine="mean", reject="varclip") result = stackit(ndd) assert_allclose(result.data, 1.6) # 100 is rejected assert_allclose(result.mask, 0) data = np.array([1., 1., 2., 2., 2., 100.]).reshape(6, 1) ndd = NDAstroData(data) ndd.variance = np.ones_like(data) ndd.variance[5] = 400 stackit = NDStacker(combine="mean", reject="varclip", lsigma=3, hsigma=3) result = stackit(ndd) assert_allclose(result.data, 1.6) # 100 is rejected stackit = NDStacker(combine="mean", reject="varclip", lsigma=5, hsigma=5) result = stackit(ndd) assert_allclose(result.data, 18) # 100 is not rejected
def test_sum1d(): big_value = 10 data = np.ones((10, )) ndd = NDAstroData(data) ndd.mask = np.zeros_like(data, dtype=DQ.datatype) ndd.mask[1] = 1 ndd.mask[2] = 2 ndd.data[4] = big_value ndd.variance = np.ones_like(data) x1 = -0.5 for x2 in np.arange(0., 4.5, 0.5): result = sum1d(ndd, x1, x2, proportional_variance=True) if x2 > 3.5: np.testing.assert_almost_equal(4 + big_value * (x2 - 3.5), result.data) else: np.testing.assert_almost_equal(x2 - x1, result.data) np.testing.assert_almost_equal(x2 - x1, result.variance) if x2 > 1.5: assert result.mask == 3 elif x2 > 0.5: assert result.mask == 1 else: assert result.mask == 0