From a6c8941f3512f0b2f1e8d14e47eb50f90d8ec552 Mon Sep 17 00:00:00 2001
From: Lionel GUEZ <guez@lmd.ens.fr>
Date: Fri, 1 Dec 2023 13:00:30 +0100
Subject: [PATCH] Bug fix: correct sign of variation of Rossby number and
 radius

Bug fix: correct sign of variation of Rossby number and radius. We
have to be consistent with the computation of `delta_ro_mean` and
`delta_r_mean`. `delta_ro_mean` and `delta_r_mean` were computed by
subtracting origin from tail.
---
 Trajectories/cost_function.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Trajectories/cost_function.py b/Trajectories/cost_function.py
index 6e4000cb..58f0a782 100755
--- a/Trajectories/cost_function.py
+++ b/Trajectories/cost_function.py
@@ -245,13 +245,13 @@ for edge in g.edges():
 
     # Rossby numbers:
     if first_av_ros[target_node] and last_av_ros[source_node]:
-        Delta_Ro = last_av_ros[source_node] - first_av_ros[target_node]
+        Delta_Ro = first_av_ros[target_node] - last_av_ros[source_node]
     else:
         # At least one of the rossbies is invalid.
         Delta_Ro = 0
 
     # R_Vmax 1 and 2 already exist, just get the delta
-    Delta_R_Vmax = last_av_rad[source_node] - first_av_rad[target_node]
+    Delta_R_Vmax = first_av_rad[target_node] - last_av_rad[source_node]
 
     # Calculate the cost and assign to the edge:
     g.ep.cost_function[edge] = math.sqrt(
-- 
GitLab