def test__subplot_ci_lines__is_output(imaging_ci_7x7, plot_path, plot_patch): imaging_ci_plotter = aplt.ImagingCIPlotter( imaging=imaging_ci_7x7, mat_plot_2d=aplt.MatPlot2D( output=aplt.Output(plot_path, format="png")), mat_plot_1d=aplt.MatPlot1D( output=aplt.Output(plot_path, format="png")), ) imaging_ci_plotter.subplot_imaging_ci() assert path.join(plot_path, "subplot_imaging_ci.png") in plot_patch.paths imaging_ci_plotter.subplot_1d_ci_line_region( line_region="parallel_front_edge") assert (path.join(plot_path, "subplot_1d_ci_parallel_front_edge.png") in plot_patch.paths)
def visualize_imaging_ci_lines(self, imaging_ci, line_region): def should_plot(name): return plot_setting(section="dataset", name=name) mat_plot_1d = self.mat_plot_1d_from(subfolders=f"imaging_ci") imaging_ci_plotter = aplt.ImagingCIPlotter( imaging=imaging_ci, mat_plot_1d=mat_plot_1d, include_2d=self.include_2d ) if should_plot("subplot_dataset"): imaging_ci_plotter.subplot_1d_ci_line_region(line_region=line_region) imaging_ci_plotter.figures_1d_ci_line_region( line_region=line_region, image=should_plot("data"), noise_map=should_plot("noise_map"), signal_to_noise_map=should_plot("signal_to_noise_map"), pre_cti_data=should_plot("pre_cti_data"), )
def test__individual_lines_are_output(imaging_ci_7x7, plot_path, plot_patch): imaging_ci_plotter = aplt.ImagingCIPlotter( imaging=imaging_ci_7x7, mat_plot_1d=aplt.MatPlot1D( output=aplt.Output(plot_path, format="png")), ) imaging_ci_plotter.figures_1d_ci_line_region( line_region="parallel_front_edge", image=True, noise_map=True, pre_cti_data=True, signal_to_noise_map=True, ) assert path.join(plot_path, "image_parallel_front_edge.png") in plot_patch.paths assert path.join(plot_path, "noise_map_parallel_front_edge.png") in plot_patch.paths assert (path.join(plot_path, "pre_cti_data_parallel_front_edge.png") in plot_patch.paths) assert (path.join(plot_path, "signal_to_noise_map_parallel_front_edge.png") in plot_patch.paths) plot_patch.paths = [] imaging_ci_plotter.figures_1d_ci_line_region( line_region="parallel_front_edge", image=True, pre_cti_data=True) assert path.join(plot_path, "image_parallel_front_edge.png") in plot_patch.paths assert (path.join(plot_path, "noise_map_parallel_front_edge.png") not in plot_patch.paths) assert (path.join(plot_path, "pre_cti_data_parallel_front_edge.png") in plot_patch.paths) assert (path.join(plot_path, "signal_to_noise_map_parallel_front_edge.png") not in plot_patch.paths)
def test__individual_attributes_are_output(imaging_ci_7x7, plot_path, plot_patch): imaging_ci_plotter = aplt.ImagingCIPlotter( imaging=imaging_ci_7x7, mat_plot_2d=aplt.MatPlot2D( output=aplt.Output(plot_path, format="png")), mat_plot_1d=aplt.MatPlot1D( output=aplt.Output(plot_path, format="png")), ) imaging_ci_7x7.cosmic_ray_map[0, 0] = 1.0 imaging_ci_plotter.figures_2d( image=True, noise_map=True, pre_cti_data=True, signal_to_noise_map=True, cosmic_ray_map=True, ) assert path.join(plot_path, "image_2d.png") in plot_patch.paths assert path.join(plot_path, "noise_map.png") in plot_patch.paths assert path.join(plot_path, "pre_cti_data.png") in plot_patch.paths assert path.join(plot_path, "signal_to_noise_map.png") in plot_patch.paths assert path.join(plot_path, "cosmic_ray_map.png") in plot_patch.paths plot_patch.paths = [] imaging_ci_plotter.figures_2d(image=True, pre_cti_data=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, "pre_cti_data.png") in plot_patch.paths assert path.join(plot_path, "signal_to_noise_map.png") not in plot_patch.paths
def visualize_imaging_ci(self, imaging_ci): def should_plot(name): return plot_setting(section="dataset", name=name) mat_plot_2d = self.mat_plot_2d_from(subfolders=f"imaging_ci") imaging_ci_plotter = aplt.ImagingCIPlotter( imaging=imaging_ci, mat_plot_2d=mat_plot_2d, include_2d=self.include_2d ) imaging_ci_plotter.figures_2d( image=should_plot("data"), noise_map=should_plot("noise_map"), inverse_noise_map=should_plot("inverse_noise_map"), signal_to_noise_map=should_plot("signal_to_noise_map"), absolute_signal_to_noise_map=should_plot("absolute_signal_to_noise_map"), potential_chi_squared_map=should_plot("potential_chi_squared_map"), pre_cti_data=should_plot("pre_cti_data"), cosmic_ray_map=should_plot("cosmic_ray_map"), ) if should_plot("subplot_dataset"): imaging_ci_plotter.subplot_imaging_ci()
simulator.from_layout( clocker=clocker, layout=layout_ci, serial_trap_list=[serial_trap_0, serial_trap_1, serial_trap_2], serial_ccd=serial_ccd, ) for layout_ci in layout_list ] """ __Output__ Output a subplot of the simulated dataset to the dataset path as .png files. """ mat_plot_2d = aplt.MatPlot2D( output=aplt.Output(path=dataset_path, format="png")) imaging_ci_plotter = aplt.ImagingCIPlotter(imaging=imaging_ci_list[0], mat_plot_2d=mat_plot_2d) imaging_ci_plotter.subplot_imaging_ci() """ Output the image, noise-map and pre cti image of the charge injection dataset to .fits files. """ [ imaging_ci.output_to_fits( image_path=path.join( dataset_path, f"image_{int(imaging_ci.layout.normalization)}.fits"), noise_map_path=path.join( dataset_path, f"noise_map_{int(imaging_ci.layout.normalization)}.fits"), pre_cti_data_path=path.join( dataset_path, f"pre_cti_data_{int(imaging_ci.layout.normalization)}.fits"),
noise_map_path=path.join( dataset_path, f"noise_map_{layout.normalization}.fits" ), pre_cti_data_path=path.join( dataset_path, f"pre_cti_data_{layout.normalization}.fits" ), layout=layout, pixel_scales=0.1, ) for layout in layout_list ] """ Lets plot the first `ImagingCI`. """ imaging_ci_plotter = aplt.ImagingCIPlotter(imaging=imaging_ci_list[0]) imaging_ci_plotter.subplot_imaging_ci() """ __Clocking__ The `Clocker` models the CCD read-out, including CTI. For parallel clocking, we use 'charge injection mode' which transfers the charge of every pixel over the full CCD. """ clocker = ac.Clocker2D(parallel_express=2, parallel_charge_injection_mode=True) """ __Model__ We now compose our CTI model, which represents the trap species and CCD volume filling behaviour used to fit the charge
dataset_path, f"noise_map_{pattern.normalization}.fits" ), pre_cti_data_path=path.join( dataset_path, f"pre_cti_data_{pattern.normalization}.fits" ), pixel_scales=0.1, layout=pattern, roe_corner=(1, 0), ) for pattern in line_pattern_list ] """ Lets plot the first `DatasetLine` with its `Mask1D` """ imaging_ci_plotter = aplt.ImagingCIPlotter(imaging=line_list[0]) imaging_ci_plotter.subplot_imaging_ci() """ We now need to mask the data, so that regions where there is no signal (e.g. the edges) are omitted from the fit. """ mask_list = [ ac.Mask2D.unmasked(shape_native=line.shape_native, pixel_scales=line.pixel_scales) for line in line_list ] """ The MaskedImaging object combines the dataset with the mask. """ masked_line_list = [ ac.ci.ImagingCI(imaging_ci=line, mask=mask)
f"image_{layout.normalization}.fits"), noise_map_path=path.join(dataset_path, f"noise_map_{layout.normalization}.fits"), pre_cti_data_path=path.join( dataset_path, f"pre_cti_data_{layout.normalization}.fits"), layout=layout, pixel_scales=0.1, ) for layout in layout_list ] """ __Plotting__ We now pass the first dataset in the imaging to a `ImagingCIPlotter` and call various `figure_*` methods to plot different attributes. """ imaging_ci_plotter = aplt.ImagingCIPlotter(imaging=imaging_ci_list[0]) imaging_ci_plotter.figures_2d( image=True, noise_map=True, pre_cti_data=True, inverse_noise_map=True, potential_chi_squared_map=True, absolute_signal_to_noise_map=True, ) """ The `ImagingCIPlotter` may also plot a subplot of all of these attributes. """ imaging_ci_plotter.subplot_imaging_ci() """ We can also call `figures_1d_*` methods which create 1D plots of regions of the image binned over the parallel or serial direction.