import math


def haversine(lat1,lon1,lat2,lon2,radius=6371000.0):
    """
    Haversine function, used to calculate the distance between two points on the surface of a sphere. Good approximation
    for distances between two points on the surface of the Earth if the correct local curvature is used and the points are
    relatively close to one another.

    Parameters
    ----------
    lat1 : array_like
        Latitude of first point in radians
    lon1 : array_like
        Longitude of first point in radians
    lat2: array_like
        Latitude of second point in radians
    lon2 : array_like
        Longitude of second point in radians
    radius : float
        Local radius of curvature in meters

    Returns
    -------
    distance : float
        Distance between the two locations
    """
    distance = 2*radius*math.asin(math.sqrt(math.sin((lat2-lat1)/2)**2+math.cos(lat1)*math.cos(lat2)*math.sin((lon2-lon1)/2)**2))
    return distance