def test_image_reduction(): """ Test image reduction when the following parameters are used: roi = (3, 3, 5, 5) and bad_pixels = [(0, 1), (4, 4), (7, 8)]; roi = (0, 0, 20, 20); bad_pixels = [(1, -1), (-1, 1)]. """ # generate simulation image data img = np.arange(100).reshape(10, 10) # set up roi and bad_pixels roi_0 = (3, 3, 5, 5) roi_1 = (0, 0, 20, 20) bad_pixels_0 = [(0, 1), (4, 4), (7, 8)] bad_pixels_1 = [(1, -1), (-1, 1)] # Expected results xsum = [265, 226, 275, 280, 285] ysum = [175, 181, 275, 325, 375] xsum_bp = [450, 369, 470, 480, 490, 500, 510, 520, 530, 521] ysum_bp = [45, 126, 245, 345, 445, 545, 645, 745, 845, 854] xsum_roi = [450, 460, 470, 480, 490, 500, 510, 520, 530, 540] ysum_roi = [45, 145, 245, 345, 445, 545, 645, 745, 845, 945] # call image reduction xline, yline = dpc.image_reduction(img, roi_0, bad_pixels_0) xline_bp, yline_bp = dpc.image_reduction(img, bad_pixels=bad_pixels_1) xline_roi, yline_roi = dpc.image_reduction(img, roi=roi_1) assert_array_equal(xline, xsum) assert_array_equal(yline, ysum) assert_array_equal(xline_bp, xsum_bp) assert_array_equal(yline_bp, ysum_bp) assert_array_equal(xline_roi, xsum_roi) assert_array_equal(yline_roi, ysum_roi)
def test_image_reduction_default(): """ Test image reduction when default parameters (roi and bad_pixels) are used. """ # Generate simulation image data img = np.arange(100).reshape(10, 10) # Expected results xsum = [450, 460, 470, 480, 490, 500, 510, 520, 530, 540] ysum = [45, 145, 245, 345, 445, 545, 645, 745, 845, 945] # call image reduction xline, yline = dpc.image_reduction(img) assert_array_equal(xline, xsum) assert_array_equal(yline, ysum)