Exemplo n.º 1
0
)

positions = solver.solve(lensing_obj=mass_profile,
                         source_plane_coordinate=light_profile.centre)

lens_galaxy = al.Galaxy(redshift=0.5, mass=mass_profile)
source_galaxy = al.Galaxy(redshift=1.0, light=light_profile)
tracer = al.Tracer.from_galaxies(galaxies=[lens_galaxy, source_galaxy])

visuals_2d = aplt.Visuals2D(positions=positions)

magnification = tracer.magnification_from_grid(grid=grid)
magnification = np.nan_to_num(magnification)
print(magnification)

tracer_plotter = aplt.TracerPlotter(tracer=tracer,
                                    grid=grid,
                                    visuals_2d=visuals_2d)
tracer_plotter.figures(image=True)

mat_plot_2d = aplt.MatPlot2D(
    cmap=aplt.Cmap(vmax=9.0, vmin=-9.0),
    positions_scatter=aplt.PositionsScatter(s=100, c="w"),
)

tracer_plotter = aplt.TracerPlotter(tracer=tracer,
                                    grid=grid,
                                    visuals_2d=visuals_2d,
                                    mat_plot_2d=mat_plot_2d)
tracer_plotter.figure_magnification()
image = al.Array2D.from_fits(file_path=image_path, hdu=0, pixel_scales=0.03)
"""
We will also need a positions to plot on the figure, we'll set these up as a `Grid2DIrregular` of 2D (y,x) coordinates.
"""
positions = al.Grid2DIrregular(grid=[(1.0, 1.0), (2.0, 2.0), (3.0, 3.0)])
"""
To plot the positions manually, we can pass it into a` Visuals2D` object.
"""
visuals_2d = aplt.Visuals2D(positions=positions)

array_plotter = aplt.Array2DPlotter(array=image, visuals_2d=visuals_2d)
array_plotter.figure_2d()
"""
The appearance of the positions is customized using a `Scatter` object.

To plot the positions this object wraps the following matplotlib method:

 https://matplotlib.org/3.2.2/api/_as_gen/matplotlib.pyplot.scatter.html
"""
positions_scatter = aplt.PositionsScatter(marker="o", c="r", s=50)

mat_plot_2d = aplt.MatPlot2D(positions_scatter=positions_scatter)

array_plotter = aplt.Array2DPlotter(array=image,
                                    mat_plot_2d=mat_plot_2d,
                                    visuals_2d=visuals_2d)
array_plotter.figure_2d()
"""
Finish.
"""