def test__array_3x2__different_origin(self): grid_2d = grid_util.regular_grid_2d_from_shape_pixel_scales_and_origin(shape=(3, 2), pixel_scales=(1.0, 1.0), origin=(3.0, -2.0)) assert (grid_2d == np.array([[[4., -2.5], [4., -1.5]], [[3., -2.5], [3., -1.5]], [[2., -2.5], [2., -1.5]]])).all()
def test__array_3x3__sets_up_arcsecond_grid(self): grid_2d = grid_util.regular_grid_2d_from_shape_pixel_scales_and_origin(shape=(3, 3), pixel_scales=(2.0, 1.0)) assert (grid_2d == np.array([[[2., -1.], [2., 0.], [2., 1.]], [[0., -1.], [0., 0.], [0., 1.]], [[-2., -1.], [-2., 0.], [-2., 1.]]])).all()
def test__array_3x3___input_origin__shifts_grid_by_origin(self): grid_2d = grid_util.regular_grid_2d_from_shape_pixel_scales_and_origin(shape=(3, 3), pixel_scales=(2.0, 1.0), origin=(1.0, 1.0)) assert (grid_2d == np.array([[[3., 0.], [3., 1.], [3., 2.]], [[1., 0.], [1., 1.], [1., 2.]], [[-1., 0.], [-1., 1.], [-1., 2.]]])).all()
def test__array_4x4_and_different_pixel_scale__sets_up_arcsecond_grid(self): grid_2d = grid_util.regular_grid_2d_from_shape_pixel_scales_and_origin(shape=(4, 4), pixel_scales=(0.5, 0.5)) assert (grid_2d == np.array([[[0.75, -0.75], [0.75, -0.25], [0.75, 0.25], [0.75, 0.75]], [[0.25, -0.75], [0.25, -0.25], [0.25, 0.25], [0.25, 0.75]], [[-0.25, -0.75], [-0.25, -0.25], [-0.25, 0.25], [-0.25, 0.75]], [[-0.75, -0.75], [-0.75, -0.25], [-0.75, 0.25], [-0.75, 0.75]]])).all()
def grid_2d(self): """ The arc second-grid of (y,x) coordinates of every pixel. This is defined from the top-left corner, such that the first pixel at location [0, 0] will have a negative x \ value y value in arc seconds. """ return grid_util.regular_grid_2d_from_shape_pixel_scales_and_origin(shape=self.shape, pixel_scales=self.pixel_scales, origin=self.origin)
def test__array_3x2__sets_up_arcsecond_grid(self): grid_2d = grid_util.regular_grid_2d_from_shape_pixel_scales_and_origin(shape=(3, 2), pixel_scales=(1.0, 1.0)) assert (grid_2d == np.array([[[1., -0.5], [1., 0.5]], [[0., -0.5], [0., 0.5]], [[-1., -0.5], [-1., 0.5]]])).all()