def test__fit_sub_plot_real_space( fit_interferometer_x2_plane_7x7, fit_interferometer_x2_plane_inversion_7x7, include_2d_all, plot_path, plot_patch, ): fit_interferometer_plotter = aplt.FitInterferometerPlotter( fit=fit_interferometer_x2_plane_7x7, include_2d=include_2d_all, mat_plot_1d=aplt.MatPlot1D(output=aplt.Output(plot_path, format="png")), mat_plot_2d=aplt.MatPlot2D(output=aplt.Output(plot_path, format="png")), ) fit_interferometer_plotter.subplot_fit_real_space() assert path.join(plot_path, "subplot_fit_real_space.png") in plot_patch.paths plot_patch.paths = [] fit_interferometer_plotter = aplt.FitInterferometerPlotter( fit=fit_interferometer_x2_plane_inversion_7x7, include_2d=include_2d_all, mat_plot_1d=aplt.MatPlot1D(output=aplt.Output(plot_path, format="png")), mat_plot_2d=aplt.MatPlot2D(output=aplt.Output(plot_path, format="png")), ) fit_interferometer_plotter.subplot_fit_real_space() assert path.join(plot_path, "subplot_fit_real_space.png") in plot_patch.paths
Checkout the output folder for live outputs of the results of the fit, including on-the-fly visualization of the best fit model! """ result = search.fit(model=model, analysis=analysis) """ __Result__ The search returns a result object, which includes: - The lens model corresponding to the maximum log likelihood solution in parameter space. - The corresponding maximum log likelihood `Tracer` and `FitInterferometer` objects. - Information on the posterior as estimated by the `Dynesty` non-linear search. """ print(result.max_log_likelihood_instance) tracer_plotter = aplt.TracerPlotter(tracer=result.max_log_likelihood_tracer, grid=real_space_mask.masked_grid_sub_1) tracer_plotter.subplot_tracer() fit_interferometer_plotter = aplt.FitInterferometerPlotter( fit=result.max_log_likelihood_fit) fit_interferometer_plotter.subplot_fit_interferometer() fit_interferometer_plotter.subplot_fit_dirty_images() dynesty_plotter = aplt.DynestyPlotter(samples=result.samples) dynesty_plotter.cornerplot() """ Checkout `autolens_workspace/notebooks/interferometer/modeling/results.py` for a full description of the result object. """
def test__fit_quantities_are_output( fit_interferometer_x2_plane_7x7, plot_path, plot_patch ): fit_interferometer_plotter = aplt.FitInterferometerPlotter( fit=fit_interferometer_x2_plane_7x7, mat_plot_1d=aplt.MatPlot1D(output=aplt.Output(path=plot_path, format="png")), mat_plot_2d=aplt.MatPlot2D(output=aplt.Output(path=plot_path, format="png")), ) fit_interferometer_plotter.figures_2d( visibilities=True, noise_map=True, signal_to_noise_map=True, model_visibilities=True, residual_map_real=True, residual_map_imag=True, normalized_residual_map_real=True, normalized_residual_map_imag=True, chi_squared_map_real=True, chi_squared_map_imag=True, image=True, ) assert path.join(plot_path, "visibilities.png") in plot_patch.paths assert path.join(plot_path, "noise_map.png") in plot_patch.paths assert path.join(plot_path, "signal_to_noise_map.png") in plot_patch.paths assert path.join(plot_path, "model_visibilities.png") in plot_patch.paths assert ( path.join(plot_path, "real_residual_map_vs_uv_distances.png") in plot_patch.paths ) assert ( path.join(plot_path, "real_residual_map_vs_uv_distances.png") in plot_patch.paths ) assert ( path.join(plot_path, "real_normalized_residual_map_vs_uv_distances.png") in plot_patch.paths ) assert ( path.join(plot_path, "imag_residual_map_vs_uv_distances.png") in plot_patch.paths ) assert ( path.join(plot_path, "imag_residual_map_vs_uv_distances.png") in plot_patch.paths ) assert ( path.join(plot_path, "imag_normalized_residual_map_vs_uv_distances.png") in plot_patch.paths ) assert path.join(plot_path, "image_2d.png") in plot_patch.paths plot_patch.paths = [] fit_interferometer_plotter.figures_2d( visibilities=True, noise_map=False, signal_to_noise_map=False, model_visibilities=True, chi_squared_map_real=True, chi_squared_map_imag=True, ) assert path.join(plot_path, "visibilities.png") in plot_patch.paths assert path.join(plot_path, "noise_map.png") not in plot_patch.paths assert path.join(plot_path, "signal_to_noise_map.png") not in plot_patch.paths assert path.join(plot_path, "model_visibilities.png") in plot_patch.paths assert ( path.join(plot_path, "real_residual_map_vs_uv_distances.png") not in plot_patch.paths ) assert ( path.join(plot_path, "real_normalized_residual_map_vs_uv_distances.png") not in plot_patch.paths ) assert ( path.join(plot_path, "real_chi_squared_map_vs_uv_distances.png") in plot_patch.paths ) assert ( path.join(plot_path, "imag_residual_map_vs_uv_distances.png") not in plot_patch.paths ) assert ( path.join(plot_path, "imag_normalized_residual_map_vs_uv_distances.png") not in plot_patch.paths ) assert ( path.join(plot_path, "imag_chi_squared_map_vs_uv_distances.png") in plot_patch.paths )
"""Time the complete fitting procedure.""" tracer = al.Tracer.from_galaxies(galaxies=[lens_galaxy, source_galaxy]) start = time.time() for i in range(repeats): fit = al.FitInterferometer( masked_interferometer=masked_interferometer, tracer=tracer, settings_inversion=al.SettingsInversion( use_linear_operators=use_linear_operators), ) calculation_time = time.time() - start print("Time to compute fit = {}".format(calculation_time / repeats)) print(fit.figure_of_merit) fit_interferometer_plotter = aplt.FitInterferometerPlotter(fit=fit) fit_interferometer_plotter.subplot_fit_interferometer() fit_interferometer_plotter.subplot_fit_real_space() """Time how long it takes to map the reconstruction of the `Inversion` back to the image-plane visibilities.""" start = time.time() for i in range(repeats): fit.inversion.mapped_reconstructed_visibilities calculation_time = time.time() - start print("Time to compute inversion mapped = {}".format(calculation_time / repeats))