Skip to content

Commit 846ca38

Browse files
author
Hengkai_Pmo_StarB
committed
ShapeletPolar with q,phi convention
1 parent f589484 commit 846ca38

4 files changed

Lines changed: 35 additions & 392 deletions

File tree

autogalaxy/profiles/light/linear/shapelets/polar.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ def __init__(
1111
n: int,
1212
m: int,
1313
centre: Tuple[float, float] = (0.0, 0.0),
14-
ell_comps: Tuple[float, float] = (0.0, 0.0),
14+
q: float = 1.0,
15+
phi: float = 0.0,
1516
beta: float = 1.0,
1617
):
1718
"""
@@ -33,8 +34,11 @@ def __init__(
3334
The m order of the shapelets basis function in the x-direction.
3435
centre
3536
The (y,x) arc-second coordinates of the profile (shapelet) centre.
36-
ell_comps
37-
The first and second ellipticity components of the elliptical coordinate system.
37+
q
38+
The axis-ratio of the elliptical coordinate system, where a perfect circle has q=1.0.
39+
phi
40+
The position angle (in degrees) of the elliptical coordinate system, measured counter-clockwise from the
41+
positive x-axis.
3842
intensity
3943
Overall intensity normalisation of the light profile (units are dimensionless and derived from the data
4044
the light profile's image is compared too, which is expected to be electrons per second).
@@ -43,7 +47,7 @@ def __init__(
4347
"""
4448

4549
super().__init__(
46-
n=n, m=m, centre=centre, ell_comps=ell_comps, beta=beta, intensity=1.0
50+
n=n, m=m, centre=centre, q=q, phi=phi, beta=beta, intensity=1.0
4751
)
4852

4953

@@ -53,6 +57,7 @@ def __init__(
5357
n: int,
5458
m: int,
5559
centre: Tuple[float, float] = (0.0, 0.0),
60+
phi: float = 0.0,
5661
beta: float = 1.0,
5762
):
5863
"""
@@ -74,8 +79,11 @@ def __init__(
7479
The order of the shapelets basis function in the x-direction.
7580
centre
7681
The (y,x) arc-second coordinates of the profile (shapelet) centre.
82+
phi
83+
The position angle (in degrees) of the elliptical coordinate system, measured counter-clockwise from the
84+
positive x-axis.
7785
beta
7886
The characteristic length scale of the shapelet basis function, defined in arc-seconds.
7987
"""
8088

81-
super().__init__(n=n, m=m, centre=centre, ell_comps=(0.0, 0.0), beta=beta)
89+
super().__init__(n=n, m=m, centre=centre, q=1.0, phi=phi, beta=beta)

autogalaxy/profiles/light/linear/shapelets/polar_q_phi.py

Lines changed: 0 additions & 90 deletions
This file was deleted.

autogalaxy/profiles/light/standard/shapelets/polar.py

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from typing import Optional, Tuple
33

44
import autoarray as aa
5+
import autolens as al
56

67

78
from autogalaxy.profiles.light.decorators import (
@@ -126,7 +127,8 @@ def __init__(
126127
n: int,
127128
m: int,
128129
centre: Tuple[float, float] = (0.0, 0.0),
129-
ell_comps: Tuple[float, float] = (0.0, 0.0),
130+
q: float = 1.0,
131+
phi: float = 0.0,
130132
intensity: float = 1.0,
131133
beta: float = 1.0,
132134
):
@@ -149,8 +151,11 @@ def __init__(
149151
The m order of the shapelets basis function in the x-direction.
150152
centre
151153
The (y,x) arc-second coordinates of the profile (shapelet) centre.
152-
ell_comps
153-
The first and second ellipticity components of the elliptical coordinate system.
154+
q
155+
The axis-ratio of the elliptical coordinate system, where a perfect circle has q=1.0.
156+
phi
157+
The position angle (in degrees) of the elliptical coordinate system, measured counter-clockwise from the
158+
positive x-axis.
154159
intensity
155160
Overall intensity normalisation of the light profile (units are dimensionless and derived from the data
156161
the light profile's image is compared too, which is expected to be electrons per second).
@@ -160,9 +165,11 @@ def __init__(
160165

161166
self.n = int(n)
162167
self.m = int(m)
168+
self.phi = float(phi)
169+
self.q = float(q)
163170

164171
super().__init__(
165-
centre=centre, ell_comps=ell_comps, beta=beta, intensity=intensity
172+
centre=centre, beta=beta, intensity=intensity
166173
)
167174

168175
@property
@@ -172,7 +179,6 @@ def coefficient_tag(self) -> str:
172179
@aa.over_sample
173180
@aa.grid_dec.to_array
174181
@check_operated_only
175-
@aa.grid_dec.transform
176182
def image_2d_from(
177183
self,
178184
grid: aa.type.Grid2DLike,
@@ -200,7 +206,9 @@ def image_2d_from(
200206
from jax.scipy.special import factorial
201207

202208
# laguerre = genlaguerre(n=(self.n - xp.abs(self.m)) / 2.0, alpha=xp.abs(self.m))
203-
209+
grid = aa.util.geometry.transform_grid_2d_to_reference_frame(
210+
grid_2d=grid.array, centre=self.centre, angle=self.phi, xp=xp
211+
)
204212
const = (
205213
((-1) ** ((self.n - xp.abs(self.m)) // 2))
206214
* xp.sqrt(
@@ -210,8 +218,8 @@ def image_2d_from(
210218
/ self.beta
211219
/ xp.sqrt(xp.pi)
212220
)
213-
rsq = (grid.array[:, 0] ** 2 + (grid.array[:, 1]/self.axis_ratio(xp)) ** 2) / self.beta**2
214-
theta = xp.arctan2(grid.array[:, 1], grid.array[:, 0])
221+
rsq = (grid[:, 0] ** 2 + (grid[:, 1]/self.q) ** 2) / self.beta**2
222+
theta = xp.arctan2(grid[:, 1], grid[:, 0])
215223

216224
m_abs = abs(self.m)
217225
n_laguerre = (self.n - m_abs) // 2
@@ -235,6 +243,7 @@ def __init__(
235243
n: int,
236244
m: int,
237245
centre: Tuple[float, float] = (0.0, 0.0),
246+
phi: float = 0.0,
238247
intensity: float = 1.0,
239248
beta: float = 1.0,
240249
):
@@ -257,6 +266,9 @@ def __init__(
257266
The order of the shapelets basis function in the x-direction.
258267
centre
259268
The (y,x) arc-second coordinates of the profile (shapelet) centre.
269+
phi
270+
The position angle (in degrees) of the elliptical coordinate system, measured counter-clockwise from the
271+
positive x-axis.
260272
intensity
261273
Overall intensity normalisation of the light profile (units are dimensionless and derived from the data
262274
the light profile's image is compared too, which is expected to be electrons per second).
@@ -268,7 +280,8 @@ def __init__(
268280
n=n,
269281
m=m,
270282
centre=centre,
271-
ell_comps=(0.0, 0.0),
283+
q=1.0,
284+
phi=phi,
272285
intensity=intensity,
273286
beta=beta,
274287
)

0 commit comments

Comments
 (0)