def test__figures_1d__all_are_output(gal_x1_lp_x1_mp, sub_grid_2d_7x7, mask_2d_7x7, include_1d_all, plot_path, plot_patch): galaxy_plotter = aplt.GalaxyPlotter( galaxy=gal_x1_lp_x1_mp, grid=sub_grid_2d_7x7, include_1d=include_1d_all, mat_plot_1d=aplt.MatPlot1D( output=aplt.Output(plot_path, format="png")), ) galaxy_plotter.figures_1d(image=True, convergence=True, potential=True) assert path.join(plot_path, "image_1d.png") in plot_patch.paths assert path.join(plot_path, "convergence_1d.png") in plot_patch.paths assert path.join(plot_path, "potential_1d.png") in plot_patch.paths plot_patch.paths = [] galaxy_plotter = aplt.GalaxyPDFPlotter( galaxy_pdf_list=[gal_x1_lp_x1_mp, gal_x1_lp_x1_mp, gal_x1_lp_x1_mp], grid=sub_grid_2d_7x7, include_1d=include_1d_all, mat_plot_1d=aplt.MatPlot1D( output=aplt.Output(plot_path, format="png")), ) galaxy_plotter.figures_1d(image=True, convergence=True, potential=True) assert path.join(plot_path, "image_1d.png") in plot_patch.paths assert path.join(plot_path, "convergence_1d.png") in plot_patch.paths assert path.join(plot_path, "potential_1d.png") in plot_patch.paths
def test__fit_sub_plot__all_types_of_fit( fit_quantity_7x7_array_2d, fit_quantity_7x7_vector_yx_2d, include_2d_all, plot_patch, plot_path, ): fit_quantity_plotter = aplt.FitQuantityPlotter( fit=fit_quantity_7x7_array_2d, mat_plot_2d=aplt.MatPlot2D( output=aplt.Output(path=plot_path, format="png")), ) fit_quantity_plotter.subplot_fit_quantity() assert path.join(plot_path, "subplot_fit_quantity.png") in plot_patch.paths fit_quantity_plotter = aplt.FitQuantityPlotter( fit=fit_quantity_7x7_vector_yx_2d, mat_plot_2d=aplt.MatPlot2D( output=aplt.Output(path=plot_path, format="png")), ) fit_quantity_plotter.subplot_fit_quantity() print(plot_patch.paths) assert path.join(plot_path, "subplot_fit_quantity_y.png") in plot_patch.paths assert path.join(plot_path, "subplot_fit_quantity_x.png") in plot_patch.paths
def test__fit_sub_plot_real_space( fit_interferometer_7x7, fit_interferometer_x2_galaxy_inversion_7x7, include_2d_all, plot_path, plot_patch, ): fit_interferometer_plotter = aplt.FitInterferometerPlotter( fit=fit_interferometer_7x7, include_2d=include_2d_all, 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_galaxy_inversion_7x7, include_2d=include_2d_all, 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__fit_sub_plot__all_types_of_galaxy_fit( gal_fit_7x7_image, gal_fit_7x7_convergence, gal_fit_7x7_potential, gal_fit_7x7_deflections_y, gal_fit_7x7_deflections_x, include_2d_all, plot_patch, plot_path, ): fit_galaxy_plotter = aplt.FitGalaxyPlotter( fit=gal_fit_7x7_image, mat_plot_2d=aplt.MatPlot2D( output=aplt.Output(path=plot_path, format="png")), ) fit_galaxy_plotter.subplot_fit_galaxy() assert path.join(plot_path, "subplot_fit_galaxy.png") in plot_patch.paths fit_galaxy_plotter = aplt.FitGalaxyPlotter( fit=gal_fit_7x7_convergence, mat_plot_2d=aplt.MatPlot2D( output=aplt.Output(path=plot_path, format="png")), ) fit_galaxy_plotter.subplot_fit_galaxy() assert path.join(plot_path, "subplot_fit_galaxy.png") in plot_patch.paths fit_galaxy_plotter = aplt.FitGalaxyPlotter( fit=gal_fit_7x7_potential, mat_plot_2d=aplt.MatPlot2D( output=aplt.Output(path=plot_path, format="png")), ) fit_galaxy_plotter.subplot_fit_galaxy() assert path.join(plot_path, "subplot_fit_galaxy.png") in plot_patch.paths fit_galaxy_plotter = aplt.FitGalaxyPlotter( fit=gal_fit_7x7_deflections_y, mat_plot_2d=aplt.MatPlot2D( output=aplt.Output(path=plot_path, format="png")), ) fit_galaxy_plotter.subplot_fit_galaxy() assert path.join(plot_path, "subplot_fit_galaxy.png") in plot_patch.paths fit_galaxy_plotter = aplt.FitGalaxyPlotter( fit=gal_fit_7x7_deflections_x, mat_plot_2d=aplt.MatPlot2D( output=aplt.Output(path=plot_path, format="png")), ) fit_galaxy_plotter.subplot_fit_galaxy() assert path.join(plot_path, "subplot_fit_galaxy.png") in plot_patch.paths
def test__all_individual_plotter__output_file_with_default_name( plane_7x7, sub_grid_2d_7x7, mask_2d_7x7, grid_2d_irregular_7x7_list, include_2d_all, plot_path, plot_patch, ): plane_plotter = aplt.PlanePlotter( plane=plane_7x7, grid=sub_grid_2d_7x7, include_2d=include_2d_all, mat_plot_2d=aplt.MatPlot2D( output=aplt.Output(plot_path, format="png")), ) plane_plotter.figures_2d(image=True, plane_image=True, plane_grid=True) assert path.join(plot_path, "image_2d.png") in plot_patch.paths assert path.join(plot_path, "plane_image.png") in plot_patch.paths assert path.join(plot_path, "plane_grid.png") in plot_patch.paths plane_7x7.galaxies[0].hyper_galaxy = ag.HyperGalaxy() plane_7x7.galaxies[0].hyper_model_image = ag.Array2D.ones(shape_native=(7, 7), pixel_scales=0.1) plane_7x7.galaxies[0].hyper_galaxy_image = ag.Array2D.ones( shape_native=(7, 7), pixel_scales=0.1) plane_plotter.figures_2d(contribution_map=True) assert path.join(plot_path, "contribution_map_2d.png") in plot_patch.paths
def test__subplots_galaxy_quantities__all_are_output( gal_x1_lp_x1_mp, sub_grid_2d_7x7, grid_2d_irregular_7x7_list, include_2d_all, plot_path, plot_patch, ): galaxy_plotter = aplt.GalaxyPlotter( galaxy=gal_x1_lp_x1_mp, grid=sub_grid_2d_7x7, include_2d=include_2d_all, mat_plot_2d=aplt.MatPlot2D( output=aplt.Output(plot_path, format="png")), ) galaxy_plotter.subplot_of_light_profiles(image=True) assert path.join(plot_path, "subplot_image.png") in plot_patch.paths galaxy_plotter.subplot_of_mass_profiles(convergence=True, potential=True, deflections_y=True, deflections_x=True) assert path.join(plot_path, "subplot_convergence.png") in plot_patch.paths assert path.join(plot_path, "subplot_potential.png") in plot_patch.paths assert path.join(plot_path, "subplot_deflections_y.png") in plot_patch.paths assert path.join(plot_path, "subplot_deflections_x.png") in plot_patch.paths
def test__figures_2d__all_are_output( gal_x1_lp_x1_mp, sub_grid_2d_7x7, mask_2d_7x7, grid_2d_irregular_7x7_list, include_2d_all, plot_path, plot_patch, ): galaxy_plotter = aplt.GalaxyPlotter( galaxy=gal_x1_lp_x1_mp, grid=sub_grid_2d_7x7, include_2d=include_2d_all, mat_plot_2d=aplt.MatPlot2D( output=aplt.Output(plot_path, format="png")), ) galaxy_plotter.figures_2d(image=True, convergence=True) assert path.join(plot_path, "image_2d.png") in plot_patch.paths assert path.join(plot_path, "convergence_2d.png") in plot_patch.paths gal_x1_lp_x1_mp.hyper_galaxy = ag.HyperGalaxy() gal_x1_lp_x1_mp.hyper_model_image = ag.Array2D.ones(shape_native=(7, 7), pixel_scales=0.1) gal_x1_lp_x1_mp.hyper_galaxy_image = ag.Array2D.ones(shape_native=(7, 7), pixel_scales=0.1) galaxy_plotter.figures_2d(contribution_map=True) assert path.join(plot_path, "contribution_map_2d.png") in plot_patch.paths
def test__figures_1d__all_are_output( mp_0, sub_grid_2d_7x7, grid_2d_irregular_7x7_list, include_1d_all, plot_path, plot_patch, ): mat_plot_1d = aplt.MatPlot1D( half_light_radius_axvline=aplt.HalfLightRadiusAXVLine(color="r"), einstein_radius_axvline=aplt.EinsteinRadiusAXVLine(color="r"), output=aplt.Output(plot_path, format="png"), ) mass_profile_plotter = aplt.MassProfilePlotter( mass_profile=mp_0, grid=sub_grid_2d_7x7, include_1d=include_1d_all, mat_plot_1d=mat_plot_1d, ) mass_profile_plotter.figures_1d(convergence=True, potential=True) assert path.join(plot_path, "convergence_1d.png") in plot_patch.paths assert path.join(plot_path, "potential_1d.png") in plot_patch.paths
def test__figures_2d__all_are_output( mp_0, sub_grid_2d_7x7, grid_2d_irregular_7x7_list, include_2d_all, plot_path, plot_patch, ): mass_profile_plotter = aplt.MassProfilePlotter( mass_profile=mp_0, grid=sub_grid_2d_7x7, include_2d=include_2d_all, mat_plot_2d=aplt.MatPlot2D( output=aplt.Output(plot_path, format="png")), ) mass_profile_plotter.figures_2d( convergence=True, potential=True, deflections_y=True, deflections_x=True, magnification=True, ) assert path.join(plot_path, "convergence_2d.png") in plot_patch.paths assert path.join(plot_path, "potential_2d.png") in plot_patch.paths assert path.join(plot_path, "deflections_y_2d.png") in plot_patch.paths assert path.join(plot_path, "deflections_x_2d.png") in plot_patch.paths assert path.join(plot_path, "magnification_2d.png") in plot_patch.paths
def test__figures_1d__all_are_output( lp_0, sub_grid_2d_7x7, grid_2d_irregular_7x7_list, include_1d_all, plot_path, plot_patch, ): mat_plot_1d = aplt.MatPlot1D( half_light_radius_axvline=aplt.HalfLightRadiusAXVLine(color="r"), einstein_radius_axvline=aplt.EinsteinRadiusAXVLine(color="r"), output=aplt.Output(plot_path, format="png"), ) light_profile_plotter = aplt.LightProfilePlotter( light_profile=lp_0, grid=sub_grid_2d_7x7, include_1d=include_1d_all, mat_plot_1d=mat_plot_1d, ) light_profile_plotter.figures_1d(image=True) assert path.join(plot_path, "image_1d.png") in plot_patch.paths
def test__fit_individuals__source_and_galaxy__dependent_on_input( fit_imaging_x2_galaxy_7x7, include_2d_all, plot_path, plot_patch): fit_imaging_plotter = aplt.FitImagingPlotter( fit=fit_imaging_x2_galaxy_7x7, include_2d=include_2d_all, mat_plot_2d=aplt.MatPlot2D( output=aplt.Output(plot_path, format="png")), ) fit_imaging_plotter.figures_2d( image=True, noise_map=False, signal_to_noise_map=False, model_image=True, chi_squared_map=True, ) assert path.join(plot_path, "image_2d.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
def test__plot_contribution_map_list( contribution_map_7x7, mask_2d_7x7, include_2d_all, plot_path, plot_patch ): hyper_plotter = aplt.HyperPlotter( include_2d=include_2d_all, mat_plot_2d=aplt.MatPlot2D(output=aplt.Output(plot_path, format="png")), ) hyper_plotter.subplot_contribution_map_list( contribution_map_list_list=[contribution_map_7x7, contribution_map_7x7, None] ) assert path.join(plot_path, "subplot_contribution_map_list.png") in plot_patch.paths
def test__plot_hyper_images_of_galaxies(hyper_galaxy_image_path_dict_7x7, mask_2d_7x7, include_2d_all, plot_path, plot_patch): hyper_plotter = aplt.HyperPlotter( include_2d=include_2d_all, mat_plot_2d=aplt.MatPlot2D( output=aplt.Output(plot_path, format="png")), ) hyper_plotter.subplot_hyper_images_of_galaxies( hyper_galaxy_image_path_dict=hyper_galaxy_image_path_dict_7x7) assert (path.join(plot_path, "subplot_hyper_images_of_galaxies.png") in plot_patch.paths)
def test__figures_1d_decomposed__all_are_output(gal_x1_lp_x1_mp, sub_grid_2d_7x7, mask_2d_7x7, include_1d_all, plot_path, plot_patch): galaxy_plotter = aplt.GalaxyPlotter( galaxy=gal_x1_lp_x1_mp, grid=sub_grid_2d_7x7, include_1d=include_1d_all, mat_plot_1d=aplt.MatPlot1D( output=aplt.Output(plot_path, format="png")), ) galaxy_plotter.figures_1d_decomposed(convergence=True) # assert path.join(plot_path, "image_1d.png") in plot_patch.paths assert path.join(plot_path, "convergence_1d_decomposed.png") in plot_patch.paths
def test__figures_2d__all_are_output( lp_0, sub_grid_2d_7x7, grid_2d_irregular_7x7_list, include_2d_all, plot_path, plot_patch, ): light_profile_plotter = aplt.LightProfilePlotter( light_profile=lp_0, grid=sub_grid_2d_7x7, include_2d=include_2d_all, mat_plot_2d=aplt.MatPlot2D(output=aplt.Output(plot_path, format="png")), ) light_profile_plotter.figures_2d(image=True) assert path.join(plot_path, "image_2d.png") in plot_patch.paths
def test__subplot_of_galaxy(fit_imaging_x2_galaxy_7x7, include_2d_all, plot_path, plot_patch): fit_imaging_plotter = aplt.FitImagingPlotter( fit=fit_imaging_x2_galaxy_7x7, include_2d=include_2d_all, mat_plot_2d=aplt.MatPlot2D( output=aplt.Output(plot_path, format="png")), ) fit_imaging_plotter.subplots_of_galaxies() assert path.join(plot_path, "subplot_of_galaxy_0.png") in plot_patch.paths assert path.join(plot_path, "subplot_of_galaxy_1.png") in plot_patch.paths plot_patch.paths = [] fit_imaging_plotter.subplots_of_galaxies(galaxy_index=0) assert path.join(plot_path, "subplot_of_galaxy_0.png") in plot_patch.paths assert path.join(plot_path, "subplot_of_galaxy_1.png") not in plot_patch.paths
def test__plot_individual_images( hyper_galaxy_image_0_7x7, contribution_map_7x7, include_2d_all, plot_path, plot_patch, ): hyper_plotter = aplt.HyperPlotter( include_2d=include_2d_all, mat_plot_2d=aplt.MatPlot2D(output=aplt.Output(plot_path, format="png")), ) hyper_plotter.figure_hyper_galaxy_image(galaxy_image=hyper_galaxy_image_0_7x7) assert path.join(plot_path, "hyper_galaxy_image.png") in plot_patch.paths hyper_plotter.figure_contribution_map(contribution_map=contribution_map_7x7) assert path.join(plot_path, "contribution_map_2d.png") in plot_patch.paths
def test__figures_of_galaxies(fit_imaging_x2_galaxy_7x7, include_2d_all, plot_path, plot_patch): fit_imaging_plotter = aplt.FitImagingPlotter( fit=fit_imaging_x2_galaxy_7x7, include_2d=include_2d_all, mat_plot_2d=aplt.MatPlot2D( output=aplt.Output(plot_path, format="png")), ) fit_imaging_plotter.figures_2d_of_galaxies(subtracted_image=True) assert path.join(plot_path, "subtracted_image_of_galaxy_0.png") in plot_patch.paths assert path.join(plot_path, "subtracted_image_of_galaxy_1.png") in plot_patch.paths fit_imaging_plotter.figures_2d_of_galaxies(model_image=True) assert path.join(plot_path, "model_image_of_galaxy_0.png") in plot_patch.paths assert path.join(plot_path, "model_image_of_galaxy_1.png") in plot_patch.paths plot_patch.paths = [] fit_imaging_plotter.figures_2d_of_galaxies(subtracted_image=True, galaxy_index=0) assert path.join(plot_path, "subtracted_image_of_galaxy_0.png") in plot_patch.paths assert (path.join(plot_path, "subtracted_image_of_galaxy_1.png") not in plot_patch.paths) fit_imaging_plotter.figures_2d_of_galaxies(model_image=True, galaxy_index=1) assert path.join(plot_path, "model_image_of_galaxy_0.png") not in plot_patch.paths assert path.join(plot_path, "model_image_of_galaxy_1.png") in plot_patch.paths