Skip to content
Snippets Groups Projects
Commit 9f9edf06 authored by tomrink's avatar tomrink
Browse files

snapshot...

parent fcb5dc5d
Branches
No related tags found
No related merge requests found
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment