Skip to content

Commit 03c4ce7

Browse files
Jammy2211Jammy2211
authored andcommitted
mnass profile plotter tests pass
1 parent a9f49f6 commit 03c4ce7

2 files changed

Lines changed: 44 additions & 25 deletions

File tree

autogalaxy/profiles/plot/light_profile_plotters.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,17 @@ def figures_1d(self, image: bool = False):
230230
plot_axis_type_override = None
231231

232232
if image:
233-
image_1d_list = [
234-
light_profile.image_2d_from(grid=self.grid_2d_projected)
235-
for light_profile in self.light_profile_pdf_list
236-
]
233+
234+
image_1d_list = []
235+
236+
for light_profile in self.light_profile_pdf_list:
237+
238+
grid = self.grid.grid_2d_radial_projected_from(
239+
centre=light_profile.centre,
240+
angle=light_profile.angle()
241+
)
242+
243+
image_1d_list.append(light_profile.image_2d_from(grid=grid))
237244

238245
min_index = min([image_1d.shape[0] for image_1d in image_1d_list])
239246
image_1d_list = [image_1d[0:min_index] for image_1d in image_1d_list]
@@ -256,7 +263,7 @@ def figures_1d(self, image: bool = False):
256263

257264
self.mat_plot_1d.plot_yx(
258265
y=median_image_1d,
259-
x=self.grid_2d_projected[:,1],
266+
x=grid[0:min_index,1],
260267
visuals_1d=visuals_1d,
261268
auto_labels=aplt.AutoLabels(
262269
title=r"Image ($\mathrm{e^{-}}\,\mathrm{s^{-1}}$) vs Radius (arcsec)",

autogalaxy/profiles/plot/mass_profile_plotters.py

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,13 @@ def __init__(
7171

7272
self.figures_2d = self._mass_plotter.figures_2d
7373

74+
@property
75+
def grid_2d_projected(self):
76+
return self.grid.grid_2d_radial_projected_from(
77+
centre=self.mass_profile.centre,
78+
angle=self.mass_profile.angle()
79+
)
80+
7481
def figures_1d(self, convergence: bool = False, potential: bool = False):
7582
"""
7683
Plots the individual attributes of the plotter's `MassProfile` object in 1D, which are computed via the
@@ -96,11 +103,11 @@ def figures_1d(self, convergence: bool = False, potential: bool = False):
96103
plot_axis_type_override = None
97104

98105
if convergence:
99-
convergence_1d = self.mass_profile.convergence_1d_from(grid=self.grid)
106+
convergence_1d = self.mass_profile.convergence_2d_from(grid=self.grid_2d_projected)
100107

101108
self.mat_plot_1d.plot_yx(
102109
y=convergence_1d,
103-
x=convergence_1d.grid_radial,
110+
x=self.grid_2d_projected[:,1],
104111
visuals_1d=self.visuals_1d,
105112
auto_labels=aplt.AutoLabels(
106113
title="Convergence vs Radius (arcsec)",
@@ -112,11 +119,11 @@ def figures_1d(self, convergence: bool = False, potential: bool = False):
112119
)
113120

114121
if potential:
115-
potential_1d = self.mass_profile.potential_1d_from(grid=self.grid)
122+
potential_1d = self.mass_profile.potential_2d_from(grid=self.grid_2d_projected)
116123

117124
self.mat_plot_1d.plot_yx(
118125
y=potential_1d,
119-
x=potential_1d.grid_radial,
126+
x=self.grid_2d_projected[:,1],
120127
visuals_1d=self.visuals_1d,
121128
auto_labels=aplt.AutoLabels(
122129
title="Potential vs Radius (arcsec)",
@@ -216,10 +223,17 @@ def figures_1d(self, convergence=False, potential=False):
216223
plot_axis_type_override = None
217224

218225
if convergence:
219-
convergence_1d_list = [
220-
mass_profile.convergence_1d_from(grid=self.grid)
221-
for mass_profile in self.mass_profile_pdf_list
222-
]
226+
227+
convergence_1d_list = []
228+
229+
for mass_profile in self.mass_profile_pdf_list:
230+
231+
grid = self.grid.grid_2d_radial_projected_from(
232+
centre=mass_profile.centre,
233+
angle=mass_profile.angle()
234+
)
235+
236+
convergence_1d_list.append(mass_profile.convergence_2d_from(grid=grid))
223237

224238
min_index = min(
225239
[convergence_1d.shape[0] for convergence_1d in convergence_1d_list]
@@ -248,7 +262,7 @@ def figures_1d(self, convergence=False, potential=False):
248262

249263
self.mat_plot_1d.plot_yx(
250264
y=median_convergence_1d,
251-
x=convergence_1d_list[0].grid_radial,
265+
x=grid[0:min_index,1],
252266
visuals_1d=visuals_1d,
253267
auto_labels=aplt.AutoLabels(
254268
title="Convergence vs Radius (arcsec)",
@@ -260,17 +274,15 @@ def figures_1d(self, convergence=False, potential=False):
260274
)
261275

262276
if potential:
263-
potential_1d_list = [
264-
mass_profile.potential_1d_from(grid=self.grid)
265-
for mass_profile in self.mass_profile_pdf_list
266-
]
277+
potential_1d_list = []
267278

268-
min_index = min(
269-
[potential_1d.shape[0] for potential_1d in potential_1d_list]
270-
)
271-
potential_1d_list = [
272-
potential_1d[0:min_index] for potential_1d in potential_1d_list
273-
]
279+
for mass_profile in self.mass_profile_pdf_list:
280+
grid = self.grid.grid_2d_radial_projected_from(
281+
centre=mass_profile.centre,
282+
angle=mass_profile.angle()
283+
)
284+
285+
potential_1d_list.append(mass_profile.potential_2d_from(grid=grid))
274286

275287
(
276288
median_potential_1d,
@@ -290,7 +302,7 @@ def figures_1d(self, convergence=False, potential=False):
290302

291303
self.mat_plot_1d.plot_yx(
292304
y=median_potential_1d,
293-
x=potential_1d_list[0].grid_radial,
305+
x=grid[0:min_index,1],
294306
visuals_1d=visuals_1d,
295307
auto_labels=aplt.AutoLabels(
296308
title="Potential vs Radius (arcsec)",

0 commit comments

Comments
 (0)