How to use the autolens.model.galaxy.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 / lens / plotters / test_sensitivity_fit_plotters.py View on Github external
def make_fit(lens_data):
    lens_galaxy = g.Galaxy(mass=mp.SphericalIsothermal(einstein_radius=1.0), redshift=1.0)
    lens_subhalo = g.Galaxy(mass=mp.SphericalIsothermal(einstein_radius=0.1), redshift=1.0)
    source_galaxy = g.Galaxy(light=lp.EllipticalSersic(intensity=1.0), redshift=2.0)

    tracer_normal = ray_tracing.TracerImageSourcePlanes(lens_galaxies=[lens_galaxy], source_galaxies=[source_galaxy],
                                                        image_plane_grid_stack=lens_data.grid_stack,
                                                        cosmology=cosmo.Planck15)
    tracer_sensitivity = ray_tracing.TracerImageSourcePlanes(lens_galaxies=[lens_galaxy, lens_subhalo],
                                                             source_galaxies=[source_galaxy],
                                                             image_plane_grid_stack=lens_data.grid_stack,
                                                             cosmology=cosmo.Planck15)
    return sensitivity_fit.SensitivityProfileFit(lens_data=lens_data, tracer_normal=tracer_normal,
                                                 tracer_sensitive=tracer_sensitivity)
github Jammy2211 / PyAutoLens / test / unit / lens / test_plane.py View on Github external
def test__within_circle_different_luminosity_units__same_as_galaxy_luminosities(
            self
        ):
            g0 = g.Galaxy(redshift=0.5, luminosity=lp.SphericalSersic(intensity=1.0))
            g1 = g.Galaxy(redshift=0.5, luminosity=lp.SphericalSersic(intensity=2.0))

            radius = dim.Length(1.0, "arcsec")

            g0_luminosity = g0.luminosity_within_circle_in_units(
                radius=radius, unit_luminosity="eps"
            )
            g1_luminosity = g1.luminosity_within_circle_in_units(
                radius=radius, unit_luminosity="eps"
            )
            plane = pl.Plane(galaxies=[g0, g1], redshift=0.5)
            plane_luminosities = plane.luminosities_of_galaxies_within_circles_in_units(
                radius=radius, unit_luminosity="eps"
            )

            assert plane_luminosities[0] == g0_luminosity
            assert plane_luminosities[1] == g1_luminosity
