Skip to content

Commit 426116e

Browse files
committed
Critica curve and caustic plots now fully implemented.
1 parent 0ce14b4 commit 426116e

8 files changed

Lines changed: 123 additions & 102 deletions

File tree

autoarray/mask/geometry.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,17 @@ def arc_second_minima(self):
7070
(-(self.shape_2d_arcsec[1] / 2.0)) + self.mask.origin[1],
7171
)
7272

73+
@property
74+
def extent(self):
75+
return np.asarray(
76+
[
77+
self.arc_second_minima[1],
78+
self.arc_second_maxima[1],
79+
self.arc_second_minima[0],
80+
self.arc_second_maxima[0],
81+
]
82+
)
83+
7384
@property
7485
def yticks(self):
7586
"""Compute the yticks labels of this grid, used for plotting the y-axis ticks when visualizing an image-grid"""

autoarray/plotters/array_plotters.py

Lines changed: 18 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -165,13 +165,7 @@ def plot_array(
165165
)
166166

167167
array = array.in_1d_binned
168-
zoom_offset_pixels = np.asarray(array.geometry._zoom_offset_pixels)
169-
170-
if array.pixel_scales is None:
171-
zoom_offset_arcsec = (0.0, 0.0)
172-
else:
173-
zoom_offset_arcsec = np.asarray(array.geometry._zoom_offset_arcsec)
174-
168+
extent = array.extent_of_zoomed_array(buffer=1)
175169
array = array.zoomed_around_mask(buffer=1)
176170

