|
| 1 | +import ast |
| 2 | +import numpy as np |
| 3 | + |
| 4 | +from autoconf import conf |
1 | 5 | from autoconf.fitsable import hdu_list_for_output_from |
2 | 6 |
|
3 | 7 | import autoarray as aa |
| 8 | +import autogalaxy as ag |
4 | 9 | import autogalaxy.plot as aplt |
5 | 10 |
|
6 | 11 | from autogalaxy.analysis.plotter_interface import plot_setting |
@@ -86,11 +91,54 @@ def should_plot(name): |
86 | 91 | "deflections_y", |
87 | 92 | "deflections_x", |
88 | 93 | ], |
89 | | - header_dict=grid.mask.header_dict, |
| 94 | + header_dict=grid_zoom.mask.header_dict, |
90 | 95 | ) |
91 | 96 |
|
92 | 97 | hdu_list.writeto(self.image_path / "tracer.fits", overwrite=True) |
93 | 98 |
|
| 99 | + if should_plot("fits_source_plane_images"): |
| 100 | + |
| 101 | + shape_native = conf.instance["visualize"]["plots"]["tracer"][ |
| 102 | + "fits_source_plane_shape" |
| 103 | + ] |
| 104 | + shape_native = ast.literal_eval(shape_native) |
| 105 | + |
| 106 | + zoom = aa.Zoom2D(mask=grid.mask) |
| 107 | + mask = zoom.mask_2d_from(buffer=1) |
| 108 | + grid_source_plane = aa.Grid2D.from_extent( |
| 109 | + extent=mask.geometry.extent, shape_native=tuple(shape_native) |
| 110 | + ) |
| 111 | + |
| 112 | + print(grid_source_plane) |
| 113 | + |
| 114 | + image_list = [grid_source_plane.mask.astype("float")] |
| 115 | + ext_name_list = ["mask"] |
| 116 | + |
| 117 | + for i, plane in enumerate(tracer.planes[1:]): |
| 118 | + |
| 119 | + if plane.has(cls=ag.LightProfile): |
| 120 | + |
| 121 | + image = plane.image_2d_from( |
| 122 | + grid=grid_source_plane, |
| 123 | + ).native |
| 124 | + |
| 125 | + else: |
| 126 | + |
| 127 | + image = np.zeros(grid_source_plane.shape_native) |
| 128 | + |
| 129 | + image_list.append(image) |
| 130 | + ext_name_list.append(f"source_plane_image_{i+1}") |
| 131 | + |
| 132 | + hdu_list = hdu_list_for_output_from( |
| 133 | + values_list=image_list, |
| 134 | + ext_name_list=ext_name_list, |
| 135 | + header_dict=grid_source_plane.mask.header_dict, |
| 136 | + ) |
| 137 | + |
| 138 | + hdu_list.writeto( |
| 139 | + self.image_path / "source_plane_images.fits", overwrite=True |
| 140 | + ) |
| 141 | + |
94 | 142 | def image_with_positions(self, image: aa.Array2D, positions: aa.Grid2DIrregular): |
95 | 143 | """ |
96 | 144 | Visualizes the positions of a model-fit, where these positions are used to resample lens models where |
|
0 commit comments