Skip to content

Bug with ShapeSolver for Voronoi calculation #308

Open
@Jammy2211

Description

@Jammy2211

I have applied the ShapeSolver to try and make a plot of the source-plane magnification in each Voronoi cell of a model-fit to a strong lens.

However, the Voronoi mesh magnification values are incorrect:

image

In the example above, magnification values of ~137 are inferred in random Voronoi source pixels quite far from the caustic. These values are too high to be realistic for a strong lens model, especially away from the caustic.

The visual above used the following:

        grid = al.Grid2D.uniform(shape_native=(200, 200), pixel_scales=0.05)

        solver = al.ShapeSolver.for_grid(
            grid=grid,
            pixel_scale_precision=0.01,
            magnification_threshold=0.1,
        )

If I set pixel_scale_precision=0.005 the magnification values all systematically increase, making the problem worse:

Here is a standalone Python script which computes 5 magnification values for this lens model and Voronoi cell polygons:

import numpy as np

import autolens as al

mass = al.mp.Isothermal(
    centre=(0.026218843845009623, 0.02611815950163722),
    ell_comps=(0.02105271436162344, 0.014167142297629842),
    einstein_radius=0.7697173280416433
)

shear = al.mp.ExternalShear(
    gamma_1=0.03795542854165093, gamma_2=0.014667731434215667
)

lens = al.Galaxy(redshift=0.5, mass=mass, shear=shear)

source = al.Galaxy(redshift=1.0, light=al.lp.Sersic())

tracer = al.Tracer(galaxies=[lens, source])


grid = al.Grid2D.uniform(shape_native=(200, 200), pixel_scales=0.05)

solver = al.ShapeSolver.for_grid(
    grid=grid,
    pixel_scale_precision=0.01,
    magnification_threshold=0.1,
)


vert_list = [
   [[0.08015572, 0.00981762], [0.0790642, 0.00873  ], [0.07706938, 0.00865381], [0.07519509, 0.02778421], [0.08160645, 0.03470296], [0.08550121, 0.02640104]],
   [[0.0319525 , 0.04060577], [0.03266289, 0.0435627 ], [0.02729163, 0.04439578], [0.02421181, 0.04001595], [0.02713242, 0.0345058 ], [0.02986114, 0.03651476]],
   [[0.0417908, 0.0371735], [0.0319525 , 0.04060577], [0.03266289, 0.0435627 ], [0.03329982, 0.04453503], [0.03595283, 0.0453078 ], [0.04305613, 0.03914449]],
   [[0.04446533, 0.03981457], [0.04998307, 0.05350169], [0.04771979, 0.05974198], [0.04665368, 0.05936335], [0.03595283, 0.0453078 ], [0.04305613, 0.03914449]],
   [[0.04049357, 0.03359793], [0.02986114, 0.03651476], [0.0319525 , 0.04060577], [0.0417908, 0.0371735]]
]


for vert in vert_list:

    shape = al.Polygon(
        vertices=vert
    )

    kept_triangles = solver.solve_triangles(
        tracer=tracer,
        shape=shape,
    )

    image_area = kept_triangles.area
    source_area = shape.area
    magnification = image_area / source_area

    print()
    print(vert)
    print("Image Area:", image_area)
    print("Source Area:", source_area)
    print("Magnification:", magnification)

The values printed for the third Voronoi cell are:

[[0.0417908, 0.0371735], [0.0319525, 0.04060577], [0.03266289, 0.0435627], [0.03329982, 0.04453503], [0.03595283, 0.0453078], [0.04305613, 0.03914449]]
Image Area: 0.006359874059041914
Source Area: 4.6182585109899977e-05
Magnification: 137.71152142972122

I have verified source pixel areas are correct, therefore I think the bug is that the image area is not being computed accurately.

This could be because additional triangles that fall outside the source Voronoi cell are being included in the area calculation incorrectly? Or maybe the source pixel is so small we need to account for the fraction of the area of image pixels that fall in the Voronoi cell?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions