def test__all_individual_plotter( tracer_x2_plane_7x7, sub_grid_7x7, mask_7x7, include_2d_all, plot_path, plot_patch ): tracer_plotter = aplt.TracerPlotter( tracer=tracer_x2_plane_7x7, grid=sub_grid_7x7, mat_plot_2d=aplt.MatPlot2D(output=aplt.Output(plot_path, format="png")), ) tracer_plotter.figures( image=True, source_plane=True, convergence=True, potential=True, deflections_y=True, deflections_x=True, magnification=True, ) assert path.join(plot_path, "image.png") in plot_patch.paths assert path.join(plot_path, "plane_image_of_plane_1.png") in plot_patch.paths assert path.join(plot_path, "convergence.png") in plot_patch.paths assert path.join(plot_path, "potential.png") in plot_patch.paths assert path.join(plot_path, "deflections_y.png") in plot_patch.paths assert path.join(plot_path, "deflections_x.png") in plot_patch.paths assert path.join(plot_path, "magnification.png") in plot_patch.paths tracer_x2_plane_7x7.planes[0].galaxies[0].hyper_galaxy = al.HyperGalaxy() tracer_x2_plane_7x7.planes[0].galaxies[0].hyper_model_image = al.Array2D.ones( shape_native=(7, 7), pixel_scales=0.1 ) tracer_x2_plane_7x7.planes[0].galaxies[0].hyper_galaxy_image = al.Array2D.ones( shape_native=(7, 7), pixel_scales=0.1 ) tracer_plotter.figures(contribution_map=True) assert path.join(plot_path, "contribution_map.png") in plot_patch.paths plot_patch.paths = [] tracer_plotter = aplt.TracerPlotter( tracer=tracer_x2_plane_7x7, grid=sub_grid_7x7, include_2d=include_2d_all, mat_plot_2d=aplt.MatPlot2D(output=aplt.Output(plot_path, format="png")), ) tracer_plotter.figures( image=True, source_plane=True, potential=True, magnification=True ) assert path.join(plot_path, "image.png") in plot_patch.paths assert path.join(plot_path, "plane_image_of_plane_1.png") in plot_patch.paths assert path.join(plot_path, "convergence.png") not in plot_patch.paths assert path.join(plot_path, "potential.png") in plot_patch.paths assert path.join(plot_path, "deflections_y.png") not in plot_patch.paths assert path.join(plot_path, "deflections_x.png") not in plot_patch.paths assert path.join(plot_path, "magnification.png") in plot_patch.paths
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
def test__subhalo_detection_sub_plot( masked_imaging_fit_x2_plane_7x7, masked_imaging_fit_x2_plane_inversion_7x7, include_all, plot_path, plot_patch, ): arr = al.Array.manual_2d(array=[[1.0, 2.0], [3.0, 4.0]], pixel_scales=1.0) aplt.Subhalo.subplot_detection_imaging( fit_imaging_detect=masked_imaging_fit_x2_plane_7x7, detection_array=arr, mass_array=arr, include=include_all, sub_plotter=aplt.SubPlotter( output=aplt.Output(path=plot_path, format="png")), ) assert path.join(plot_path, "subplot_detection_imaging.png") in plot_patch.paths aplt.Subhalo.subplot_detection_imaging( fit_imaging_detect=masked_imaging_fit_x2_plane_inversion_7x7, detection_array=arr, mass_array=arr, include=include_all, sub_plotter=aplt.SubPlotter( output=aplt.Output(path=plot_path, format="png")), ) assert path.join(plot_path, "subplot_detection_imaging.png") in plot_patch.paths
def test__subhalo_detection_fits( masked_imaging_fit_x2_plane_7x7, masked_imaging_fit_x2_plane_inversion_7x7, include_all, plot_path, plot_patch, ): aplt.Subhalo.subplot_detection_fits( fit_imaging_before=masked_imaging_fit_x2_plane_7x7, fit_imaging_detect=masked_imaging_fit_x2_plane_7x7, include=include_all, sub_plotter=aplt.SubPlotter( output=aplt.Output(path=plot_path, format="png")), ) assert path.join(plot_path, "subplot_detection_fits.png") in plot_patch.paths aplt.Subhalo.subplot_detection_fits( fit_imaging_before=masked_imaging_fit_x2_plane_inversion_7x7, fit_imaging_detect=masked_imaging_fit_x2_plane_inversion_7x7, include=include_all, sub_plotter=aplt.SubPlotter( output=aplt.Output(path=plot_path, format="png")), ) assert path.join(plot_path, "subplot_detection_fits.png") in plot_patch.paths
def test__subtracted_image_of_plane_is_output( masked_imaging_fit_x1_plane_7x7, masked_imaging_fit_x2_plane_7x7, include_all, plot_path, plot_patch, ): aplt.FitImaging.subtracted_image_of_plane( fit=masked_imaging_fit_x1_plane_7x7, plane_index=0, include=include_all, plotter=aplt.Plotter(output=aplt.Output(plot_path, format="png")), ) assert plot_path + "subtracted_image_of_plane_0.png" in plot_patch.paths aplt.FitImaging.subtracted_image_of_plane( fit=masked_imaging_fit_x2_plane_7x7, plane_index=0, include=include_all, plotter=aplt.Plotter(output=aplt.Output(plot_path, format="png")), ) assert plot_path + "subtracted_image_of_plane_0.png" in plot_patch.paths aplt.FitImaging.subtracted_image_of_plane( fit=masked_imaging_fit_x2_plane_7x7, plane_index=1, include=include_all, plotter=aplt.Plotter(output=aplt.Output(plot_path, format="png")), ) assert plot_path + "subtracted_image_of_plane_1.png" in plot_patch.paths
def simulate_imaging_from_instrument(instrument, dataset_name, galaxies): # Simulate the imaging data, remembering that we use a special image which ensures edge-effects don't # degrade our modeling of the telescope optics (e.al. the PSF convolution). grid = instrument_util.grid_from_instrument(instrument=instrument) simulator = simulator_from_instrument(instrument=instrument) # Use the input galaxies to setup a tracer, which will generate the image for the simulated imaging data. tracer = al.Tracer.from_galaxies(galaxies=galaxies) imaging = simulator.from_tracer_and_grid(tracer=tracer, grid=grid) # Now, lets output this simulated imaging-data to the test_autoarray/simulator folder. test_path = path.join("{}".format(path.dirname(path.realpath(__file__))), "..", "..") dataset_path = path.join(test_path, "dataset", "imaging", dataset_name, instrument) imaging.output_to_fits( image_path=path.join(dataset_path, "image.fits"), psf_path=path.join(dataset_path, "psf.fits"), noise_map_path=path.join(dataset_path, "noise_map.fits"), overwrite=True, ) plotter = aplt.Plotter(output=aplt.Output(path=dataset_path, format="png")) sub_plotter = aplt.SubPlotter( output=aplt.Output(path=dataset_path, format="png")) aplt.Imaging.subplot_imaging(imaging=imaging, sub_plotter=sub_plotter) aplt.Imaging.individual( imaging=imaging, plot_image=True, plot_noise_map=True, plot_psf=True, plot_signal_to_noise_map=True, plotter=plotter, ) aplt.Tracer.subplot_tracer(tracer=tracer, grid=grid, sub_plotter=sub_plotter) aplt.Tracer.individual( tracer=tracer, grid=grid, plot_image=True, plot_source_plane=True, plot_convergence=True, plot_potential=True, plot_deflections=True, plotter=plotter, )
def test__subplot_of_plane( masked_imaging_fit_x1_plane_7x7, masked_imaging_fit_x2_plane_7x7, include_all, plot_path, plot_patch, ): aplt.fit_imaging.subplot_of_plane( fit=masked_imaging_fit_x1_plane_7x7, plane_index=0, include=include_all, sub_plotter=aplt.SubPlotter( output=aplt.Output(plot_path, format="png")), ) assert plot_path + "subplot_of_plane_0.png" in plot_patch.paths aplt.fit_imaging.subplot_of_plane( fit=masked_imaging_fit_x2_plane_7x7, plane_index=0, include=include_all, sub_plotter=aplt.SubPlotter( output=aplt.Output(plot_path, format="png")), ) assert plot_path + "subplot_of_plane_0.png" in plot_patch.paths aplt.fit_imaging.subplot_of_plane( fit=masked_imaging_fit_x2_plane_7x7, plane_index=1, include=include_all, sub_plotter=aplt.SubPlotter( output=aplt.Output(plot_path, format="png")), ) assert plot_path + "subplot_of_plane_1.png" in plot_patch.paths aplt.fit_imaging.subplots_of_all_planes( fit=masked_imaging_fit_x1_plane_7x7, include=include_all, sub_plotter=aplt.SubPlotter( output=aplt.Output(plot_path, format="png")), ) assert plot_path + "subplot_of_plane_0.png" in plot_patch.paths aplt.fit_imaging.subplots_of_all_planes( fit=masked_imaging_fit_x2_plane_7x7, include=include_all, sub_plotter=aplt.SubPlotter( output=aplt.Output(plot_path, format="png")), ) assert plot_path + "subplot_of_plane_0.png" in plot_patch.paths assert plot_path + "subplot_of_plane_1.png" in plot_patch.paths
def simulate_interferometer_from_instrument(instrument, dataset_name, galaxies): # Simulate the imaging data, remembering that we use a special image which ensures edge-effects don't # degrade our modeling of the telescope optics (e.al. the PSF convolution). grid = instrument_util.grid_from_instrument(instrument=instrument) simulator = simulator_from_instrument(instrument=instrument) # Use the input galaxies to setup a tracer, which will generate the image for the simulated imaging data. tracer = al.Tracer.from_galaxies(galaxies=galaxies) interferometer = simulator.from_tracer_and_grid(tracer=tracer, grid=grid) # Now, lets output this simulated interferometer-simulator to the test_autoarray/simulator folder. test_path = path.join("{}".format(path.dirname(path.realpath(__file__))), "..", "..") dataset_path = path.join("dataset", "interferometer", dataset_name, instrument) interferometer.output_to_fits( visibilities_path=path.join(dataset_path, "visibilities.fits"), noise_map_path=path.join(dataset_path, "noise_map.fits"), uv_wavelengths_path=path.join(dataset_path, "uv_wavelengths.fits"), overwrite=True, ) plotter = aplt.MatPlot2D( output=aplt.Output(path=dataset_path, format="png")) plotter = aplt.MatPlot2D( output=aplt.Output(path=dataset_path, format="png")) aplt.Interferometer.subplot_interferometer(interferometer=interferometer, plotter=plotter) aplt.Interferometer.figures(interferometer=interferometer, visibilities=True, plotter=plotter) aplt.Tracer.subplot_tracer(tracer=tracer, grid=grid, plotter=plotter) aplt.Tracer.figures( tracer=tracer, grid=grid, image=True, source_plane=True, convergence=True, potential=True, deflections=True, plotter=plotter, )
def simulate_interferometer_from_instrument(instrument, data_name, galaxies): # Simulate the imaging data, remembering that we use a special image which ensures edge-effects don't # degrade our modeling of the telescope optics (e.al. the PSF convolution). grid = instrument_util.grid_from_instrument(instrument=instrument) simulator = simulator_from_instrument(instrument=instrument) # Use the input galaxies to setup a tracer, which will generate the image for the simulated imaging data. tracer = al.Tracer.from_galaxies(galaxies=galaxies) interferometer = simulator.from_tracer_and_grid(tracer=tracer, grid=grid) # Now, lets output this simulated interferometer-simulator to the test_autoarray/simulator folder. test_path = "{}/../../".format(os.path.dirname(os.path.realpath(__file__))) dataset_path = af.util.create_path( path=test_path, folders=["dataset", "interferometer", data_name, instrument] ) interferometer.output_to_fits( visibilities_path=f"{dataset_path}/visibilities.fits", noise_map_path=f"{dataset_path}/noise_map.fits", uv_wavelengths_path=f"{dataset_path}/uv_wavelengths.fits", overwrite=True, ) plotter = aplt.Plotter(output=aplt.Output(path=dataset_path, format="png")) sub_plotter = aplt.SubPlotter(output=aplt.Output(path=dataset_path, format="png")) aplt.Interferometer.subplot_interferometer( interferometer=interferometer, sub_plotter=sub_plotter ) aplt.Interferometer.individual( interferometer=interferometer, plot_visibilities=True, plotter=plotter ) aplt.Tracer.subplot_tracer(tracer=tracer, grid=grid, sub_plotter=sub_plotter) aplt.Tracer.individual( tracer=tracer, grid=grid, plot_image=True, plot_source_plane=True, plot_convergence=True, plot_potential=True, plot_deflections=True, plotter=plotter, )
def test__subplot_fit_point(fit_point_dataset_x2_plane, include_2d_all, plot_path, plot_patch): fit_point_plotter = aplt.FitPointDatasetPlotter( fit=fit_point_dataset_x2_plane, include_2d=include_2d_all, 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_point_plotter.subplot_fit_point() assert path.join(plot_path, "subplot_fit_point.png") in plot_patch.paths
def test__subhalo_detection_sub_plot( fit_imaging_x2_plane_7x7, fit_imaging_x2_plane_inversion_7x7, include_2d_all, plot_path, plot_patch, ): arr = al.Array2D.manual_native(array=[[1.0, 2.0], [3.0, 4.0]], pixel_scales=1.0) subhalo_plotter = aplt.SubhaloPlotter( include_2d=include_2d_all, mat_plot_2d=aplt.MatPlot2D( output=aplt.Output(path=plot_path, format="png")), ) subhalo_plotter.subplot_detection_imaging( fit_imaging_detect=fit_imaging_x2_plane_7x7, detection_array=arr, mass_array=arr) assert path.join(plot_path, "subplot_detection_imaging.png") in plot_patch.paths subhalo_plotter.subplot_detection_imaging( fit_imaging_detect=fit_imaging_x2_plane_inversion_7x7, detection_array=arr, mass_array=arr, ) assert path.join(plot_path, "subplot_detection_imaging.png") in plot_patch.paths
def test__subplot_point_dataset(point_dataset, include_2d_all, plot_path, plot_patch): point_dataset_plotter = aplt.PointDatasetPlotter( point_dataset=point_dataset, include_2d=include_2d_all, 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")), ) point_dataset_plotter.subplot_point_dataset() assert path.join(plot_path, "subplot_point_dataset.png") in plot_patch.paths
def test__figures_of_plane( tracer_x2_plane_7x7, sub_grid_2d_7x7, mask_2d_7x7, include_2d_all, plot_path, plot_patch, ): tracer_plotter = aplt.TracerPlotter( tracer=tracer_x2_plane_7x7, grid=sub_grid_2d_7x7, include_2d=include_2d_all, mat_plot_2d=aplt.MatPlot2D( output=aplt.Output(path=plot_path, format="png")), ) tracer_plotter.figures_2d_of_planes(plane_image=True, plane_grid=True) assert path.join(plot_path, "plane_image_of_plane_0.png") in plot_patch.paths assert path.join(plot_path, "plane_image_of_plane_1.png") in plot_patch.paths plot_patch.paths = [] tracer_plotter.figures_2d_of_planes(plane_image=True, plane_index=0) assert path.join(plot_path, "plane_image_of_plane_0.png") in plot_patch.paths assert path.join(plot_path, "plane_image_of_plane_1.png") not in plot_patch.paths
def test__subhalo_detection_fits( masked_imaging_fit_x2_plane_7x7, masked_imaging_fit_x2_plane_inversion_7x7, include_2d_all, plot_path, plot_patch, ): subhalo_plotter = aplt.SubhaloPlotter( include_2d=include_2d_all, mat_plot_2d=aplt.MatPlot2D(output=aplt.Output(path=plot_path, format="png")), ) subhalo_plotter.subplot_detection_fits( fit_imaging_before=masked_imaging_fit_x2_plane_7x7, fit_imaging_detect=masked_imaging_fit_x2_plane_7x7, ) assert path.join(plot_path, "subplot_detection_fits.png") in plot_patch.paths subhalo_plotter.subplot_detection_fits( fit_imaging_before=masked_imaging_fit_x2_plane_inversion_7x7, fit_imaging_detect=masked_imaging_fit_x2_plane_inversion_7x7, ) assert path.join(plot_path, "subplot_detection_fits.png") in plot_patch.paths
def test__fit_individuals__source_and_lens__depedent_on_input( masked_interferometer_fit_x1_plane_7x7, masked_interferometer_fit_x2_plane_7x7, include_all, plot_path, plot_patch, ): aplt.FitInterferometer.individuals( fit=masked_interferometer_fit_x1_plane_7x7, plot_visibilities=True, plot_noise_map=False, plot_signal_to_noise_map=False, plot_model_visibilities=True, plot_chi_squared_map=True, include=include_all, plotter=aplt.Plotter(output=aplt.Output(plot_path, format="png")), ) assert plot_path + "visibilities.png" in plot_patch.paths assert plot_path + "noise_map.png" not in plot_patch.paths assert plot_path + "signal_to_noise_map.png" not in plot_patch.paths assert plot_path + "model_visibilities.png" in plot_patch.paths assert plot_path + "residual_map_vs_uv_distances_real.png" not in plot_patch.paths assert (plot_path + "normalized_residual_map_vs_uv_distances_real.png" not in plot_patch.paths) assert plot_path + "chi_squared_map_vs_uv_distances_real.png" in plot_patch.paths
def test__tracer_individuals__dependent_on_input(tracer_x2_plane_7x7, sub_grid_7x7, include_all, ray_tracing_plotter_path, plot_patch): aplt.Tracer.individual( tracer=tracer_x2_plane_7x7, grid=sub_grid_7x7, plot_image=True, plot_source_plane=True, plot_potential=True, plot_magnification=True, include=include_all, plotter=aplt.Plotter( output=aplt.Output(ray_tracing_plotter_path, format="png")), ) assert ray_tracing_plotter_path + "image.png" in plot_patch.paths assert ray_tracing_plotter_path + "source_plane.png" in plot_patch.paths assert ray_tracing_plotter_path + "convergence.png" not in plot_patch.paths assert ray_tracing_plotter_path + "potential.png" in plot_patch.paths assert ray_tracing_plotter_path + "deflections_y.png" not in plot_patch.paths assert ray_tracing_plotter_path + "deflections_x.png" not in plot_patch.paths assert ray_tracing_plotter_path + "magnification.png" in plot_patch.paths
def test__fit_point_quantities_are_output(fit_point_dataset_x2_plane, include_2d_all, plot_path, plot_patch): fit_point_plotter = aplt.FitPointDatasetPlotter( fit=fit_point_dataset_x2_plane, include_2d=include_2d_all, 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_point_plotter.figures_2d(positions=True, fluxes=True) assert path.join(plot_path, "fit_point_dataset_positions.png") in plot_patch.paths assert path.join(plot_path, "fit_point_dataset_fluxes.png") in plot_patch.paths plot_patch.paths = [] fit_point_plotter.figures_2d(positions=True, fluxes=False) assert path.join(plot_path, "fit_point_dataset_positions.png") in plot_patch.paths assert path.join(plot_path, "fit_point_dataset_fluxes.png") not in plot_patch.paths plot_patch.paths = [] fit_point_dataset_x2_plane.point_dataset.fluxes = None fit_point_plotter = aplt.FitPointDatasetPlotter( fit=fit_point_dataset_x2_plane, include_2d=include_2d_all, mat_plot_2d=aplt.MatPlot2D( output=aplt.Output(path=plot_path, format="png")), ) fit_point_plotter.figures_2d(positions=True, fluxes=True) assert path.join(plot_path, "fit_point_dataset_positions.png") in plot_patch.paths assert path.join(plot_path, "fit_point_dataset_fluxes.png") not in plot_patch.paths
def test__fit_quantities_are_output( masked_imaging_fit_x2_plane_7x7, include_all, plot_path, plot_patch ): aplt.FitImaging.image( fit=masked_imaging_fit_x2_plane_7x7, include=include_all, plotter=aplt.Plotter(output=aplt.Output(path=plot_path, format="png")), ) assert plot_path + "image.png" in plot_patch.paths aplt.FitImaging.noise_map( fit=masked_imaging_fit_x2_plane_7x7, include=include_all, plotter=aplt.Plotter(output=aplt.Output(path=plot_path, format="png")), ) assert plot_path + "noise_map.png" in plot_patch.paths aplt.FitImaging.signal_to_noise_map( fit=masked_imaging_fit_x2_plane_7x7, include=include_all, plotter=aplt.Plotter(output=aplt.Output(path=plot_path, format="png")), ) assert plot_path + "signal_to_noise_map.png" in plot_patch.paths aplt.FitImaging.model_image( fit=masked_imaging_fit_x2_plane_7x7, include=include_all, plotter=aplt.Plotter(output=aplt.Output(path=plot_path, format="png")), ) assert plot_path + "model_image.png" in plot_patch.paths aplt.FitImaging.residual_map( fit=masked_imaging_fit_x2_plane_7x7, include=include_all, plotter=aplt.Plotter(output=aplt.Output(path=plot_path, format="png")), ) assert plot_path + "residual_map.png" in plot_patch.paths aplt.FitImaging.normalized_residual_map( fit=masked_imaging_fit_x2_plane_7x7, include=include_all, plotter=aplt.Plotter(output=aplt.Output(path=plot_path, format="png")), ) assert plot_path + "normalized_residual_map.png" in plot_patch.paths aplt.FitImaging.chi_squared_map( fit=masked_imaging_fit_x2_plane_7x7, include=include_all, plotter=aplt.Plotter(output=aplt.Output(path=plot_path, format="png")), ) assert plot_path + "chi_squared_map.png" in plot_patch.paths
def test__fit_sub_plot( masked_imaging_fit_x2_plane_7x7, include_all, plot_path, plot_patch ): aplt.FitImaging.subplot_fit_imaging( fit=masked_imaging_fit_x2_plane_7x7, include=include_all, sub_plotter=aplt.SubPlotter(output=aplt.Output(path=plot_path, format="png")), ) assert path.join(plot_path, "subplot_fit_imaging.png") in plot_patch.paths
def test__plot_individual_images(hyper_galaxy_image_0_7x7, contribution_map_7x7, include_all, plot_path, plot_patch): aplt.hyper.hyper_galaxy_image( galaxy_image=hyper_galaxy_image_0_7x7, include=include_all, plotter=aplt.Plotter(output=aplt.Output(plot_path, format="png")), ) assert plot_path + "hyper_galaxy_image.png" in plot_patch.paths aplt.hyper.contribution_map( contribution_map_in=contribution_map_7x7, include=include_all, plotter=aplt.Plotter(output=aplt.Output(plot_path, format="png")), ) assert plot_path + "contribution_map.png" in plot_patch.paths
def test__fit_sub_plot(masked_interferometer_fit_x2_plane_7x7, include_all, plot_path, plot_patch): aplt.FitInterferometer.subplot_fit_interferometer( fit=masked_interferometer_fit_x2_plane_7x7, include=include_all, sub_plotter=aplt.SubPlotter( output=aplt.Output(plot_path, format="png")), ) assert plot_path + "subplot_fit_interferometer.png" in plot_patch.paths
def test__tracer_sub_plot_output(tracer_x2_plane_7x7, sub_grid_7x7, include_all, plot_path, plot_patch): aplt.Tracer.subplot_tracer( tracer=tracer_x2_plane_7x7, grid=sub_grid_7x7, include=include_all, sub_plotter=aplt.SubPlotter( output=aplt.Output(plot_path, format="png")), ) assert path.join(plot_path, "subplot_tracer.png") in plot_patch.paths
def test__tracer_sub_plot_output(tracer_x2_plane_7x7, sub_grid_7x7, include_all, ray_tracing_plotter_path, plot_patch): aplt.tracer.subplot_tracer( tracer=tracer_x2_plane_7x7, grid=sub_grid_7x7, include=include_all, sub_plotter=aplt.SubPlotter( output=aplt.Output(ray_tracing_plotter_path, format="png")), ) assert ray_tracing_plotter_path + "subplot_tracer.png" in plot_patch.paths
def test__subplot_point_dict(point_dict, include_2d_all, plot_path, plot_patch): point_dict_plotter = aplt.PointDictPlotter( point_dict=point_dict, include_2d=include_2d_all, 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")), ) point_dict_plotter.subplot_positions() assert path.join(plot_path, "subplot_point_dict_positions.png") in plot_patch.paths point_dict_plotter.subplot_fluxes() assert path.join(plot_path, "subplot_point_dict_fluxes.png") in plot_patch.paths
def test__tracer_sub_plot_output(tracer_x2_plane_7x7, sub_grid_7x7, include_2d_all, plot_path, plot_patch): tracer_plotter = aplt.TracerPlotter( tracer=tracer_x2_plane_7x7, grid=sub_grid_7x7, include_2d=include_2d_all, mat_plot_2d=aplt.MatPlot2D( output=aplt.Output(plot_path, format="png")), ) tracer_plotter.subplot_tracer() assert path.join(plot_path, "subplot_tracer.png") in plot_patch.paths
def test_subplot_fit_imaging_is_output(masked_imaging_fit_x2_plane_7x7, include_2d_all, plot_path, plot_patch): fit_imaging_plotter = aplt.FitImagingPlotter( fit=masked_imaging_fit_x2_plane_7x7, include_2d=include_2d_all, mat_plot_2d=aplt.MatPlot2D( output=aplt.Output(plot_path, format="png")), ) fit_imaging_plotter.subplot_fit_imaging() assert path.join(plot_path, "subplot_fit_imaging.png") in plot_patch.paths
def test__plot_hyper_galaxy_images(hyper_galaxy_image_path_dict_7x7, mask_7x7, include_all, plot_path, plot_patch): aplt.hyper.subplot_hyper_galaxy_images( hyper_galaxy_image_path_dict=hyper_galaxy_image_path_dict_7x7, mask=mask_7x7, include=include_all, sub_plotter=aplt.SubPlotter( output=aplt.Output(plot_path, format="png")), ) assert plot_path + "subplot_hyper_galaxy_images.png" in plot_patch.paths
def test__image_and_mapper_subplot_is_output_for_all_mappers( imaging_7x7, rectangular_mapper_7x7_3x3, voronoi_mapper_9_3x3, plot_path, plot_patch): critical_curves = [(0.0, 0.0), (0.1, 0.1)] caustics = [(0.0, 0.0), (0.1, 0.1)] aplt.mapper.subplot_image_and_mapper( image=imaging_7x7.image, mapper=rectangular_mapper_7x7_3x3, critical_curves=critical_curves, caustics=caustics, include=aplt.Include(inversion_pixelization_grid=True, inversion_grid=True, inversion_border=True), image_pixel_indexes=[[0, 1, 2], [3]], source_pixel_indexes=[[1, 2], [0]], sub_plotter=aplt.SubPlotter( output=aplt.Output(path=plot_path, format="png")), ) assert plot_path + "subplot_image_and_mapper.png" in plot_patch.paths aplt.mapper.subplot_image_and_mapper( image=imaging_7x7.image, mapper=voronoi_mapper_9_3x3, critical_curves=critical_curves, caustics=caustics, include=aplt.Include(inversion_pixelization_grid=True, inversion_grid=True, inversion_border=True), image_pixel_indexes=[[0, 1, 2], [3]], source_pixel_indexes=[[1, 2], [0]], sub_plotter=aplt.SubPlotter( output=aplt.Output(path=plot_path, format="png")), ) assert plot_path + "subplot_image_and_mapper.png" in plot_patch.paths
def test__inversion_subplot_is_output_for_all_inversions( imaging_7x7, rectangular_inversion_7x7_3x3, voronoi_inversion_9_3x3, plot_path, plot_patch, ): aplt.inversion.subplot_inversion( inversion=rectangular_inversion_7x7_3x3, image_pixel_indexes=[[0, 1, 2], [3]], source_pixel_indexes=[[1, 2], [0]], sub_plotter=aplt.SubPlotter( output=aplt.Output(path=plot_path, format="png")), ) assert plot_path + "subplot_inversion.png" in plot_patch.paths aplt.inversion.subplot_inversion( inversion=voronoi_inversion_9_3x3, image_pixel_indexes=[[0, 1, 2], [3]], source_pixel_indexes=[[1, 2], [0]], sub_plotter=aplt.SubPlotter( output=aplt.Output(path=plot_path, format="png")), ) assert plot_path + "subplot_inversion.png" in plot_patch.paths
def test__fit_quantities_are_output(masked_imaging_fit_x2_plane_7x7, include_2d_all, plot_path, plot_patch): fit_imaging_plotter = aplt.FitImagingPlotter( fit=masked_imaging_fit_x2_plane_7x7, include_2d=include_2d_all, mat_plot_2d=aplt.MatPlot2D( output=aplt.Output(path=plot_path, format="png")), ) fit_imaging_plotter.figures( image=True, noise_map=True, signal_to_noise_map=True, model_image=True, residual_map=True, normalized_residual_map=True, chi_squared_map=True, ) assert path.join(plot_path, "image.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_image.png") in plot_patch.paths assert path.join(plot_path, "residual_map.png") in plot_patch.paths assert path.join(plot_path, "normalized_residual_map.png") in plot_patch.paths assert path.join(plot_path, "chi_squared_map.png") in plot_patch.paths plot_patch.paths = [] fit_imaging_plotter.figures( image=True, noise_map=False, signal_to_noise_map=False, model_image=True, chi_squared_map=True, ) assert path.join(plot_path, "image.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_image.png") in plot_patch.paths assert path.join(plot_path, "residual_map.png") not in plot_patch.paths assert path.join(plot_path, "normalized_residual_map.png") not in plot_patch.paths assert path.join(plot_path, "chi_squared_map.png") in plot_patch.paths