print(mapper.source_grid_slim[0]) print("Source Grid2D Pixel 2") print(source_plane_grid[1]) print(mapper.source_grid_slim[1]) print("etc.") """ We can over-lay this grid on the figure, which is starting to look a bit less boring now! """ include_2d = aplt.Include2D(mapper_source_grid_slim=True, mapper_source_pixelization_grid=True) mapper_plotter = aplt.MapperPlotter(mapper=mapper, include_2d=include_2d) mapper_plotter.set_title("Even less Boring Grid2D of Rectangular Pixels") mapper_plotter.figure_2d() mat_plot_2d = aplt.MatPlot2D(axis=aplt.Axis(extent=[-0.3, 0.3, -0.3, 0.3])) mapper_plotter = aplt.MapperPlotter(mapper=mapper, mat_plot_2d=mat_plot_2d, include_2d=include_2d) mapper_plotter.set_title("Zoomed Grid2D of Rectangular Pixels") mapper_plotter.figure_2d() """ Finally, the mapper`s `pixeliation_grid` has lots of information about the pixelization, for example, the arc-second size and dimensions. """ print(mapper.source_pixelization_grid.shape_native_scaled) print(mapper.source_pixelization_grid.scaled_maxima) print(mapper.source_pixelization_grid.scaled_minima) """ __Wrap Up__
plane_plotter = aplt.PlanePlotter(plane=source_plane, grid=source_plane_grid, mat_plot_2d=mat_plot_2d) plane_plotter.figures_2d(plane_grid=True) """ The source-plane looks very interesting! We can see it is not regular, not uniform, and has an aestetically pleasing visual appearance. Remember that every coordinate on this source-plane grid (e.g. every black dot) corresponds to a coordinate on the image-plane grid that has been deflected by our mass profile; this is strong gravitational lensing in action! We can zoom in on the `centre` of the source-plane (remembering the lens galaxy was centred at (0.0", 0.0")) to reveal a 'diamond like' structure with a fractal like appearance. """ mat_plot_2d = aplt.MatPlot2D( title=aplt.Title(label="Source-plane Grid2D Zoomed"), axis=aplt.Axis(extent=[-0.1, 0.1, -0.1, 0.1]), ) plane_plotter = aplt.PlanePlotter(plane=source_plane, grid=source_plane_grid, mat_plot_2d=mat_plot_2d) plane_plotter.figures_2d(plane_grid=True) """ __Mappings__ Lets plot the image and source planes next to one another and highlight specific points on both. The coloring of the highlighted points therefore shows how specific image pixels **map** to the source-plane (and visa versa). This is the first time we have used the `Visuals2D` object, which allows the appearance of **PyAutoLens** figures to be customized. We'll see this object crop up throughout the **HowToLens** lectures, and a full description of all
# workspace_path = str(here()) # %cd $workspace_path # print(f"Working Directory has been set to `{workspace_path}`") from os import path import autolens as al import autolens.plot as aplt """ First, lets load an example Hubble Space Telescope image of a real strong lens as an `Array2D`. """ dataset_path = path.join("dataset", "slacs", "slacs1430+4105") image_path = path.join(dataset_path, "image.fits") image = al.Array2D.from_fits(file_path=image_path, hdu=0, pixel_scales=0.03) """ We can customize the figure using the `Axis` matplotlib wrapper object which wraps the following method(s): plt.axis: https://matplotlib.org/3.3.2/api/_as_gen/matplotlib.pyplot.axis.html """ array_plotter = aplt.Array2DPlotter(array=image) array_plotter.figure_2d() axis = aplt.Axis(extent=[-1.0, 1.0, -1.0, 1.0]) mat_plot_2d = aplt.MatPlot2D(axis=axis) array_plotter = aplt.Array2DPlotter(array=image, mat_plot_2d=mat_plot_2d) array_plotter.figure_2d() """ Finish. """