diff --git a/scripts/chapter_1_introduction/tutorial_1_grids_and_galaxies.py b/scripts/chapter_1_introduction/tutorial_1_grids_and_galaxies.py index c35ea02..352267c 100644 --- a/scripts/chapter_1_introduction/tutorial_1_grids_and_galaxies.py +++ b/scripts/chapter_1_introduction/tutorial_1_grids_and_galaxies.py @@ -1,4 +1,4 @@ -""" +r""" HowToLens: Introduction ======================= @@ -171,7 +171,7 @@ """ aplt.plot_grid(grid=grid_shifted, title="Grid Centered Around (0.3, 0.5)") -""" +r""" Next, we can rotate the grid by an angle `phi` (in degrees). The rotation is counter-clockwise from the positive x-axis. To rotate the grid: @@ -203,7 +203,7 @@ """ aplt.plot_grid(grid=grid_rotated, title="Grid Rotated 60 Degrees") -""" +r""" Next, we convert the rotated grid to elliptical coordinates using: $\eta = \sqrt{(x_r)^2 + (y_r)^2/q^2}$ @@ -220,7 +220,7 @@ axis_ratio = 0.5 eta = np.sqrt((grid_rotated[:, 0]) ** 2 + (grid_rotated[:, 1]) ** 2 / axis_ratio**2) -""" +r""" Above, the angle $\phi$ (in degrees) was used to rotate the grid, and the axis-ratio $q$ was used to convert the grid to elliptical coordinates. @@ -247,7 +247,7 @@ print(ell_comps) -""" +r""" __Light Profiles__ Galaxies are collections of stars, gas, dust, and other astronomical objects that emit light. Astronomers study this @@ -426,7 +426,7 @@ plt.close() -""" +r""" Since galaxy light distributions often cover a wide range of values, they are typically better visualized on a log10 scale. This approach helps highlight details in the faint outskirts of a light profile. diff --git a/scripts/chapter_1_introduction/tutorial_2_ray_tracing.py b/scripts/chapter_1_introduction/tutorial_2_ray_tracing.py index c914104..d0f7346 100644 --- a/scripts/chapter_1_introduction/tutorial_2_ray_tracing.py +++ b/scripts/chapter_1_introduction/tutorial_2_ray_tracing.py @@ -124,7 +124,7 @@ """ deflections = sis_mass_profile.deflections_yx_2d_from(grid=image_plane_grid) -""" +r""" Like grids and arrays, the deflection angles can be accessed using the `native` and `slim` attributes. These are structured similarly to a `Grid2D` object: @@ -151,7 +151,7 @@ """ print(type(deflections)) -""" +r""" This structure includes a `grid`, which represents the `Grid2D` of coordinates where the deflection angles are calculated (in this case, the `image_plane_grid` we defined earlier). It also has vector-specific methods, such as `magnitude`, which calculates the magnitude of each deflection vector using \((x^2 + y^2)^{0.5}\). @@ -229,7 +229,7 @@ use_log10=True, ) -""" +r""" __Ray Tracing Grids__ We now have all the tools we need to perform our first ray-tracing calculation. @@ -367,7 +367,7 @@ aplt.plot_grid(grid=image_plane_grid_traced, title="Image Plane Grid") aplt.plot_grid(grid=source_plane_grid_traced, title="Source Plane Grid") -""" +r""" __Wrap Up__ In this tutorial, you performed your first lensing calculations. Let's summarise what we've learnt: diff --git a/scripts/chapter_1_introduction/tutorial_4_point_sources.py b/scripts/chapter_1_introduction/tutorial_4_point_sources.py index 30467bb..f2f88d3 100644 --- a/scripts/chapter_1_introduction/tutorial_4_point_sources.py +++ b/scripts/chapter_1_introduction/tutorial_4_point_sources.py @@ -161,7 +161,7 @@ tracer = al.Tracer(galaxies=[lens_galaxy, source_galaxy]) -""" +r""" Note that we attached the point source to its galaxy with the name `point_0`. This name is a label that PyAutoLens uses when fitting real data to pair each point source in the model with the dataset containing its observed image positions. With one source the name is a formality, but group- and cluster-scale lenses can contain many point @@ -270,7 +270,7 @@ title="Multiple Images and Critical Curve", ) -""" +r""" __Magnifications__ Lensing does not just relocate a point source's light — it magnifies it. Each multiple image has its own @@ -340,7 +340,7 @@ print("Time Delays relative to first image (days):") print(time_delays - time_delays[0]) -""" +r""" __Extended Versus Point Computations__ We can now state precisely why point-source lensing works so differently from everything in tutorials 2 and 3, on diff --git a/scripts/chapter_1_introduction/tutorial_7_fitting.py b/scripts/chapter_1_introduction/tutorial_7_fitting.py index 58e0239..9d82d04 100644 --- a/scripts/chapter_1_introduction/tutorial_7_fitting.py +++ b/scripts/chapter_1_introduction/tutorial_7_fitting.py @@ -328,7 +328,7 @@ aplt.plot_array(array=fit.data, title="Data") aplt.plot_array(array=fit.model_data, title="Model Image") -""" +r""" The `residual_map` is the different between the observed image and model image, showing where in the image the fit is good (e.g. low residuals) and where it is bad (e.g. high residuals). @@ -348,7 +348,7 @@ aplt.plot_array(array=fit.residual_map, title="Residual Map") -""" +r""" Are these residuals indicative of a good fit to the data? Without considering the noise in the data, it's difficult to ascertain. That is, its hard to ascenrtain if a residual value is large or small because this depends on the amount of noise in that pixel. @@ -372,7 +372,7 @@ aplt.plot_array(array=fit.normalized_residual_map, title="Normalized Residual Map") -""" +r""" Next, we define the `chi_squared_map`, which is obtained by squaring the `normalized_residual_map` and serves as a measure of goodness of fit. @@ -395,7 +395,7 @@ aplt.plot_array(array=fit.chi_squared_map, title="Chi Squared Map") -""" +r""" Now, we consolidate all the information in our `chi_squared_map` into a single measure of goodness-of-fit called `chi_squared`. @@ -428,7 +428,7 @@ reduced_chi_squared = chi_squared / dataset.mask.pixels_in_mask print("Reduced Chi-squared = ", reduced_chi_squared) -""" +r""" Another quantity that contributes to our final assessment of the goodness-of-fit is the `noise_normalization`. The `noise_normalization` is computed by summing, over every pixel, the logarithm of 2 pi times the squared noise value: @@ -448,7 +448,7 @@ print("Noise Normalization = ", noise_normalization) print("Noise Normalization via fit = ", fit.noise_normalization) -""" +r""" From the `chi_squared` and `noise_normalization`, we can define a final goodness-of-fit measure known as the `log_likelihood`. @@ -464,7 +464,7 @@ print("Log Likelihood = ", log_likelihood) print("Log Likelihood via fit = ", fit.log_likelihood) -""" +r""" In the previous discussion, we noted that a lower \(\chi^2\) value indicates a better fit of the model to the observed data. diff --git a/scripts/chapter_2_lens_modeling/tutorial_1_non_linear_search.py b/scripts/chapter_2_lens_modeling/tutorial_1_non_linear_search.py index a94c841..171dc06 100644 --- a/scripts/chapter_2_lens_modeling/tutorial_1_non_linear_search.py +++ b/scripts/chapter_2_lens_modeling/tutorial_1_non_linear_search.py @@ -1,4 +1,4 @@ -""" +r""" Tutorial 1: Non-linear Search ============================= diff --git a/scripts/chapter_3_pixelizations/tutorial_5_bayesian_formalism.py b/scripts/chapter_3_pixelizations/tutorial_5_bayesian_formalism.py index 2a3b757..939ef6d 100644 --- a/scripts/chapter_3_pixelizations/tutorial_5_bayesian_formalism.py +++ b/scripts/chapter_3_pixelizations/tutorial_5_bayesian_formalism.py @@ -175,7 +175,7 @@ tracer = al.Tracer(galaxies=[lens_galaxy, source_galaxy]) -""" +r""" __Ray Tracing__ Every 2D (y,x) image-plane coordinate $\theta$ is ray-traced to its source-plane coordinate $\beta$ by subtracting @@ -331,7 +331,7 @@ plt.show() plt.close() -""" +r""" __Data Vector (D)__ We now pose the reconstruction as a linear inversion, converting the blurred mapping matrix, data and noise-map @@ -363,7 +363,7 @@ plt.show() plt.close() -""" +r""" __Curvature Matrix (F)__ The curvature matrix has dimensions `(total_source_pixels, total_source_pixels)` and is given by (WD03): @@ -386,7 +386,7 @@ plt.show() plt.close() -""" +r""" __Unregularized Solve__ The inversion seeks the source-pixel fluxes $s$ (a vector with one entry per source pixel) that minimize the @@ -410,7 +410,7 @@ print(reconstruction) -""" +r""" The reconstructed source-pixel fluxes are a noisy, unsmooth mess -- exactly the over-fitting we saw in tutorial 4 when we set the regularization coefficient to zero. The linear inversion is fitting the noise in the data, because this system of equations is ill-posed: we need a smoothness prior. @@ -486,7 +486,7 @@ aplt.plot_array(array=mapped_reconstructed_data, title="Reconstructed Image") -""" +r""" __Likelihood Function__ We now quantify the goodness-of-fit of the source reconstruction, computing the quantity tutorial 4 called the @@ -521,7 +521,7 @@ print(chi_squared) -""" +r""" __Regularization Term__ The second term, $s^{T} H s$, is the $\lambda \, G_{L}$ regularization penalty evaluated at the solution: the summed @@ -536,7 +536,7 @@ print(regularization_term) -""" +r""" __Complexity Terms__ Up to this point, nothing has justified our choice of `regularization_coefficient=1.0`. We cannot choose it using diff --git a/scripts/chapter_4_scaling_up_lensing/tutorial_3_scaling_relation.py b/scripts/chapter_4_scaling_up_lensing/tutorial_3_scaling_relation.py index 676b5bd..0b4059f 100644 --- a/scripts/chapter_4_scaling_up_lensing/tutorial_3_scaling_relation.py +++ b/scripts/chapter_4_scaling_up_lensing/tutorial_3_scaling_relation.py @@ -1,4 +1,4 @@ -""" +r""" Tutorial 3: Scaling Relations ============================= @@ -541,7 +541,7 @@ f"Tied galaxy {i}: relation predicts = {einstein_radius_predicted:.3f}" ) -""" +r""" The prediction lands within a few percent of the truth: this simulated pair happens to sit almost exactly on the Faber-Jackson relation. That is why the tied fit succeeds. Real galaxies are not always so obliging. diff --git a/scripts/chapter_4_scaling_up_lensing/tutorial_5_cluster_scale.py b/scripts/chapter_4_scaling_up_lensing/tutorial_5_cluster_scale.py index 0e4ca3c..973fbdf 100644 --- a/scripts/chapter_4_scaling_up_lensing/tutorial_5_cluster_scale.py +++ b/scripts/chapter_4_scaling_up_lensing/tutorial_5_cluster_scale.py @@ -1,4 +1,4 @@ -""" +r""" Tutorial 5: Cluster Scale =========================