The main sequence comes down to three steps: check and convert the command line arguments; find the local sidereal time; and then find the horizon coordinates.
# - - - - - m a i n
def main():
"""Main program for rdaa.
"""
#-- 1 --
# [ if sys.argv contains a valid set of command line
# arguments ->
# raDec := the right ascension and declination as
# a sidereal.RADec instance
# latLon := the observer's location as a
# sidereal.LatLon instance
# dt := the observer's date and time as a
# datetime.datetime instance
# else ->
# sys.stderr +:= error message
# stop execution ]
raDec, latLon, dt = checkArgs()
Since the time specified might have a time zone attached, we'll need to convert it to UTC.
#-- 2 --
# [ if dt has no time zone information ->
# utc := dt
# else ->
# utc := the UTC equivalent to dt ]
if ( (dt.tzinfo is None) or
(dt.utcoffset() is None) ):
utc = dt
else:
utc = dt - dt.utcoffset()
Just for convenience and user reference, we'll compute and display the observer's local sidereal time.
#-- 3 --
# [ sys.stdout +:= local sidereal time for dt and latLon ]
gst = sidereal.SiderealTime.fromDatetime ( utc )
lst = gst.lst ( latLon.lon )
print "Equatorial coordinates:", raDec
print "Observer's location:", latLon
print "Observer's time:", dt
print "Local sidereal time is", lst
Now find the hour angle, convert to horizon coordinates, and print the result.
#-- 4 --
# [ h := hour angle for raDec at time (utc) and longitude
# (latLon.lon) ]
h = raDec.hourAngle ( utc, latLon.lon )
#-- 5 --
# [ aa := horizon coordinates of raDec at hour angle h
# as a sidereal.AltAz instance ]
aa = raDec.altAz ( h, latLon.lat )
#-- 6 --
print "Horizon coordinates:", aa