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
1 change: 1 addition & 0 deletions autolens/config/visualize/plots.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ point_dataset: # Settings for plots of point source

fit_point_dataset: # Settings for plots of fits to point source datasets (e.g. FitPointDatasetPlotter).
fit_image_with_points: true # Plot the observed image (if passed to AnalysisPoint) with observed and model positions and critical curves over it (fit_image_with_points.png)?
subplot_point_solver: false # Plot how the PointSolver refines its triangles onto the best-fit model's images (point_solver.png)? Re-solves with NumPy at the best fit only, so it is off by default.

weak_dataset: # Settings for plots of weak lensing shear catalogues (e.g. PlotterWeak).
subplot_dataset: true # Plot subplot containing all dataset quantities (e.g. the shear field, noise-map, etc.)?
Expand Down
1 change: 1 addition & 0 deletions autolens/plot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
plot_image_with_points,
)
from autolens.point.plot.point_dataset_plots import subplot_dataset as subplot_point_dataset
from autolens.point.plot.point_solver_plots import plot_point_solver

from autolens.cluster.plot.cluster_plots import (
plot_positions_overlay,
Expand Down
50 changes: 50 additions & 0 deletions autolens/point/model/plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from autolens.point.plot.fit_point_plots import plot_image_with_points
from autolens.point.dataset import PointDataset
from autolens.point.plot.point_dataset_plots import subplot_dataset
from autolens.point.plot import point_solver_plots

from autolens.analysis.plotter import plot_setting

Expand Down Expand Up @@ -160,3 +161,52 @@ def should_plot(name):
source_plane_line_colors=sp_colors,
title_prefix=self.title_prefix,
)

def point_solver(self, fit: FitPointDataset, image_plane_lines=None):
"""
Output `point_solver.png`: how the `PointSolver` refines its triangles onto the images of the fit's model.

The model's point source is re-solved with NumPy (the JAX path pads the steps and, inside `jax.jit`, hides
them), so this is a diagnostic of the model-fit's own solver at this model: did the grid cover every image
and how many triangles survive each step. A warning is logged when a step keeps nearly as many triangles as
the JAX solver's `MAX_CONTAINING_SIZE`, which the JAX path truncates to.

Controlled by the `fit_point_dataset: subplot_point_solver` setting, which is off by default as the
re-solve and figure cost a few seconds per visualization (more for a many-galaxy multi-plane cluster). The
figure is not output for fits without a `PointSolver` (e.g. source-plane fits of a model with no solver).

Parameters
----------
fit
The maximum log likelihood `FitPointDataset` of the non-linear search.
image_plane_lines
Pre-computed critical-curve lines; `None` computes them.
"""
try:
if not plot_setting(
section=["fit", "fit_point_dataset"], name="subplot_point_solver"
):
return
except KeyError:
return

solver = getattr(fit, "solver", None)
fit_positions = getattr(fit, "positions", None)
if solver is None or not hasattr(solver, "steps") or fit_positions is None:
return

data = point_solver_plots.point_solver_data_from(
solver=solver,
tracer=fit.tracer,
source_plane_coordinate=fit_positions.source_plane_coordinate,
positions=fit.dataset.positions,
plane_redshift=fit_positions.plane_redshift,
image_plane_lines=image_plane_lines,
)
point_solver_plots.warn_if_near_jax_cap(data)
point_solver_plots.plot_point_solver_from_data(
data=data,
output_path=str(self.image_path),
output_format=self.fmt,
title_prefix=self.title_prefix,
)
6 changes: 6 additions & 0 deletions autolens/point/model/visualizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,9 @@ def visualize(
galaxies=tracer.galaxies,
grid=grid,
)

# Off by default (`fit_point_dataset: subplot_point_solver`): re-solves the best-fit model with NumPy to show
# the solver's refinement steps, so it is output only for the full (not quick-update) visualization.
plotter.point_solver(
fit=fit, image_plane_lines=ip_lines if ip_lines is not None else []
)
Loading
Loading