#NEWLINE# def course( p0 , p1 , deg = True , bearing = False ) : #NEWLINE# #INDENT# '\n    Compute the initial bearing along the great circle from p0 to p1\n\n    NB: The angle returned by course() is not the traditional definition of\n    bearing. It is definted such that 0 degrees to due East increasing\n    counter-clockwise such that 90 degrees is due North. To obtain the bearing\n    (0 degrees is due North increasing clockwise so that 90 degrees is due\n    East), set the bearing flag input to True.\n\n    Parameters\n    ----------\n    p0 : point-like (or array of point-like) [lon, lat] objects\n    p1 : point-like (or array of point-like) [lon, lat] objects\n    deg : bool, optional (default True)\n        indicates if p0 and p1 are specified in degrees. The returned\n        angle is returned in the same units as the input.\n    bearing : bool, optional (default False)\n        If True, use the classical definition of bearing where 0 degrees is\n        due North increasing clockwise so that and 90 degrees is due East.\n\n    Reference\n    ---------\n    http://www.movable-type.co.uk/scripts/latlong.html - Bearing\n\n    ' #NEWLINE# ( single , ( p0 , p1 ) ) = _to_arrays ( ( p0 , 2 ) , ( p1 , 2 ) ) #NEWLINE# if deg : #NEWLINE# #INDENT# p0 = np . radians ( p0 ) #NEWLINE# p1 = np . radians ( p1 ) #NEWLINE# #UNINDENT# ( lon0 , lat0 ) = ( p0 [ : , 0 ] , p0 [ : , 1 ] ) #NEWLINE# ( lon1 , lat1 ) = ( p1 [ : , 0 ] , p1 [ : , 1 ] ) #NEWLINE# dlon = ( lon1 - lon0 ) #NEWLINE# a = ( sin ( dlon ) * cos ( lat1 ) ) #NEWLINE# b = ( ( cos ( lat0 ) * sin ( lat1 ) ) - ( ( sin ( lat0 ) * cos ( lat1 ) ) * cos ( dlon ) ) ) #NEWLINE# if bearing : #NEWLINE# #INDENT# angle = arctan2 ( a , b ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# angle = arctan2 ( b , a ) #NEWLINE# #UNINDENT# if deg : #NEWLINE# #INDENT# angle = np . degrees ( angle ) #NEWLINE# #UNINDENT# if single : #NEWLINE# #INDENT# angle = angle [ 0 ] #NEWLINE# #UNINDENT# return angle