Next / Previous / Contents / TCC Help System / NM Tech homepage

9.3. hourAngleToRA(): Convert an hour angle to right ascension

For a given hour angle h, a given time ut, and an observer's longitude eLong, this function returns the right ascension in radians.

sidereal.py
# - - -   h o u r A n g l e T o R A

def hourAngleToRA ( h, ut, eLong ):
    """Convert hour angle to right ascension.

      [ (h is an hour angle 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 right ascension in radians corresponding
          to that hour angle at that time and location ]
    """

This is Duffett-Smith's algorithm 24, “Converting between right ascension and hour-angle.” The formula relating hour-angle H and right ascension α is:

The first step is to convert ut into Greenwich Sidereal Time, GST. See Section 14.7, “SiderealTime.fromDatetime(): Convert UTC to GST (static method)”.

sidereal.py
    #-- 1 --
    # [ gst  :=  the Greenwich Sidereal Time equivalent to
    #            ut, as a SiderealTime instance ]
    gst  =  SiderealTime.fromDatetime ( ut )

Next we convert GST to LST, local sidereal time. See Section 14.6, “SiderealTime.lst(): Greenwich to local sidereal”.

sidereal.py
    #-- 2 --
    # [ lst  :=  the local time corresponding to gst at
    #            longitude eLong ]
    lst  =  gst.lst ( eLong )

Finally we subtract H from LST, normalizing the result to [0,2π).

sidereal.py
    #-- 3 --
    # [ alpha  :=  lst - h, normalized to [0,2*pi) ]
    alpha  =  (lst.radians - h) % TWO_PI

    #-- 4 --
    return alpha