How to use the autolens.analysis.galaxy.Galaxy function in autolens

To help you get started, we’ve selected a few autolens examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Jammy2211 / PyAutoLens / test / analysis / test_ray_tracing.py View on Github external
def test__x1_galaxy_light_no_mass_in_each_plane__image_of_each_plane_is_galaxy_image(self, grids):

            sersic = lp.EllipticalSersicLP(axis_ratio=0.5, phi=0.0, intensity=1.0, effective_radius=0.6,
                                                       sersic_index=4.0)

            g0 = g.Galaxy(redshift=0.1, light_profile=sersic)
            g1 = g.Galaxy(redshift=1.0, light_profile=sersic)
            g2 = g.Galaxy(redshift=2.0, light_profile=sersic)

            tracer = ray_tracing.TracerMulti(galaxies=[g0, g1, g2], image_grids=grids, cosmology=cosmo.Planck15)

            plane_0 = ray_tracing.Plane(galaxies=[g0], grids=grids, compute_deflections=True)
            plane_1 = ray_tracing.Plane(galaxies=[g1], grids=grids, compute_deflections=True)
            plane_2 = ray_tracing.Plane(galaxies=[g2], grids=grids, compute_deflections=False)

            image_plane_blurring_image = plane_0.image_plane_blurring_image + plane_1.image_plane_blurring_image + \
                                         plane_2.image_plane_blurring_image

            assert (image_plane_blurring_image == tracer.image_plane_blurring_image).all()
            assert (tracer.image_plane_blurring_images_of_planes[0] == plane_0.image_plane_blurring_image).all()
            assert (tracer.image_plane_blurring_images_of_planes[1] == plane_1.image_plane_blurring_image).all()
            assert (tracer.image_plane_blurring_images_of_planes[2] == plane_2.image_plane_blurring_image).all()
github Jammy2211 / PyAutoLens / test / analysis / test_ray_tracing.py View on Github external
def test_all_with_hyper_galaxies_tracer(self, grids):
        tracer = ray_tracing.TracerImageSourcePlanes([galaxy.Galaxy(hyper_galaxy=galaxy.HyperGalaxy())],
                                              [galaxy.Galaxy(hyper_galaxy=galaxy.HyperGalaxy())],
                                              grids)

        assert tracer.all_with_hyper_galaxies

        tracer = ray_tracing.TracerImageSourcePlanes([galaxy.Galaxy(hyper_galaxy=galaxy.HyperGalaxy())],
                                              [galaxy.Galaxy()],
                                              grids)

        assert not tracer.all_with_hyper_galaxies
github Jammy2211 / PyAutoLens / test / analysis / test_ray_tracing.py View on Github external
def test__4_planes__coordinate_grids_and_deflections_are_correct__sis_mass_profile(self, grids):
            import math

            g0 = galaxy.Galaxy(redshift=2.0, mass_profile=mass_profiles.SphericalIsothermalMP(einstein_radius=1.0))
            g1 = galaxy.Galaxy(redshift=2.0, mass_profile=mass_profiles.SphericalIsothermalMP(einstein_radius=1.0))
            g2 = galaxy.Galaxy(redshift=0.1, mass_profile=mass_profiles.SphericalIsothermalMP(einstein_radius=1.0))
            g3 = galaxy.Galaxy(redshift=3.0, mass_profile=mass_profiles.SphericalIsothermalMP(einstein_radius=1.0))
            g4 = galaxy.Galaxy(redshift=1.0, mass_profile=mass_profiles.SphericalIsothermalMP(einstein_radius=1.0))
            g5 = galaxy.Galaxy(redshift=3.0, mass_profile=mass_profiles.SphericalIsothermalMP(einstein_radius=1.0))

            tracer = ray_tracing.TracerMulti(galaxies=[g0, g1, g2, g3, g4, g5],
                                             image_grids=grids, cosmology=cosmo.Planck15)

            # From unit test below:
            # Beta_01 = 0.9348
            # Beta_02 = 0.9840
            # Beta_03 = 1.0
            # Beta_12 = 0.754
            # Beta_13 = 1.0
            # Beta_23 = 1.0

            val = math.sqrt(2) / 2.0

            assert tracer.planes[0].grids.image[0] == pytest.approx(np.array([1.0, 1.0]), 1e-4)
