From 19d0be2be3c61d81cc7cdfeba7fa4b241f83157c Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Thu, 12 Feb 2026 13:34:47 +0000 Subject: [PATCH 1/2] revert geometry profiles to use angle method --- autogalaxy/convert.py | 3 ++- autogalaxy/profiles/geometry_profiles.py | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/autogalaxy/convert.py b/autogalaxy/convert.py index ff1c2a17d..ca0664dad 100644 --- a/autogalaxy/convert.py +++ b/autogalaxy/convert.py @@ -28,6 +28,7 @@ def ell_comps_from(axis_ratio: float, angle: float, xp=np) -> Tuple[float, float return (ellip_y, ellip_x) + def axis_ratio_and_angle_from( ell_comps: Tuple[float, float], xp=np ) -> Tuple[float, float]: @@ -60,7 +61,7 @@ def axis_ratio_and_angle_from( ell_comps The elliptical components of the light or mass profile which are converted to an angle. """ - angle = xp.arctan2(ell_comps[0], ell_comps[1]) / 2 + angle = 0.5 * xp.arctan2(ell_comps[0], xp.where((ell_comps[0] == 0) & (ell_comps[1] == 0), 1.0, ell_comps[1])) angle *= 180.0 / xp.pi angle = xp.where(angle < -45, angle + 180, angle) diff --git a/autogalaxy/profiles/geometry_profiles.py b/autogalaxy/profiles/geometry_profiles.py index 1df8ccec1..920247bdf 100644 --- a/autogalaxy/profiles/geometry_profiles.py +++ b/autogalaxy/profiles/geometry_profiles.py @@ -106,8 +106,7 @@ def _cartesian_grid_via_radial_from( """ grid_angles = xp.arctan2(grid.array[:, 0], grid.array[:, 1]) - cos_theta = xp.cos(grid_angles) - sin_theta = xp.sin(grid_angles) + cos_theta, sin_theta = self.angle_to_profile_grid_from(grid_angles=grid_angles, xp=xp, **kwargs) return xp.multiply(radius[:, None], xp.vstack((sin_theta, cos_theta)).T) From 85e78ab33e6f7e0aa4801eebfe8f4b71fbff464f Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Thu, 12 Feb 2026 13:42:59 +0000 Subject: [PATCH 2/2] same zero guard applied to shear and multipole --- autogalaxy/convert.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/autogalaxy/convert.py b/autogalaxy/convert.py index ca0664dad..fa0b12b91 100644 --- a/autogalaxy/convert.py +++ b/autogalaxy/convert.py @@ -198,7 +198,7 @@ def shear_magnitude_and_angle_from( gamma_2 The gamma 2 component of the shear. """ - angle = xp.arctan2(gamma_2, gamma_1) / 2 * 180.0 / xp.pi + angle = 0.5 * xp.arctan2(gamma_2, xp.where((gamma_1 == 0) & (gamma_2 == 0), 1.0, gamma_1)) * 180.0 / xp.pi magnitude = xp.sqrt(gamma_1**2 + gamma_2**2) angle = xp.where(angle < 0, angle + 180.0, angle) @@ -298,9 +298,15 @@ def multipole_k_m_and_phi_m_from( ------- The normalization and angle parameters of the multipole. """ - phi_m = ( - xp.arctan2(multipole_comps[0], multipole_comps[1]) * 180.0 / xp.pi / float(m) - ) + phi_m = xp.arctan2( + multipole_comps[0], + xp.where( + (multipole_comps[0] == 0) & (multipole_comps[1] == 0), + 1.0, + multipole_comps[1], + ), + ) * 180.0 / xp.pi / float(m) + k_m = xp.sqrt(multipole_comps[1] ** 2 + multipole_comps[0] ** 2) phi_m = xp.where(phi_m < -90.0 / m, phi_m + 360.0 / m, phi_m)