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
2 changes: 2 additions & 0 deletions autogalaxy/config/visualize/plots.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ fit_interferometer: # Settings for plots of fits to inter
fits_dirty_images: false # output dirty_images.fits showing the dirty image, noise-map, model-data, resiual-map, normalized residual map and chi-squared map?

fit_ellipse: # Settings for plots of ellipse fitting fits (e.g. FitEllipse)
subplot_fit_ellipse : true # Plot subplot of all fit quantities for ellipse fits (e.g. the model data, residual-map, etc.)?
data : true # Plot the data of the ellipse fit?
data_no_ellipse: true # Plot the data without the black data ellipses, which obscure noisy data?
ellipse_residuals: true # Plot the residuals of the ellipse fit?

fit_quantity: {} # Settings for plots of fit quantities (e.g. FitQuantityPlotter).
4 changes: 2 additions & 2 deletions autogalaxy/ellipse/ellipse/ellipse_multipole.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class representing the multipole of an ellispe with, which is used to perform el
self.multipole_comps = multipole_comps

def points_perturbed_from(
self, pixel_scale, points, ellipse: Ellipse
self, pixel_scale, points, ellipse: Ellipse, n_i: int = 0
) -> np.ndarray:
"""
Returns the (y,x) coordinates of the input points, which are perturbed by the multipole of the ellipse.
Expand All @@ -57,7 +57,7 @@ def points_perturbed_from(
The (y,x) coordinates of the input points, which are perturbed by the multipole.
"""

angles = ellipse.angles_from_x0_from(pixel_scale=pixel_scale)
angles = ellipse.angles_from_x0_from(pixel_scale=pixel_scale, n_i=n_i)

radial = np.add(
self.multipole_comps[1] * np.cos(self.m * (angles - ellipse.angle_radians)),
Expand Down
28 changes: 19 additions & 9 deletions autogalaxy/ellipse/fit_ellipse.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ def points_from_major_axis_from(self) -> np.ndarray:
pixel_scale=self.dataset.pixel_scales[0],
)

if self.multipole_list is not None:
for multipole in self.multipole_list:
points = multipole.points_perturbed_from(
pixel_scale=self.dataset.pixel_scales[0],
points=points,
ellipse=self.ellipse,
)

if self.interp.mask_interp is not None:

i_total = 300
Expand All @@ -74,6 +82,16 @@ def points_from_major_axis_from(self) -> np.ndarray:
pixel_scale=self.dataset.pixel_scales[0], n_i=i
)

if self.multipole_list is not None:
for multipole in self.multipole_list:

points = multipole.points_perturbed_from(
pixel_scale=self.dataset.pixel_scales[0],
points=points,
ellipse=self.ellipse,
n_i=i
)

if i == i_total:

raise ValueError(
Expand All @@ -88,14 +106,6 @@ def points_from_major_axis_from(self) -> np.ndarray:

points = points[self.interp.mask_interp(points) == 0]

if self.multipole_list is not None:
for multipole in self.multipole_list:
points = multipole.points_perturbed_from(
pixel_scale=self.dataset.pixel_scales[0],
points=points,
ellipse=self.ellipse,
)

return points

@cached_property
Expand Down Expand Up @@ -279,4 +289,4 @@ def figure_of_merit(self) -> float:
-------
The figure of merit of the fit.
"""
return self.log_likelihood
return -0.5* (self.chi_squared + self.noise_normalization)
16 changes: 10 additions & 6 deletions autogalaxy/ellipse/model/plotter_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,18 +93,22 @@ def should_plot(name):
fit_list=fit_list, mat_plot_2d=mat_plot_2d, include_2d=self.include_2d
)

try:
fit_plotter.figures_2d(data=should_plot("data"))
except ValueError:
print(fit_plotter.fit_list[0].ellipse.major_axis)
print(fit_plotter.fit_list[0].ellipse.ell_comps)
fit_plotter.figures_2d(
data=should_plot("data"),
ellipse_residuals=should_plot("ellipse_residuals"),
)

if should_plot("data_no_ellipse"):
fit_plotter.figures_2d(
data=True,
disable_data_contours=True,

)

if should_plot("subplot_fit_ellipse"):

fit_plotter.subplot_fit_ellipse()

fit_plotter.mat_plot_2d.use_log10 = True

fit_plotter.figures_2d(data=should_plot("data"))
Expand All @@ -113,4 +117,4 @@ def should_plot(name):
fit_plotter.figures_2d(
data=True,
disable_data_contours=True,
)
)
Loading
Loading