From e561c78ad6b4e4da2fafe5a8fb83af05f0b06648 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=2E=20M=C3=B8ller?= Date: Mon, 29 Jun 2026 10:09:40 +0200 Subject: [PATCH 1/2] Switch to using np.arctan2 for Probabilistic Advection --- Models/ProbabilisticAdvection.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Models/ProbabilisticAdvection.py b/Models/ProbabilisticAdvection.py index ecf667a..f082145 100644 --- a/Models/ProbabilisticAdvection.py +++ b/Models/ProbabilisticAdvection.py @@ -62,8 +62,9 @@ def ens_forecast(self, else: raise Exception('angle_pert_dist must be either normal or vonmises') - pert_motion_field[0, :, :] = pert_abs * np.cos(np.arctan(y / x) + beta_noise) - pert_motion_field[1, :, :] = pert_abs * np.sin(np.arctan(y / x) + beta_noise) + base_angle = np.arctan2(y, x) + pert_motion_field[0, :, :] = pert_abs * np.cos(base_angle + beta_noise) + pert_motion_field[1, :, :] = pert_abs * np.sin(base_angle + beta_noise) yhat_maps = self.extrapolate(self.last_map, pert_motion_field, From 719da6617d4e675cc4d1e7dd864e6d1dc21f5524 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=2E=20M=C3=B8ller?= Date: Mon, 29 Jun 2026 11:34:24 +0200 Subject: [PATCH 2/2] Add comment on the use of arctan2 --- Models/ProbabilisticAdvection.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Models/ProbabilisticAdvection.py b/Models/ProbabilisticAdvection.py index f082145..87d3875 100644 --- a/Models/ProbabilisticAdvection.py +++ b/Models/ProbabilisticAdvection.py @@ -62,6 +62,7 @@ def ens_forecast(self, else: raise Exception('angle_pert_dist must be either normal or vonmises') + # Use arctan2 for angle calculation to handle all quadrants correctly base_angle = np.arctan2(y, x) pert_motion_field[0, :, :] = pert_abs * np.cos(base_angle + beta_noise) pert_motion_field[1, :, :] = pert_abs * np.sin(base_angle + beta_noise)