sersic_light_profile = al.lp.EllSersic( centre=(0.0, 0.0), elliptical_comps=(0.2, 0.1), intensity=0.005, effective_radius=2.0, sersic_index=4.0, ) """ By passing this profile a `Grid2D`, we can evaluate the light at every (y,x) coordinate on the `Grid2D` and create an image of the `LightProfile`. """ image = sersic_light_profile.image_2d_from(grid=grid) """ The PyAutoLens plot module provides methods for plotting objects and their properties, like the `LightProfile`'s image. """ light_profile_plotter = aplt.LightProfilePlotter( light_profile=sersic_light_profile, grid=grid) light_profile_plotter.figures_2d(image=True) """ __Mass Profiles__ **PyAutoLens** uses `MassProfile` objects to represent a galaxy's mass distribution and perform ray-tracing calculations. Below we create an `EllIsothermal` `MassProfile` and compute its deflection angles on our Cartesian grid: """ isothermal_mass_profile = al.mp.EllIsothermal(centre=(0.0, 0.0), elliptical_comps=(0.1, 0.0), einstein_radius=1.6) deflections = isothermal_mass_profile.deflections_yx_2d_from(grid=grid) """ Lets plot the `MassProfile`'s deflection angle map.
galaxy_plotter = aplt.GalaxyPlotter( galaxy=fit.tracer.source_plane.galaxies[0], grid=source_plane_grid ) galaxy_plotter.figures(image=True) # %% """ As our fit and ray-tracing becomes more complex, it is useful to know how to decompose their different attributes to extract different things about them. For example, we made our source-galaxy above with two `LightProfile`'s, a `bulge` and `disk. We can plot the image of each component individually, if we know how to break-up the different components of the fit and `Tracer`. """ # %% light_profile_plotter = aplt.LightProfilePlotter( light_profile=fit.tracer.source_plane.galaxies[0].bulge, grid=source_plane_grid ) light_profile_plotter.set_title("Bulge Image") light_profile_plotter.figures() light_profile_plotter = aplt.LightProfilePlotter( light_profile=fit.tracer.source_plane.galaxies[0].disk, grid=source_plane_grid ) light_profile_plotter.set_title("Disk Image") light_profile_plotter.figures() # %% """ And, we're done, not just with the tutorial, but the chapter! To end, I want to quickly talk about code-design and structure. Yeah, I know, as a scientist, you don't like code
effective_radius=0.8, sersic_index=4.0, ) """ __Grid__ We also need the 2D grid the `LightProfile` is evaluated on. """ grid = al.Grid2D.uniform(shape_native=(100, 100), pixel_scales=0.05) """ __Figures__ We now pass the light profile and grid to a `LightProfilePlotter` and call various `figure_*` methods to plot different attributes in 1D and 2D. """ light_profile_plotter = aplt.LightProfilePlotter(light_profile=bulge, grid=grid) light_profile_plotter.figures_1d(image=True) light_profile_plotter.figures_2d(image=True) """ __Include__ A `LightProfile` and its `Grid2D` contains the following attributes which can be plotted automatically via the `Include2D` object. (By default, a `Grid2D` does not contain a `Mask2D`, we therefore manually created a `Grid2D` with a mask to illustrate plotting its mask and border below). """ include_2d = aplt.Include2D(origin=True, mask=True, border=True, light_profile_centres=True)
galaxy_plotter = aplt.GalaxyPlotter( galaxy=fit.tracer.source_plane.galaxies[0], grid=source_plane_grid ) galaxy_plotter.figures_2d(image=True) """ Understanding how these objects decompose into the different components of a strong lens is important for general **PyAutoLens** use. As the strong lens systems that we analyse become more complex, it is useful to know how to decompose their light profiles, mass profiles, galaxies and planes to extract different pieces of information about the strong lens. For example, we made our source-galaxy above with two light profiles, a `bulge` and `disk`. We can plot the lensed image of each component individually, now that we know how to break-up the different components of the fit and tracer. """ light_profile_plotter = aplt.LightProfilePlotter( light_profile=fit.tracer.source_plane.galaxies[0].bulge, grid=source_plane_grid ) light_profile_plotter.set_title("Bulge Image") light_profile_plotter.figures_2d(image=True) light_profile_plotter = aplt.LightProfilePlotter( light_profile=fit.tracer.source_plane.galaxies[0].disk, grid=source_plane_grid ) light_profile_plotter.set_title("Disk Image") light_profile_plotter.figures_2d(image=True) """ __Visualization__ Furthermore, using the `MatPLot2D`, `Visuals2D` and `Include2D` objects visualize any aspect of a fit we're interested in and fully customize the figure.
""" We also need the 2D grid the `LightProfile` is evaluated on. """ grid = al.Grid2D.uniform(shape_native=(100, 100), pixel_scales=0.05) """ We now pass the light profile and grid to a `LightProfilePlotter` and call the `figures_1d` methods to plot its image as a function of radius. The `LightProfile` includes the half-light radius as an internal property, meaning we can plot it via an `Include1D` object. """ include_1d = aplt.Include1D(half_light_radius=True) light_profile_plotter = aplt.LightProfilePlotter( light_profile=bulge, grid=grid, include_1d=include_1d ) light_profile_plotter.figures_1d(image=True) """ The appearance of the half-light radius is customized using a `HalfLightRadiusAXVLine` object. To plot the half-light radius as a vertical line this wraps the following matplotlib method: plt.axvline: https://matplotlib.org/3.3.2/api/_as_gen/matplotlib.pyplot.axvline.html """ half_light_radius_axvline = aplt.HalfLightRadiusAXVLine( linestyle="-.", c="r", linewidth=20 ) mat_plot_1d = aplt.MatPlot1D(half_light_radius_axvline=half_light_radius_axvline)