This is the inverse of Section 9.4, “raToHourAngle(): Convert a right
ascension to an hour angle”.
The first two steps are the same: derive the GST and
convert it to LST.
# - - - r a T o H o u r A n g l e
def raToHourAngle ( ra, ut, eLong ):
"""Convert right ascension to hour angle.
[ (ra is a right ascension in radians as a float) and
(ut is a timestamp as a datetime.datetime instance) and
(eLong is an east longitude in radians) ->
return the hour angle in radians at that time and
location corresponding to that right ascension ]
"""
#-- 1 --
# [ gst := the Greenwich Sidereal Time equivalent to
# ut, as a SiderealTime instance ]
gst = SiderealTime.fromDatetime ( ut )
#-- 2 --
# [ lst := the local time corresponding to gst at
# longitude eLong ]
lst = gst.lst ( eLong )
All that remains is to subtract h from
lst and normalize the result to
[0,2π).
#-- 3 --
# [ h := lst - ra, normalized to [0,2*pi) ]
h = (lst.radians - ra) % TWO_PI
#-- 4 --
return h