Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions scripts/chapter_1_introduction/tutorial_1_grids_and_galaxies.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""
r"""
HowToGalaxy: Introduction
=========================

Expand Down Expand Up @@ -147,7 +147,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:
Expand Down Expand Up @@ -179,7 +179,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}$
Expand All @@ -199,7 +199,7 @@
print("First Ten Elliptical Coordinates:")
print(eta[:10])

"""
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.

Expand All @@ -226,7 +226,7 @@
print(ell_comps)


"""
r"""
__Light Profiles__

Galaxies are collections of stars, gas, dust, and other astronomical objects that emit light. Astronomers study this
Expand Down
14 changes: 7 additions & 7 deletions scripts/chapter_1_introduction/tutorial_3_fitting.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@
aplt.plot_array(array=dataset.data, title="Data")
aplt.plot_array(array=fit.model_data, title="Model Image")

"""
r"""
The `residual_map` is the difference 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).

Expand All @@ -317,7 +317,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 ascertain if a residual value is large or small because this depends on the
amount of noise in that pixel.
Expand All @@ -341,7 +341,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.

Expand All @@ -364,7 +364,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`.

Expand Down Expand Up @@ -397,7 +397,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 as the logarithm of the sum of squared noise values in our data:
Expand All @@ -417,7 +417,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`.

Expand All @@ -433,7 +433,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.

Expand Down
2 changes: 1 addition & 1 deletion scripts/chapter_2_modeling/tutorial_1_non_linear_search.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""
r"""
Tutorial 1: Non-linear Search
=============================

Expand Down
14 changes: 7 additions & 7 deletions scripts/chapter_3_pixelizations/tutorial_5_bayesian_formalism.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,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
Expand Down Expand Up @@ -335,7 +335,7 @@
plt.show()
plt.close()

"""
r"""
__Curvature Matrix (F)__

The curvature matrix has dimensions `(total_mesh_pixels, total_mesh_pixels)` and is given by (WD03):
Expand All @@ -359,7 +359,7 @@
plt.show()
plt.close()

"""
r"""
__Unregularized Solve__

The inversion seeks the mesh-pixel fluxes $s$ (a vector with one entry per mesh pixel) that minimize the
Expand All @@ -383,7 +383,7 @@

plot_mapper(mapper=mapper, solution_vector=reconstruction)

"""
r"""
The reconstructed mesh-pixel fluxes are a noisy, unsmooth mess -- exactly the over-fitting we saw in tutorial 4
when we lowered the regularization coefficient towards zero. The linear inversion is fitting the noise in the
data, because this system of equations is ill-posed: we need a smoothness prior.
Expand Down Expand Up @@ -459,7 +459,7 @@

aplt.plot_array(array=mapped_reconstructed_data, title="Reconstructed Image")

"""
r"""
__Likelihood Function__

We now quantify the goodness-of-fit of the galaxy reconstruction, computing the quantity tutorial 4 called the
Expand Down Expand Up @@ -494,7 +494,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
Expand All @@ -509,7 +509,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
Expand Down
Loading