177171
if aspect is "square":
@@ -180,6 +174,7 @@ def plot_array(
180174
fig = plot_figure(
181175
array=array,
182176
as_subplot=as_subplot,
177+
extent=extent,
183178
units=units,
184179
kpc_per_arcsec=kpc_per_arcsec,
185180
figsize=figsize,
@@ -215,14 +210,12 @@ def plot_array(
215210
include_origin=include_origin,
216211
units=units,
217212
kpc_per_arcsec=kpc_per_arcsec,
218-
zoom_offset_arcsec=zoom_offset_arcsec,
219213
)
220214
plot_mask(
221215
mask=mask,
222216
units=units,
223217
kpc_per_arcsec=kpc_per_arcsec,
224218
pointsize=mask_pointsize,
225-
zoom_offset_pixels=zoom_offset_pixels,
226219
)
227220
plotter_util.plot_lines(line_lists=lines)
228221
plot_border(
@@ -231,30 +224,26 @@ def plot_array(
231224
units=units,
232225
kpc_per_arcsec=kpc_per_arcsec,
233226
pointsize=border_pointsize,
234-
zoom_offset_arcsec=zoom_offset_arcsec,
235227
)
236228
plot_points(
237229
points_arcsec=positions,
238230
array=array,
239231
units=units,
240232
kpc_per_arcsec=kpc_per_arcsec,
241233
pointsize=position_pointsize,
242-
zoom_offset_arcsec=zoom_offset_arcsec,
243234
)
244235
plot_grid(
245236
grid_arcsec=grid,
246237
array=array,
247238
units=units,
248239
kpc_per_arcsec=kpc_per_arcsec,
249240
pointsize=grid_pointsize,
250-
zoom_offset_arcsec=zoom_offset_arcsec,
251241
)
252242
plot_centres(
253243
array=array,
254244
centres=centres,
255245
units=units,
256246
kpc_per_arcsec=kpc_per_arcsec,
257-
zoom_offset_arcsec=zoom_offset_arcsec,
258247
)
259248
plot_ellipses(
260249
fig=fig,
@@ -264,7 +253,6 @@ def plot_array(
264253
phis=phis,
265254
units=units,
266255
kpc_per_arcsec=kpc_per_arcsec,
267-
zoom_offset_arcsec=zoom_offset_arcsec,
268256
)
269257
plotter_util.output_figure(
270258
array,
@@ -279,6 +267,7 @@ def plot_array(
279267
def plot_figure(
280268
array,
281269
as_subplot,
270+
extent,
282271
units,
283272
kpc_per_arcsec,
284273
figsize,
@@ -345,6 +334,7 @@ def plot_figure(
345334

346335
extent = get_extent(
347336
array=array,
337+
extent=extent,
348338
units=units,
349339
kpc_per_arcsec=kpc_per_arcsec,
350340
xticks_manual=xticks_manual,
@@ -355,7 +345,7 @@ def plot_figure(
355345
return fig
356346

357347

358-
def get_extent(array, units, kpc_per_arcsec, xticks_manual, yticks_manual):
348+
def get_extent(array, extent, units, kpc_per_arcsec, xticks_manual, yticks_manual):
359349
"""Get the extent of the dimensions of the array in the units of the figure (e.g. arc-seconds or kpc).
360350
361351
This is used to set the extent of the array and thus the y / x axis limits.
@@ -381,26 +371,12 @@ def get_extent(array, units, kpc_per_arcsec, xticks_manual, yticks_manual):
381371
if units in "pixels":
382372
return np.asarray([0, array.shape_2d[1], 0, array.shape_2d[0]])
383373
elif units in "arcsec" or kpc_per_arcsec is None:
384-
return np.asarray(
385-
[
386-
array.mask.geometry.arc_second_minima[1],
387-
array.mask.geometry.arc_second_maxima[1],
388-
array.mask.geometry.arc_second_minima[0],
389-
array.mask.geometry.arc_second_maxima[0],
390-
]
391-
)
374+
return extent
392375
elif units in "kpc":
393376
return list(
394377
map(
395378
lambda tick: tick * kpc_per_arcsec,
396-
np.asarray(
397-
[
398-
array.mask.geometry.arc_second_minima[1],
399-
array.mask.geometry.arc_second_maxima[1],
400-
array.mask.geometry.arc_second_minima[0],
401-
array.mask.geometry.arc_second_maxima[0],
402-
]
403-
),
379+
extent,
404380
)
405381
)
406382
else:
@@ -548,7 +524,7 @@ def convert_grid_units(array, grid_arcsec, units, kpc_per_arcsec):
548524
)
549525

550526

551-
def plot_origin(array, include_origin, units, kpc_per_arcsec, zoom_offset_arcsec):
527+
def plot_origin(array, include_origin, units, kpc_per_arcsec):
552528
"""Plot the (y,x) origin ofo the array's coordinates as a 'x'.
553529
554530
Parameters
@@ -566,9 +542,6 @@ def plot_origin(array, include_origin, units, kpc_per_arcsec, zoom_offset_arcsec
566542

567543
origin_grid = np.asarray(array.origin)
568544

569-
if zoom_offset_arcsec is not None:
570-
origin_grid -= zoom_offset_arcsec
571-
572545
origin_units = convert_grid_units(
573546
array=array,
574547
grid_arcsec=origin_grid,
@@ -578,7 +551,7 @@ def plot_origin(array, include_origin, units, kpc_per_arcsec, zoom_offset_arcsec
578551
plt.scatter(y=origin_units[0], x=origin_units[1], s=80, c="k", marker="x")
579552

580553

581-
def plot_centres(array, centres, units, kpc_per_arcsec, zoom_offset_arcsec):
554+
def plot_centres(array, centres, units, kpc_per_arcsec):
582555
"""Plot the (y,x) centres (e.g. of a mass profile) on the array as an 'x'.
583556
584557
Parameters
@@ -600,9 +573,6 @@ def plot_centres(array, centres, units, kpc_per_arcsec, zoom_offset_arcsec):
600573
color = next(colors)
601574
for centre in centres_of_galaxy:
602575

603-
if zoom_offset_arcsec is not None:
604-
centre -= zoom_offset_arcsec
605-
606576
centre_units = convert_grid_units(
607577
array=array,
608578
grid_arcsec=centre,
@@ -615,7 +585,7 @@ def plot_centres(array, centres, units, kpc_per_arcsec, zoom_offset_arcsec):
615585

616586

617587
def plot_ellipses(
618-
fig, array, centres, axis_ratios, phis, units, kpc_per_arcsec, zoom_offset_arcsec
588+
fig, array, centres, axis_ratios, phis, units, kpc_per_arcsec,
619589
):
620590
"""Plot the (y,x) centres (e.g. of a mass profile) on the array as an 'x'.
621591
@@ -642,9 +612,6 @@ def plot_ellipses(
642612
axis_ratio = axis_ratios[set_index][geometry_index]
643613
phi = phis[set_index][geometry_index]
644614

645-
if zoom_offset_arcsec is not None:
646-
centre -= zoom_offset_arcsec
647-
648615
centre_units = convert_grid_units(
649616
array=array,
650617
grid_arcsec=centre,
@@ -663,7 +630,7 @@ def plot_ellipses(
663630
)
664631

665632

666-
def plot_mask(mask, units, kpc_per_arcsec, pointsize, zoom_offset_pixels):
633+
def plot_mask(mask, units, kpc_per_arcsec, pointsize):
667634
"""Plot the mask of the array on the figure.
668635
669636
Parameters
@@ -686,13 +653,8 @@ def plot_mask(mask, units, kpc_per_arcsec, pointsize, zoom_offset_pixels):
686653
+ 0.5
687654
)
688655

689-
if zoom_offset_pixels is not None:
690-
edge_pixels_plot = edge_pixels - zoom_offset_pixels
691-
else:
692-
edge_pixels_plot = edge_pixels
693-
694656
edge_arcsec = mask.geometry.grid_arcsec_from_grid_pixels_1d(
695-
grid_pixels_1d=edge_pixels_plot
657+
grid_pixels_1d=edge_pixels
696658
)
697659
edge_units = convert_grid_units(
698660
array=mask,
@@ -710,7 +672,7 @@ def plot_mask(mask, units, kpc_per_arcsec, pointsize, zoom_offset_pixels):
710672

711673

712674
def plot_border(
713-
mask, include_border, units, kpc_per_arcsec, pointsize, zoom_offset_arcsec
675+
mask, include_border, units, kpc_per_arcsec, pointsize,
714676
):
715677
"""Plot the borders of the mask or the array on the figure.
716678
@@ -732,14 +694,9 @@ def plot_border(
732694
plt.gca()
733695
border_grid = mask.geometry.border_grid.in_1d_binned
734696

735-
if zoom_offset_arcsec is not None:
736-
border_grid_plot = border_grid - zoom_offset_arcsec.astype("int")
737-
else:
738-
border_grid_plot = border_grid
739-
740697
border_units = convert_grid_units(
741698
array=mask,
742-
grid_arcsec=border_grid_plot,
699+
grid_arcsec=border_grid,
743700
units=units,
744701
kpc_per_arcsec=kpc_per_arcsec,
745702
)
@@ -748,7 +705,7 @@ def plot_border(
748705

749706

750707
def plot_points(
751-
points_arcsec, array, units, kpc_per_arcsec, pointsize, zoom_offset_arcsec
708+
points_arcsec, array, units, kpc_per_arcsec, pointsize,
752709
):
753710
"""Plot a set of points over the array of data_type on the figure.
754711
@@ -774,14 +731,9 @@ def plot_points(
774731
point_colors = itertools.cycle(["m", "y", "r", "w", "c", "b", "g", "k"])
775732
for point_set_arcsec in points_arcsec:
776733

777-
if zoom_offset_arcsec is not None:
778-
point_set_arcsec_plot = point_set_arcsec - zoom_offset_arcsec
779-
else:
780-
point_set_arcsec_plot = point_set_arcsec
781-
782734
point_set_units = convert_grid_units(
783735
array=array,
784-
grid_arcsec=point_set_arcsec_plot,
736+
grid_arcsec=point_set_arcsec,
785737
units=units,
786738
kpc_per_arcsec=kpc_per_arcsec,
787739
)
@@ -793,7 +745,7 @@ def plot_points(
793745
)
794746

795747

796-
def plot_grid(grid_arcsec, array, units, kpc_per_arcsec, pointsize, zoom_offset_arcsec):
748+
def plot_grid(grid_arcsec, array, units, kpc_per_arcsec, pointsize):
797749
"""Plot a grid of points over the array of data_type on the figure.
798750
799751
Parameters
@@ -811,13 +763,8 @@ def plot_grid(grid_arcsec, array, units, kpc_per_arcsec, pointsize, zoom_offset_
811763
"""
812764
if grid_arcsec is not None:
813765

814-
if zoom_offset_arcsec is not None:
815-
grid_arcsec_plot = grid_arcsec - zoom_offset_arcsec
816-
else:
817-
grid_arcsec_plot = grid_arcsec
818-
819766
grid_units = convert_grid_units(
820-
grid_arcsec=grid_arcsec_plot,
767+
grid_arcsec=grid_arcsec,
821768
array=array,
822769
units=units,
823770
kpc_per_arcsec=kpc_per_arcsec,

0 commit comments

Comments
 (0)