This is pretty similar to Section 4.5, “checkArgs(): Process command-line
arguments”, except that the first item is an azimuth, sign, and
altitude.
# - - - c h e c k A r g s
def checkArgs():
"""Process all command line arguments.
[ if sys.argv[1:] is a valid set of command line arguments ->
return (altAz, latLon, dt) where altAz is a set of
horizon coordinates as a sidereal.AltAz instance,
latLon is position as a sidereal.LatLon instance, and
dt is a datetime.datetime instance
else ->
sys.stderr +:= error message
stop execution ]
"""
#-- 1 --
# [ if sys.argv[1:] has exactly four elements ->
# rawAltAz, rawLat, rawLon, rawDT := those elements
# else ->
# sys.stderr +:= error message
# stop execution ]
argList = sys.argv[1:]
if len(argList) != 4:
usage ("Incorrect command line argument count." )
else:
rawAltAz, rawLat, rawLon, rawDT = argList
For the checking of the first argument, see Section 5.7, “checkAltAz(): Validate horizon
coordinates”. The rest are as in Section 4.5, “checkArgs(): Process command-line
arguments”.
#-- 2 --
# [ if rawAltAz is a valid set of horizon coordinates ->
# altAz := those coordinates as a sidereal.AltAz instance
altAz = checkAltAz ( rawAltAz )
#-- 3 --
# [ if rawLat is a valid latitude ->
# lat := that latitude in radians
# else ->
# sys.stderr +:= error message
# stop execution ]
try:
lat = sidereal.parseLat ( rawLat )
except SyntaxError, detail:
usage ( "Invalid latitude: %s" % detail )
#-- 4 --
# [ if rawLon is a valid longitude ->
# lon := that longitude in radians
# else ->
# sys.stderr +:= error message
# stop execution ]
try:
lon = sidereal.parseLon ( rawLon )
except SyntaxError, detail:
usage ( "Invalid longitude: %s" % detail )
#-- 5 --
# [ if rawDT is a valid date-time string ->
# dt := that date-time as a datetime.datetime instance
# else ->
# sys.stderr +:= error message
# stop execution ]
try:
dt = sidereal.parseDatetime ( rawDT )
except SyntaxError, detail:
usage ( "Invalid timestamp: %s" % detail )
#-- 6 --
latLon = sidereal.LatLon ( lat, lon )
return (altAz, latLon, dt)