github Jammy2211 / PyAutoLens / test / analysis / test_ray_tracing.py View on Github external
def test__same_as_above_but_multiple_galaxies_in_a_plane(self, grids):

            g0 = galaxy.Galaxy(light_profile=light_profiles.EllipticalSersicLP(intensity=1.0),
                               mass_profile=mass_profiles.SphericalIsothermalMP(einstein_radius=1.0))

            g1 = galaxy.Galaxy(light_profile=light_profiles.EllipticalSersicLP(intensity=2.0))
            g2 = galaxy.Galaxy(light_profile=light_profiles.EllipticalSersicLP(intensity=3.0))
            g3 = galaxy.Galaxy(light_profile=light_profiles.EllipticalSersicLP(intensity=4.0))

            g0_image = g0.intensity_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]]))

            g1_image = g1.intensity_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]]))

            grids.image = np.array([[-1.5, -1.5], [1.5, 1.5]])

            tracer = ray_tracing.TracerImageSourcePlanes(lens_galaxies=[g0, g1], source_galaxies=[g2, g3],
                                                         image_grids=grids)

            g2_image_grid = ray_tracing.uniform_grid_from_lensed_grid(tracer.source_plane.grids.image, shape=(3,3))
github Jammy2211 / PyAutoLens / test / analysis / test_ray_tracing.py View on Github external
def test__same_as_above_but_multiple_sets_of_positions(self):

            import math

            g0 = galaxy.Galaxy(redshift=2.0, mass_profile=mass_profiles.SphericalIsothermalMP(einstein_radius=1.0))
            g1 = galaxy.Galaxy(redshift=2.0, mass_profile=mass_profiles.SphericalIsothermalMP(einstein_radius=1.0))
            g2 = galaxy.Galaxy(redshift=0.1, mass_profile=mass_profiles.SphericalIsothermalMP(einstein_radius=1.0))
            g3 = galaxy.Galaxy(redshift=3.0, mass_profile=mass_profiles.SphericalIsothermalMP(einstein_radius=1.0))
            g4 = galaxy.Galaxy(redshift=1.0, mass_profile=mass_profiles.SphericalIsothermalMP(einstein_radius=1.0))
            g5 = galaxy.Galaxy(redshift=3.0, mass_profile=mass_profiles.SphericalIsothermalMP(einstein_radius=1.0))

            tracer = ray_tracing.TracerMultiPositions(galaxies=[g0, g1, g2, g3, g4, g5],
                                                      positions=[np.array([[1.0, 1.0]]), np.array([[1.0, 1.0]])],
                                             cosmology=cosmo.Planck15)

            # From unit test below:
            # Beta_01 = 0.9348
            # Beta_02 = 0.9840
            # Beta_03 = 1.0
            # Beta_12 = 0.754
            # Beta_13 = 1.0
            # Beta_23 = 1.0

            val = math.sqrt(2) / 2.0

            assert tracer.planes[0].positions[0] == pytest.approx(np.array([[1.0, 1.0]]), 1e-4)
github Jammy2211 / PyAutoLens / test / analysis / test_ray_tracing.py View on Github external
def test__same_as_above_but_multiple_galaxies_in_a_plane(self, grids):

            g0 = g.Galaxy(light_profile=lp.EllipticalSersicLP(intensity=1.0),
                               mass_profile=mp.SphericalIsothermalMP(einstein_radius=1.0))

            g1 = g.Galaxy(light_profile=lp.EllipticalSersicLP(intensity=2.0))
            g2 = g.Galaxy(light_profile=lp.EllipticalSersicLP(intensity=3.0))
            g3 = g.Galaxy(light_profile=lp.EllipticalSersicLP(intensity=4.0))

            g0_image = g0.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]]))

            g1_image = g1.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]]))

            grids.image = np.array([[-1.5, -1.5], [1.5, 1.5]])

            tracer = ray_tracing.TracerImageSourcePlanes(lens_galaxies=[g0, g1], source_galaxies=[g2, g3],
                                                         image_grids=grids)

            g2_image_grid = ray_tracing.uniform_grid_from_lensed_grid(tracer.source_plane.grids.image, shape=(3,3))
