From 0bb2bd2c37aa738bbc8ef0cbd346b2393d8dfe0e Mon Sep 17 00:00:00 2001 From: Aymeric Galan <aymeric.galan@gmail.com> Date: Mon, 15 Apr 2024 09:55:43 +0200 Subject: [PATCH 1/2] Fix position angle computed from central moments --- coolest/api/util.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/coolest/api/util.py b/coolest/api/util.py index fdb42f7..a54347f 100644 --- a/coolest/api/util.py +++ b/coolest/api/util.py @@ -214,6 +214,8 @@ def ellipticity_from_moments(light_map, pixel_size): lambda_2 = (mu_20_ + mu_02_) / 2. - np.sqrt(4*mu_11_**2 + (mu_20_ - mu_02_)**2) / 2. q = np.sqrt(lambda_2 / lambda_1) # b/a, axis ratio phi = np.arctan(2. * mu_11_ / (mu_20_ - mu_02_)) / 2. # position angle + if mu_02_ > mu_20_: + phi += np.pi # makes it consistent angles conventions in COOLEST return phi, q From b58f0391c3ba66202ca518c323d5f4324071db52 Mon Sep 17 00:00:00 2001 From: Aymeric Galan <aymeric.galan@gmail.com> Date: Tue, 16 Apr 2024 09:41:54 +0200 Subject: [PATCH 2/2] Fix angle offset in moments --- coolest/api/util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coolest/api/util.py b/coolest/api/util.py index a54347f..2e41723 100644 --- a/coolest/api/util.py +++ b/coolest/api/util.py @@ -215,7 +215,7 @@ def ellipticity_from_moments(light_map, pixel_size): q = np.sqrt(lambda_2 / lambda_1) # b/a, axis ratio phi = np.arctan(2. * mu_11_ / (mu_20_ - mu_02_)) / 2. # position angle if mu_02_ > mu_20_: - phi += np.pi # makes it consistent angles conventions in COOLEST + phi += np.pi / 2. # makes it consistent angles conventions in COOLEST return phi, q