예제 #1
0
        def test__x2_data_stacks__x2_plane_images(self, grid_stack_0,
                                                  grid_stack_1):
            grid_stack_0.regular[1] = np.array([2.0, 2.0])

            galaxy = g.Galaxy(light=lp.EllipticalSersic(intensity=1.0))

            plane_stack = pl_stack.PlaneStack(
                galaxies=[galaxy],
                grid_stacks=[grid_stack_0, grid_stack_1],
                compute_deflections=False)

            plane_image_from_func = lens_util.plane_image_of_galaxies_from_grid(
                shape=(3, 4), grid=grid_stack_0.regular, galaxies=[galaxy])

            plane_image_from_func_1 = lens_util.plane_image_of_galaxies_from_grid(
                shape=(3, 4), grid=grid_stack_1.regular, galaxies=[galaxy])

            assert (plane_image_from_func == plane_stack.plane_images[0]).all()
            assert (
                plane_image_from_func_1 == plane_stack.plane_images[1]).all()
예제 #2
0
    def test__3x2_grid__shape_change_correct_and_coordinates_shift(self):

        galaxy = g.Galaxy(light=lp.EllipticalSersic(intensity=1.0))

        grid = np.array([[-1.5, -1.5], [1.5, 1.5]])

        plane_image = lens_util.plane_image_of_galaxies_from_grid(
            shape=(3, 2), grid=grid, galaxies=[galaxy], buffer=0.0)

        plane_image_galaxy = galaxy.intensities_from_grid(
            grid=np.array([[-1.0, -0.75], [-1.0, 0.75], [0.0, -0.75],
                           [0.0, 0.75], [1.0, -0.75], [1.0, 0.75]]))

        plane_image_galaxy = mapping_util.map_unmasked_1d_array_to_2d_array_from_array_1d_and_shape(
            array_1d=plane_image_galaxy, shape=(3, 2))

        assert (plane_image == plane_image_galaxy).all()
예제 #3
0
    def test__3x3_grid__extracts_max_min_coordinates__creates_regular_grid_including_half_pixel_offset_from_edge(
            self):

        galaxy = g.Galaxy(light=lp.EllipticalSersic(intensity=1.0))

        grid = np.array([[-1.5, -1.5], [1.5, 1.5]])

        plane_image = lens_util.plane_image_of_galaxies_from_grid(
            shape=(3, 3), grid=grid, galaxies=[galaxy], buffer=0.0)

        plane_image_galaxy = galaxy.intensities_from_grid(grid=np.array(
            [[-1.0, -1.0], [-1.0, 0.0], [-1.0, 1.0], [0.0, -1.0], [0.0, 0.0],
             [0.0, 1.0], [1.0, -1.0], [1.0, 0.0], [1.0, 1.0]]))

        plane_image_galaxy = mapping_util.map_unmasked_1d_array_to_2d_array_from_array_1d_and_shape(
            array_1d=plane_image_galaxy, shape=(3, 3))

        assert (plane_image == plane_image_galaxy).all()
예제 #4
0
    def test__3x3_grid__extracts_max_min_coordinates__ignores_other_coordinates_more_central(
            self):

        galaxy = g.Galaxy(light=lp.EllipticalSersic(intensity=1.0))

        grid = np.array([[-1.5, -1.5], [1.5, 1.5], [0.1, -0.1], [-1.0, 0.6],
                         [1.4, -1.3], [1.5, 1.5]])

        plane_image = lens_util.plane_image_of_galaxies_from_grid(
            shape=(3, 3), grid=grid, galaxies=[galaxy], buffer=0.0)

        plane_image_galaxy = galaxy.intensities_from_grid(grid=np.array(
            [[-1.0, -1.0], [-1.0, 0.0], [-1.0, 1.0], [0.0, -1.0], [0.0, 0.0],
             [0.0, 1.0], [1.0, -1.0], [1.0, 0.0], [1.0, 1.0]]))

        plane_image_galaxy = mapping_util.map_unmasked_1d_array_to_2d_array_from_array_1d_and_shape(
            array_1d=plane_image_galaxy, shape=(3, 3))

        assert (plane_image == plane_image_galaxy).all()
예제 #5
0
    def test__3x3_grid__buffer_aligns_two_grids(self):

        galaxy = g.Galaxy(light=lp.EllipticalSersic(intensity=1.0))

        grid_without_buffer = np.array([[-1.48, -1.48], [1.48, 1.48]])

        plane_image = lens_util.plane_image_of_galaxies_from_grid(
            shape=(3, 3),
            grid=grid_without_buffer,
            galaxies=[galaxy],
            buffer=0.02)

        plane_image_galaxy = galaxy.intensities_from_grid(grid=np.array(
            [[-1.0, -1.0], [-1.0, 0.0], [-1.0, 1.0], [0.0, -1.0], [0.0, 0.0],
             [0.0, 1.0], [1.0, -1.0], [1.0, 0.0], [1.0, 1.0]]))

        plane_image_galaxy = mapping_util.map_unmasked_1d_array_to_2d_array_from_array_1d_and_shape(
            array_1d=plane_image_galaxy, shape=(3, 3))

        assert (plane_image == plane_image_galaxy).all()
예제 #6
0
 def plane_image(self):
     return lens_util.plane_image_of_galaxies_from_grid(shape=self.grid_stack.regular.mask.shape,
                                                         grid=self.grid_stack.regular,
                                                         galaxies=self.galaxies)
예제 #7
0
 def plane_images(self):
     return list(map(lambda grid_stack :
                     lens_util.plane_image_of_galaxies_from_grid(shape=grid_stack.regular.mask.shape,
                                                                  grid=grid_stack.regular, galaxies=self.galaxies),
                     self.grid_stacks))
예제 #8
0
 def plane_image_from_grid(self, grid):
     return lens_util.plane_image_of_galaxies_from_grid(
         shape=grid.mask.shape,
         grid=grid.unlensed_unsubbed_1d,
         galaxies=self.galaxies,
     )