Skip to content

Commit 59d9280

Browse files
Jammy2211Jammy2211
authored andcommitted
mix in with Sams code
2 parents 4f7f40a + 50fcfef commit 59d9280

7 files changed

Lines changed: 84 additions & 5 deletions

File tree

autogalaxy/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
from .ellipse.dataset_interp import DatasetInterp
6060
from .ellipse.ellipse.ellipse import Ellipse
6161
from .ellipse.ellipse.ellipse_multipole import EllipseMultipole
62+
from .ellipse.ellipse.ellipse_multipole import EllipseMultipoleRelative
6263
from .ellipse.fit_ellipse import FitEllipse
6364
from .ellipse.model.analysis import AnalysisEllipse
6465
from .operate.image import OperateImage

autogalaxy/config/notation.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ label:
2020
ell_comps_1: \epsilon_{\rm 2}
2121
multipole_comps_0: M_{\rm 1}
2222
multipole_comps_1: M_{\rm 2}
23+
input_multipole_comps_0: M_{\rm 1}
24+
input_multipole_comps_1: M_{\rm 2}
2325
flux: F
2426
gamma: \gamma
2527
gamma_1: \gamma
@@ -96,6 +98,8 @@ label_format:
9698
ell_comps_1: '{:.4f}'
9799
multipole_comps_0: '{:.4f}'
98100
multipole_comps_1: '{:.4f}'
101+
input_multipole_comps_0: '{:.4f}'
102+
input_multipole_comps_1: '{:.4f}'
99103
flux: '{:.4e}'
100104
gamma: '{:.4f}'
101105
inner_coefficient: '{:.4f}'

autogalaxy/config/priors/ellipse/ellipse_multipole.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,25 @@ EllipseMultipole:
1919
gaussian_limits:
2020
lower: -inf
2121
upper: inf
22+
23+
EllipseMultipoleRelative:
24+
input_multipole_comps_0:
25+
type: Uniform
26+
lower_limit: -0.1
27+
upper_limit: 0.1
28+
width_modifier:
29+
type: Absolute
30+
value: 0.05
31+
gaussian_limits:
32+
lower: -inf
33+
upper: inf
34+
input_multipole_comps_1:
35+
type: Uniform
36+
lower_limit: -0.1
37+
upper_limit: 0.1
38+
width_modifier:
39+
type: Absolute
40+
value: 0.05
41+
gaussian_limits:
42+
lower: -inf
43+
upper: inf

autogalaxy/ellipse/ellipse/ellipse_multipole.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import numpy as np
22
from typing import Tuple
3+
from autogalaxy.convert import multipole_comps_from, multipole_k_m_and_phi_m_from
34

45

56
from autogalaxy.ellipse.ellipse.ellipse import Ellipse
@@ -72,3 +73,57 @@ def points_perturbed_from(
7273
y = points[:, 0] + radial * np.sin(theta)
7374

7475
return np.stack((y, x), axis=-1)
76+
77+
class EllipseMultipoleRelative(EllipseMultipole):
78+
def __init__(
79+
self,
80+
m=4,
81+
input_multipole_comps: Tuple[float, float] = (0.0, 0.0),
82+
major_axis=1.,
83+
):
84+
self.input_multipole_comps = input_multipole_comps
85+
k, phi = multipole_k_m_and_phi_m_from(multipole_comps=input_multipole_comps, m=m)
86+
k_adjusted = k*major_axis
87+
88+
adjusted_multipole_comps = multipole_comps_from(k_adjusted, phi, m)
89+
90+
super().__init__(m, adjusted_multipole_comps)
91+
92+
self.adjusted_multipole_comps = adjusted_multipole_comps
93+
self.m = m
94+
95+
def points_perturbed_from(
96+
self, pixel_scale, points, ellipse: Ellipse, n_i: int = 0
97+
) -> np.ndarray:
98+
"""
99+
Returns the (y,x) coordinates of the input points, which are perturbed by the multipole of the ellipse.
100+
101+
Parameters
102+
----------
103+
pixel_scale
104+
The pixel scale of the data that the ellipse is fitted to and interpolated over.
105+
points
106+
The (y,x) coordinates of the ellipse that are perturbed by the multipole.
107+
ellipse
108+
The ellipse that is perturbed by the multipole, which is used to compute the angles of the ellipse.
109+
110+
Returns
111+
-------
112+
The (y,x) coordinates of the input points, which are perturbed by the multipole.
113+
"""
114+
115+
# 1) compute cartesian (polar) angle
116+
theta = np.arctan2(points[:,0], points[:,1]) # <- true polar angle
117+
118+
# 2) multipole in that same frame
119+
delta_theta = self.m * (theta - ellipse.angle_radians)
120+
radial = (
121+
self.adjusted_multipole_comps[1] * np.cos(delta_theta)
122+
+ self.adjusted_multipole_comps[0] * np.sin(delta_theta)
123+
)
124+
125+
# 3) perturb along the true radial direction
126+
x = points[:, 1] + radial * np.cos(theta)
127+
y = points[:, 0] + radial * np.sin(theta)
128+
129+
return np.stack((y, x), axis=-1)

autogalaxy/ellipse/plot/fit_ellipse_plotters.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ def subplot_fit_ellipse(self):
131131

132132
self.open_subplot_figure(number_subplots=2)
133133

134+
self.mat_plot_2d.use_log10 = True
134135
self.figures_2d(data=True)
135136
self.figures_2d(ellipse_residuals=True, for_subplot=True)
136137

@@ -237,7 +238,7 @@ def subplot_ellipse_errors(self):
237238
visuals_2d=visuals_2d,
238239
auto_labels=aplt.AutoLabels(
239240
title=f"Ellipse Fit",
240-
filename=f"subhplot_ellipse_errors",
241+
filename=f"subplot_ellipse_errors",
241242
),
242243
)
243244

autogalaxy/plot/mat_plot/two_d.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ def __init__(
2525
output: Optional[aplt.Output] = None,
2626
array_overlay: Optional[aplt.ArrayOverlay] = None,
2727
contour: Optional[aplt.Contour] = None,
28-
fill: Optional[aplt.Fill] = None,
2928
grid_scatter: Optional[aplt.GridScatter] = None,
3029
grid_plot: Optional[aplt.GridPlot] = None,
3130
vector_yx_quiver: Optional[aplt.VectorYXQuiver] = None,
@@ -194,7 +193,6 @@ def __init__(
194193
xlabel=xlabel,
195194
text=text,
196195
annotate=annotate,
197-
fill=fill,
198196
output=output,
199197
origin_scatter=origin_scatter,
200198
mask_scatter=mask_scatter,

autogalaxy/plot/visuals/two_d.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ def __init__(
1717
mesh_grid: aa.Grid2D = None,
1818
vectors: aa.VectorYX2DIrregular = None,
1919
patches: Union[ptch.Patch] = None,
20-
fill_region: Optional[List] = None,
2120
array_overlay: aa.Array2D = None,
2221
light_profile_centres: aa.Grid2DIrregular = None,
2322
mass_profile_centres: aa.Grid2DIrregular = None,
@@ -48,7 +47,6 @@ def __init__(
4847
mesh_grid=mesh_grid,
4948
vectors=vectors,
5049
patches=patches,
51-
fill_region=fill_region,
5250
array_overlay=array_overlay,
5351
origin=origin,
5452
border=border,

0 commit comments

Comments
 (0)