Example #1
0
def check_args(ti):
	print('check_args')
	print(ti)
	'''
	Process all command line arguments.

	 [ if sys.argv[1:] is a valid set of command line arguments ->
		 return (ra_dec, lat_lon, dt) where ra_dec is a set of
		 celestial coordinates as a sdr.ra_dec instance,
		 lat_lon is position as a sdr.lat_lon instance, and
		 dt is a datetime.datetime instance
		else ->
		 sys.stderr +:= error message
		 stop execution ]
	'''
	#-- 1 --
	# [ if sys.argv[1:] has exactly four elements ->
	#	 raw_ra_dec, raw_lat, raw_lon, raw_dt := those elements
	# else ->
	#	 sys.stderr +:= error message
	#	 stop execution ]
	arg_list = sys.argv[1:]
	if len(arg_list) != 5:
		usage ('Incorrect command line argument count.')
	else:
		raw_ra_dec, raw_lat, raw_lon, raw_dt, IONEX_TEC_file = arg_list
	raw_dt = str(ti)
	print('arg_list', arg_list)

	#-- 2 --
	# [ if raw_ra_dec is a valid set of equatorial coordinates ->
	#	 ra_dec := those coordinates as a sdr.ra_dec instance
	# else ->
	#	 sys.stderr +:= error message
	#	 stop execution ]
	ra_dec = check_ra_dec(raw_ra_dec)

	#-- 3 --
	# [ if raw_lat is a valid latitude ->
	#	 lat := that latitude in radians
	# else ->
	#	 sys.stderr +:= error message
	#	 stop execution ]
	try:
		lat = sdr.parse_lat(raw_lat)
	except SyntaxError, detail:
		usage('Invalid latitude: {detail}'.format(detail=detail))