github Jammy2211 / PyAutoLens / test / unit / lens / test_ray_tracing.py View on Github external
def test__2_planes__z01_and_z1(self):
        g0 = g.Galaxy(redshift=0.1)
        g1 = g.Galaxy(redshift=1.0)

        tracer = ray_tracing.Tracer.from_galaxies(galaxies=[g0, g1])

        assert tracer.cosmology == cosmo.Planck15

        assert tracer.image_plane.arcsec_per_kpc == pytest.approx(0.525060, 1e-5)
        assert tracer.image_plane.kpc_per_arcsec == pytest.approx(1.904544, 1e-5)
        assert tracer.image_plane.angular_diameter_distance_to_earth_in_units(
            unit_length="kpc"
        ) == pytest.approx(392840, 1e-5)

        assert tracer.source_plane.arcsec_per_kpc == pytest.approx(0.1214785, 1e-5)
        assert tracer.source_plane.kpc_per_arcsec == pytest.approx(8.231907, 1e-5)
        assert tracer.source_plane.angular_diameter_distance_to_earth_in_units(
            unit_length="kpc"
github Jammy2211 / PyAutoLens / test / unit / lens / test_ray_tracing.py View on Github external
def test__4_planes_after_slicing(self, sub_grid_7x7):

            lens_g0 = g.Galaxy(redshift=0.5)
            source_g0 = g.Galaxy(redshift=2.0)
            los_g0 = g.Galaxy(redshift=1.0)

            tracer = ray_tracing.Tracer.sliced_tracer_from_lens_line_of_sight_and_source_galaxies(
                lens_galaxies=[lens_g0],
                line_of_sight_galaxies=[los_g0],
                source_galaxies=[source_g0],
                planes_between_lenses=[1, 1],
                cosmology=cosmo.Planck15,
            )

            assert (
                tracer.arcsec_per_kpc_proper_of_plane(i=0)
                == tracer.cosmology.arcsec_per_kpc_proper(z=0.25).value
            )
            assert (
github Jammy2211 / PyAutoLens / test / lens / test_ray_tracing.py View on Github external
def test__has_galaxy_with_pixelization(self, grid_stack):
            gal = g.Galaxy()
            gal_lp = g.Galaxy(light_profile=lp.LightProfile())
            gal_pix = g.Galaxy(pixelization=pixelizations.Pixelization(), regularization=regularization.Constant())

            assert ray_tracing.TracerImageSourcePlanes \
                       ([gal], [gal], image_plane_grid_stack=grid_stack).has_pixelization == False
            assert ray_tracing.TracerImageSourcePlanes \
                       ([gal_lp], [gal_lp], image_plane_grid_stack=grid_stack).has_pixelization == False
            assert ray_tracing.TracerImageSourcePlanes \
                       ([gal_pix], [gal_pix], image_plane_grid_stack=grid_stack).has_pixelization == True
            assert ray_tracing.TracerImageSourcePlanes \
                       ([gal_pix], [gal], image_plane_grid_stack=grid_stack).has_pixelization == True
            assert ray_tracing.TracerImageSourcePlanes \
                       ([gal_pix], [gal_lp], image_plane_grid_stack=grid_stack).has_pixelization == True
github Jammy2211 / PyAutoLens / test / lens / util / test_lens_util.py View on Github external
def test__6_galaxies_producing_4_planes(self):
        g0 = g.Galaxy(redshift=1.0)
        g1 = g.Galaxy(redshift=1.0)
        g2 = g.Galaxy(redshift=0.1)
        g3 = g.Galaxy(redshift=1.05)
        g4 = g.Galaxy(redshift=0.95)
        g5 = g.Galaxy(redshift=1.05)

        galaxies = [g0, g1, g2, g3, g4, g5]

        ordered_plane_redshifts = lens_util.ordered_plane_redshifts_from_galaxies(galaxies=galaxies)

        assert ordered_plane_redshifts == [0.1, 0.95, 1.0, 1.05]

        ordered_galaxies = lens_util.galaxies_in_redshift_ordered_planes_from_galaxies(galaxies=galaxies,
                                                                                              plane_redshifts=ordered_plane_redshifts)

        assert ordered_galaxies[0][0].redshift == 0.1
        assert ordered_galaxies[1][0].redshift == 0.95
github Jammy2211 / PyAutoLens / test / autofit / test_model_mapper.py View on Github external
def test_instances_from_list(self):
        instance = model_mapper.ModelInstance()
        galaxy_1 = g.Galaxy()
        galaxy_2 = g.Galaxy()
        instance.galaxies = [galaxy_1, galaxy_2]
        assert instance.instances_of(g.Galaxy) == [galaxy_1, galaxy_2]
github Jammy2211 / PyAutoLens / workspace / howtolens / chapter_2_lens_modeling / scripts / tutorial_3_realism_and_complexity.py View on Github external
def simulate():

    from autolens.data.array import grids
    from autolens.model.galaxy import galaxy as g
    from autolens.lens import ray_tracing

    psf = ccd.PSF.simulate_as_gaussian(shape=(11, 11), sigma=0.05, pixel_scale=0.05)
    image_plane_grid_stack = grids.GridStack.grid_stack_for_simulation(shape=(130, 130), pixel_scale=0.1, psf_shape=(11, 11))

    lens_galaxy = g.Galaxy(light=lp.EllipticalSersic(centre=(0.0, 0.0), axis_ratio=0.9, phi=45.0, intensity=0.04,
                                                             effective_radius=0.5, sersic_index=3.5),
                           mass=mp.EllipticalIsothermal(centre=(0.0, 0.0), axis_ratio=0.8, phi=45.0, einstein_radius=0.8))

    source_galaxy = g.Galaxy(light=lp.EllipticalSersic(centre=(0.0, 0.0), axis_ratio=0.5, phi=90.0, intensity=0.03,
                                                       effective_radius=0.3, sersic_index=3.0))
    tracer = ray_tracing.TracerImageSourcePlanes(lens_galaxies=[lens_galaxy], source_galaxies=[source_galaxy],
                                                 image_plane_grid_stack=image_plane_grid_stack)

    ccd_simulated = ccd.CCDData.simulate(array=tracer.image_plane_image_for_simulation, pixel_scale=0.1,
                                                   exposure_time=300.0, psf=psf, background_sky_level=0.1, add_noise=True)

    return ccd_simulated
github Jammy2211 / PyAutoLens / workspace / howtolens / chapter_4_inversions / scripts / tutorial_5_borders.py View on Github external
def simulate_image_x2_lenses():

    from autolens.data.array import grids
    from autolens.model.galaxy import galaxy as g
    from autolens.lens import ray_tracing

    psf = ccd.PSF.simulate_as_gaussian(shape=(11, 11), sigma=0.05, pixel_scale=0.05)

    image_plane_grid_stack = grids.GridStack.grid_stack_for_simulation(shape=(300, 300), pixel_scale=0.05, psf_shape=(11, 11))

    lens_galaxy_0 = g.Galaxy(
        mass=mp.EllipticalIsothermal(centre=(1.1, 0.51), axis_ratio=0.9, phi=110.0, einstein_radius=1.07))
    lens_galaxy_1 = g.Galaxy(
        mass=mp.EllipticalIsothermal(centre=(-0.20, -0.35), axis_ratio=0.56, phi=16.0, einstein_radius=0.71))
    source_galaxy_0 = g.Galaxy(light=lp.EllipticalSersic(centre=(0.05, 0.05), axis_ratio=0.8, phi=90.0, intensity=0.2,
                                                         effective_radius=0.3, sersic_index=1.0))

    tracer = ray_tracing.TracerImageSourcePlanes(lens_galaxies=[lens_galaxy_0, lens_galaxy_1],
                                                 source_galaxies=[source_galaxy_0],
                                                 image_plane_grid_stack=image_plane_grid_stack)

    return ccd.CCDData.simulate(array=tracer.image_plane_image_for_simulation, pixel_scale=0.05,
                                exposure_time=300.0, psf=psf, background_sky_level=0.1, add_noise=True)