def angsep(lon1,lat1,lon2,lat2):
"""
Angular separation (deg) between two sky coordinates.
Borrowed from astropy (www.astropy.org)
Notes
-----
The angular separation is calculated using the Vincenty formula [1],
which is slighly more complex and computationally expensive than
some alternatives, but is stable at at all distances, including the
poles and antipodes.
[1] http://en.wikipedia.org/wiki/Great-circle_distance
"""
lon1,lat1 = numpy.radians([lon1,lat1])
lon2,lat2 = numpy.radians([lon2,lat2])
sdlon = numpy.sin(lon2 - lon1)
cdlon = numpy.cos(lon2 - lon1)
slat1 = numpy.sin(lat1)
slat2 = numpy.sin(lat2)
clat1 = numpy.cos(lat1)
clat2 = numpy.cos(lat2)
num1 = clat2 * sdlon
num2 = clat1 * slat2 - slat1 * clat2 * cdlon
denominator = slat1 * slat2 + clat1 * clat2 * cdlon
return numpy.degrees(numpy.arctan2(numpy.hypot(num1,num2), denominator))
############################################################
# ADW: Reduce numpy array operations for speed
评论列表
文章目录