From 9f9edf063d5699b37041aaa7f9dec9cfba6fe36c Mon Sep 17 00:00:00 2001 From: tomrink <rink@ssec.wisc.edu> Date: Fri, 20 Jan 2023 13:32:47 -0600 Subject: [PATCH] snapshot... --- modules/util/util.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/util/util.py b/modules/util/util.py index 8ad1d742..9116e4ef 100644 --- a/modules/util/util.py +++ b/modules/util/util.py @@ -135,14 +135,14 @@ def add_time_range_to_filename(pathname, tstart, tend=None): return path -def haversine_np(lon1, lat1, lon2, lat2): +def haversine_np(lon1, lat1, lon2, lat2, earth_radius=6367.0): """ Calculate the great circle distance between two points on the earth (specified in decimal degrees) (lon1, lat1) must be broadcastable with (lon2, lat2). - """ + lon1, lat1, lon2, lat2 = map(np.radians, [lon1, lat1, lon2, lat2]) dlon = lon2 - lon1 @@ -150,8 +150,8 @@ def haversine_np(lon1, lat1, lon2, lat2): a = np.sin(dlat/2.0)**2 + np.cos(lat1) * np.cos(lat2) * np.sin(dlon/2.0)**2 - c = 2 * np.arcsin(np.sqrt(a)) - km = 6367 * c + c = 2.0 * np.arcsin(np.sqrt(a)) + km = earth_radius * c return km -- GitLab