def test__gal_data_7x7_image(self, gal_data_7x7, sub_mask_2d_7x7): galaxy_fit_data = ag.MaskedGalaxyDataset(galaxy_data=gal_data_7x7, mask=sub_mask_2d_7x7, use_image=True) assert galaxy_fit_data.pixel_scales == (1.0, 1.0) assert (galaxy_fit_data.galaxy_data.image.native == np.ones( (7, 7))).all() assert (galaxy_fit_data.galaxy_data.noise_map.native == 2.0 * np.ones( (7, 7))).all() assert (galaxy_fit_data.image.slim == np.ones(9)).all() assert (galaxy_fit_data.noise_map.slim == 2.0 * np.ones(9)).all() assert (galaxy_fit_data.mask == np.array([ [True, True, True, True, True, True, True], [True, True, True, True, True, True, True], [True, True, False, False, False, True, True], [True, True, False, False, False, True, True], [True, True, False, False, False, True, True], [True, True, True, True, True, True, True], [True, True, True, True, True, True, True], ])).all() assert (galaxy_fit_data.image.native == 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, 1.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 0.0], [0.0, 0.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], ])).all() assert (galaxy_fit_data.noise_map.native == 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, 2.0, 2.0, 2.0, 0.0, 0.0], [0.0, 0.0, 2.0, 2.0, 2.0, 0.0, 0.0], [0.0, 0.0, 2.0, 2.0, 2.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() galaxy = mock.MockGalaxy(value=1, shape=36) image = galaxy_fit_data.profile_quantity_from_galaxies( galaxies=[galaxy]) assert (image.binned == np.ones(9)).all() galaxy = ag.Galaxy(redshift=0.5, light=ag.lp.SphSersic(intensity=1.0)) image_gal = galaxy.image_2d_from_grid(grid=galaxy_fit_data.grid) image_gd = galaxy_fit_data.profile_quantity_from_galaxies( galaxies=[galaxy]) assert (image_gal == image_gd).all()
def test__gal_data_7x7_deflections_x(self, gal_data_7x7, sub_mask_2d_7x7): galaxy_fit_data = ag.MaskedGalaxyDataset(galaxy_data=gal_data_7x7, mask=sub_mask_2d_7x7, use_deflections_x=True) assert galaxy_fit_data.pixel_scales == (1.0, 1.0) assert (galaxy_fit_data.galaxy_data.image.native == np.ones( (7, 7))).all() assert (galaxy_fit_data.galaxy_data.noise_map.native == 2.0 * np.ones( (7, 7))).all() assert (galaxy_fit_data.image.slim == np.ones(9)).all() assert (galaxy_fit_data.noise_map.slim == 2.0 * np.ones(9)).all() assert (galaxy_fit_data.mask == np.array([ [True, True, True, True, True, True, True], [True, True, True, True, True, True, True], [True, True, False, False, False, True, True], [True, True, False, False, False, True, True], [True, True, False, False, False, True, True], [True, True, True, True, True, True, True], [True, True, True, True, True, True, True], ])).all() assert (galaxy_fit_data.image.native == 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, 1.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 0.0], [0.0, 0.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], ])).all() assert (galaxy_fit_data.noise_map.native == 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, 2.0, 2.0, 2.0, 0.0, 0.0], [0.0, 0.0, 2.0, 2.0, 2.0, 0.0, 0.0], [0.0, 0.0, 2.0, 2.0, 2.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() galaxy = mock.MockGalaxy(value=1, shape=36) deflections_x = galaxy_fit_data.profile_quantity_from_galaxies( galaxies=[galaxy]) assert (deflections_x.binned == np.ones(9)).all() galaxy = ag.Galaxy(redshift=0.5, mass=ag.mp.SphIsothermal(einstein_radius=1.0)) deflections_gal = galaxy.deflections_2d_from_grid( grid=galaxy_fit_data.grid) deflections_gal = np.asarray([ np.multiply( deflections_gal.mask.sub_fraction, deflections_gal[:, 0].reshape( -1, deflections_gal.mask.sub_length).sum(axis=1), ), np.multiply( deflections_gal.mask.sub_fraction, deflections_gal[:, 1].reshape( -1, deflections_gal.mask.sub_length).sum(axis=1), ), ]).T deflections_gd = galaxy_fit_data.profile_quantity_from_galaxies( galaxies=[galaxy]) assert (deflections_gal[:, 1] == deflections_gd.binned).all()
def test__gal_data_7x7_potential(self, gal_data_7x7, sub_mask_2d_7x7): galaxy_fit_data = ag.MaskedGalaxyDataset(galaxy_data=gal_data_7x7, mask=sub_mask_2d_7x7, use_potential=True) assert galaxy_fit_data.pixel_scales == (1.0, 1.0) assert (galaxy_fit_data.galaxy_data.image.native == np.ones( (7, 7))).all() assert (galaxy_fit_data.galaxy_data.noise_map.native == 2.0 * np.ones( (7, 7))).all() assert (galaxy_fit_data.image.slim == np.ones(9)).all() assert (galaxy_fit_data.noise_map.slim == 2.0 * np.ones(9)).all() assert (galaxy_fit_data.mask == np.array([ [True, True, True, True, True, True, True], [True, True, True, True, True, True, True], [True, True, False, False, False, True, True], [True, True, False, False, False, True, True], [True, True, False, False, False, True, True], [True, True, True, True, True, True, True], [True, True, True, True, True, True, True], ])).all() assert (galaxy_fit_data.image.native == 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, 1.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 0.0], [0.0, 0.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], ])).all() assert (galaxy_fit_data.noise_map.native == 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, 2.0, 2.0, 2.0, 0.0, 0.0], [0.0, 0.0, 2.0, 2.0, 2.0, 0.0, 0.0], [0.0, 0.0, 2.0, 2.0, 2.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() galaxy = mock.MockGalaxy(value=1, shape=36) potential = galaxy_fit_data.profile_quantity_from_galaxies( galaxies=[galaxy]) assert (potential.binned == np.ones(9)).all() galaxy = ag.Galaxy(redshift=0.5, mass=ag.mp.SphIsothermal(einstein_radius=1.0)) potential_gal = galaxy.potential_2d_from_grid( grid=galaxy_fit_data.grid) potential_gd = galaxy_fit_data.profile_quantity_from_galaxies( galaxies=[galaxy]) assert (potential_gal == potential_gd).all()