22from typing import Optional , Tuple
33
44import autoarray as aa
5+ import autolens as al
56
67
78from 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