From efdfee04681ccb62ac37bd75e5f1952713d0d56f Mon Sep 17 00:00:00 2001
From: Lionel GUEZ <guez@lmd.ens.fr>
Date: Fri, 1 Dec 2023 09:24:54 +0100
Subject: [PATCH] Assume the Earth is a sphere

It does not make sense here to assume an ellipsoid: the computation of
the distance with $\cos \phi \delta \lambda$ and $\delta \phi$ is a
rougher approximation than treating the Earth as a sphere.
---
 Trajectories/cost_function.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/Trajectories/cost_function.py b/Trajectories/cost_function.py
index bb15b146..5e4c82b1 100755
--- a/Trajectories/cost_function.py
+++ b/Trajectories/cost_function.py
@@ -27,6 +27,7 @@ import graph_tool
 import util_eddies
 
 Omega = 2 * math.pi / 86164.0
+r_Earth = 6371  # radius of the Earth, in km
 
 
 def calculate_radii_rossby(properties):
@@ -240,10 +241,9 @@ for edge in g.edges():
     if lon_diff > math.radians(300):
         lon_diff = 2 * math.pi - lon_diff
 
-    Delta_Cent = math.sqrt(
-        (lon_diff * 6378.166175 * math.cos(latitude)) ** 2
-        + ((pos_last[source_node][1] - pos_first[target_node][1]) * 6335.423523)
-        ** 2
+    Delta_Cent = r_Earth * math.sqrt(
+        (lon_diff * math.cos(latitude)) ** 2
+        + (pos_last[source_node][1] - pos_first[target_node][1]) ** 2
     )
 
     # Rossbies:
-- 
GitLab