Beispiel #1
0
def test__operate_lens__sums_individual_quantities():

    grid = al.Grid2D.uniform(shape_native=(50, 50), pixel_scales=0.15)

    sis_0 = al.mp.SphIsothermal(centre=(0.0, 0.0), einstein_radius=0.2)
    sis_1 = al.mp.SphIsothermal(centre=(0.0, 0.0), einstein_radius=0.4)
    sis_2 = al.mp.SphIsothermal(centre=(0.0, 0.0), einstein_radius=0.6)
    sis_3 = al.mp.SphIsothermal(centre=(0.0, 0.0), einstein_radius=0.8)

    galaxy_0 = al.Galaxy(mass_profile_0=sis_0,
                         mass_profile_1=sis_1,
                         redshift=0.5)
    galaxy_1 = al.Galaxy(mass_profile_0=sis_2,
                         mass_profile_1=sis_3,
                         redshift=0.5)

    plane = al.Plane(galaxies=[galaxy_0, galaxy_1])

    tracer = al.Tracer(planes=[plane,
                               al.Plane(redshift=1.0, galaxies=None)],
                       cosmology=cosmo.Planck15)

    einstein_mass = tracer.einstein_mass_angular_from(grid=grid)

    assert einstein_mass == pytest.approx(np.pi * 2.0**2.0, 1.0e-1)
Beispiel #2
0
def test__operate_image__blurred_images_2d_via_convolver_from__for_tracer_gives_list_of_planes(
        sub_grid_2d_7x7, blurring_grid_2d_7x7, convolver_7x7):
    g0 = al.Galaxy(
        redshift=0.5,
        light_profile=al.lp.EllSersic(intensity=1.0),
        mass_profile=al.mp.SphIsothermal(einstein_radius=1.0),
    )
    g1 = al.Galaxy(redshift=1.0, light_profile=al.lp.EllSersic(intensity=2.0))

    plane_0 = al.Plane(redshift=0.5, galaxies=[g0])
    plane_1 = al.Plane(redshift=1.0, galaxies=[g1])

    blurred_image_0 = plane_0.blurred_image_2d_via_convolver_from(
        grid=sub_grid_2d_7x7,
        convolver=convolver_7x7,
        blurring_grid=blurring_grid_2d_7x7,
    )

    source_grid_2d_7x7 = plane_0.traced_grid_from(grid=sub_grid_2d_7x7)
    source_blurring_grid_2d_7x7 = plane_0.traced_grid_from(
        grid=blurring_grid_2d_7x7)

    blurred_image_1 = plane_1.blurred_image_2d_via_convolver_from(
        grid=source_grid_2d_7x7,
        convolver=convolver_7x7,
        blurring_grid=source_blurring_grid_2d_7x7,
    )

    tracer = al.Tracer(planes=[plane_0, plane_1],
                       cosmology=al.cosmo.Planck15())

    blurred_image = tracer.blurred_image_2d_via_convolver_from(
        grid=sub_grid_2d_7x7,
        convolver=convolver_7x7,
        blurring_grid=blurring_grid_2d_7x7,
    )

    assert blurred_image.native == pytest.approx(
        blurred_image_0.native + blurred_image_1.native, 1.0e-4)

    blurred_image_list = tracer.blurred_image_2d_list_via_convolver_from(
        grid=sub_grid_2d_7x7,
        convolver=convolver_7x7,
        blurring_grid=blurring_grid_2d_7x7,
    )

    assert (blurred_image_list[0].slim == blurred_image_0.slim).all()
    assert (blurred_image_list[1].slim == blurred_image_1.slim).all()

    assert (blurred_image_list[0].native == blurred_image_0.native).all()
    assert (blurred_image_list[1].native == blurred_image_1.native).all()
Beispiel #3
0
def test__operate_image__visibilities_of_planes_from_grid_and_transformer(
        sub_grid_2d_7x7, transformer_7x7_7):

    g0 = al.Galaxy(redshift=0.5, light_profile=al.lp.EllSersic(intensity=1.0))
    g1 = al.Galaxy(redshift=1.0, light_profile=al.lp.EllSersic(intensity=2.0))

    plane_0 = al.Plane(redshift=0.5, galaxies=[g0])
    plane_1 = al.Plane(redshift=0.5, galaxies=[g1])
    plane_2 = al.Plane(redshift=1.0, galaxies=[al.Galaxy(redshift=1.0)])

    visibilities_0 = plane_0.visibilities_via_transformer_from(
        grid=sub_grid_2d_7x7, transformer=transformer_7x7_7)

    visibilities_1 = plane_1.visibilities_via_transformer_from(
        grid=sub_grid_2d_7x7, transformer=transformer_7x7_7)

    tracer = al.Tracer(planes=[plane_0, plane_1, plane_2],
                       cosmology=cosmo.Planck15)

    visibilities = tracer.visibilities_list_via_transformer_from(
        grid=sub_grid_2d_7x7, transformer=transformer_7x7_7)

    assert (visibilities[0] == visibilities_0).all()
    assert (visibilities[1] == visibilities_1).all()
lens_galaxy = al.Galaxy(redshift=0.5, mass=mass_profile)

light_profile = al.lp.SphSersic(centre=(0.0, 0.0),
                                intensity=1.0,
                                effective_radius=1.0,
                                sersic_index=1.0)

source_galaxy = al.Galaxy(redshift=1.0, bulge=light_profile)
"""
__Planes__

We now use the `Plane` object to create the image-plane of the schematic above, which uses the lens galaxy above. 
Because this galaxy is at redshift 0.5, this means our image-plane is also at redshift 0.5.
"""
image_plane = al.Plane(galaxies=[lens_galaxy])
"""
Just like profiles and galaxies, a `Plane` has `_from_grid` method which we can use to compute its quantities.
"""
deflections = image_plane.deflections_yx_2d_from(grid=image_plane_grid)

print("deflection-angles of `Plane`'s `Grid2D` pixel 0:")
print(deflections.native[0, 0, 0])
print(deflections.native[0, 0, 0])

print("deflection-angles of `Plane`'s `Grid2D` pixel 1:")
print(deflections.native[0, 1, 1])
print(deflections.native[0, 1, 1])
"""
There is also a `PlanePlotter` which, you guessed it, behaves like the profile and galaxy plotters.
"""
Beispiel #5
0
def make_plane_7x7(gal_x1_lp_x1_mp):
    return al.Plane(galaxies=[gal_x1_lp_x1_mp])