def test__padded_3x3_to_4x4__goes_to_5x5_to_keep_symmetry(self): data = np.ones((3, 3)) data[1, 1] = 2.0 data = image.Image(data, pixel_scale=0.1) data = image.pad(data, pixel_dimensions=(4, 4)) assert (data == np.array([[0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 1.0, 1.0, 1.0, 0.0], [0.0, 1.0, 2.0, 1.0, 0.0], [0.0, 1.0, 1.0, 1.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0]])).all() assert data.shape == (5, 5) assert data.central_pixel_coordinates == (2.0, 2.0) assert data.shape_arc_seconds == pytest.approx((0.5, 0.5), 1e-3)
def test__padded_4x4_to_6x6(self): data = np.ones((4, 4)) data[1:3, 1:3] = 2.0 data = image.Image(data, pixel_scale=0.1) data = image.pad(data, pixel_dimensions=(6, 6)) assert (data == np.array([[0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 1.0, 1.0, 1.0, 1.0, 0.0], [0.0, 1.0, 2.0, 2.0, 1.0, 0.0], [0.0, 1.0, 2.0, 2.0, 1.0, 0.0], [0.0, 1.0, 1.0, 1.0, 1.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]])).all() assert data.shape == (6, 6) assert data.central_pixel_coordinates == (2.5, 2.5) assert data.shape_arc_seconds == pytest.approx((0.6, 0.6), 1e-3)
def test__padded_2x3_to_5x6__goes_to_6x7_to_keep_symmetry(self): data = np.ones((2, 3)) data[0:2, 1] = 2.0 data[1, 2] = 9 data = image.Image(data, pixel_scale=0.1) data = image.pad(data, pixel_dimensions=(5, 6)) assert (data == np.array([[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 1.0, 2.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 2.0, 9.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]])).all() assert data.shape == (6, 7) assert data.central_pixel_coordinates == (2.5, 3.0) assert data.shape_arc_seconds == pytest.approx((0.6, 0.7), 1e-3)
def test__padded_4x4_to_7x7__goes_to_8x8_to_keep_symmetry(self): data = np.ones((4, 4)) data[1:3, 1:3] = 2.0 data = image.Image(data, pixel_scale=0.1) data = image.pad(data, pixel_dimensions=(7, 7)) assert (data == np.array([[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 2.0, 2.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 2.0, 2.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]])).all() assert data.shape == (8, 8) assert data.central_pixel_coordinates == (3.5, 3.5) assert data.shape_arc_seconds == pytest.approx((0.8, 0.8), 1e-3)
def test__padded_5x5_to_8x8__goes_to_9x9_to_keep_symmetry(self): data = np.ones((5, 5)) data[2, 2] = 2.0 data = image.Image(data, pixel_scale=0.1) data = image.pad(data, pixel_dimensions=(8, 8)) assert (data == np.array([[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 1.0, 2.0, 1.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]])).all() assert data.shape == (9, 9) assert data.central_pixel_coordinates == (4.0, 4.0) assert data.shape_arc_seconds == pytest.approx((0.9, 0.9), 1e-3)
def test_plain(self): src = array([ [ [0.5], [0.5], ], [ [0.3], [0.4], ], ]) result = image.pad(src, 2, padding_pixel=0.99) expected = array([ [ [0.99], [0.99], [0.99], [0.99], [0.99], [0.99], ], [ [0.99], [0.99], [0.99], [0.99], [0.99], [0.99], ], [ [0.99], [0.99], [0.5], [0.5], [0.99], [0.99], ], [ [0.99], [0.99], [0.3], [0.4], [0.99], [0.99], ], [ [0.99], [0.99], [0.99], [0.99], [0.99], [0.99], ], [ [0.99], [0.99], [0.99], [0.99], [0.99], [0.99], ], ]) self.assertEqual(expected.tolist(), result.tolist())