github Jammy2211 / PyAutoLens / test / analysis / test_ray_tracing.py View on Github external
def test__6_galaxies_producing_4_planes(self, grids):
            g0 = galaxy.Galaxy(redshift=1.0)
            g1 = galaxy.Galaxy(redshift=1.0)
            g2 = galaxy.Galaxy(redshift=0.1)
            g3 = galaxy.Galaxy(redshift=1.05)
            g4 = galaxy.Galaxy(redshift=0.95)
            g5 = galaxy.Galaxy(redshift=1.05)

            tracer = ray_tracing.TracerMulti(galaxies=[g0, g1, g2, g3, g4, g5],
                                             image_grids=grids, cosmology=cosmo.Planck15)

            assert tracer.galaxies_redshift_order[0].redshift == 0.1
            assert tracer.galaxies_redshift_order[1].redshift == 0.95
            assert tracer.galaxies_redshift_order[2].redshift == 1.0
            assert tracer.galaxies_redshift_order[3].redshift == 1.0
            assert tracer.galaxies_redshift_order[4].redshift == 1.05
            assert tracer.galaxies_redshift_order[5].redshift == 1.05

            assert tracer.planes_redshift_order[0] == 0.1
github Jammy2211 / PyAutoLens / test / analysis / test_ray_tracing.py View on Github external
def test__has_hyper_galaxy_with_pixelization(self, grids):

        gal = galaxy.Galaxy()
        gal_lp = galaxy.Galaxy(light_profile=light_profiles.LightProfile())
        gal_hyper = galaxy.Galaxy(hyper_galaxy=galaxy.HyperGalaxy())

        assert ray_tracing.TracerImageSourcePlanes([gal], [gal], grids).has_hyper_galaxy == False
        assert ray_tracing.TracerImageSourcePlanes([gal_lp], [gal_lp], grids).has_hyper_galaxy == False
        assert ray_tracing.TracerImageSourcePlanes([gal_hyper], [gal_hyper], grids).has_hyper_galaxy == True
        assert ray_tracing.TracerImageSourcePlanes([gal_hyper], [gal], grids).has_hyper_galaxy == True
        assert ray_tracing.TracerImageSourcePlanes([gal_hyper], [gal_lp], grids).has_hyper_galaxy == True
github Jammy2211 / PyAutoLens / test / analysis / test_ray_tracing.py View on Github external
def make_galaxy_mass_sis():
    sis = mass_profiles.SphericalIsothermalMP(einstein_radius=1.0)
    return galaxy.Galaxy(mass_profile=sis)
github Jammy2211 / PyAutoLens / paper_plots / density_plot_tools.py View on Github external
phi=values[6], intensity=values[2],
                                                          effective_radius=values[3],
                                                          sersic_index=values[4],
                                                          mass_to_light_ratio=values[12 + self.center_skip])

        exponential_halo = mass_profiles.EllipticalExponentialMass(axis_ratio=values[9 + self.center_skip],
                                                                   phi=values[10 + self.center_skip],
                                                                   intensity=values[7 + self.center_skip],
                                                                   effective_radius=values[8 + self.center_skip],
                                                                   mass_to_light_ratio=values[
                                                                    12 + self.ltm_skip + self.center_skip])

        dark_matter_halo = mass_profiles.SphericalNFW(kappa_s=values[11 + self.center_skip],
                                                      scale_radius=30.0*self.arcsec_per_kpc)

        self.lens_galaxy = galaxy.Galaxy(redshift=self.redshift,
                                         mass_profiles=[sersic_bulge, exponential_halo, dark_matter_halo])

        self.source_galaxy = galaxy.Galaxy(redshift=self.source_redshift)