Документ взят из кэша поисковой машины. Адрес оригинального документа : http://www.stsci.edu/spst/UnixTransition/doc/select_tut_windows.py
Дата изменения: Fri Feb 28 14:46:11 2014
Дата индексирования: Sat Mar 1 21:57:39 2014
Кодировка:

Поисковые слова: trifid nebula
#
#MODULE select_tut_windows
#
#****************************************************************************
"""

TITLE: select_tut_windows.py
DEVELOPER: Alan Patterson, 24-Jul-2003

PURPOSE: The tool selects the TUT windows from the TUT file
specified given the TDRS, service and time window limits

USAGE: do select_tut_windows tutfile -tdrs=...,... -service=...,...
-start=
-end=
where -tdrs specifies a list of acceptable TDRS
(TDE,TDW,171,TDS)
-service specifies a list of acceptable
services (MAR,MAF,SSAF)
-start specifies the start time
-end specifies the end time
-outfile an output file may be specified, default
is to print to the screen
RETURNS: Nothing

MOD HISTORY:
Initial version app 07/24/03

"""
#****************************************************************************
import tdrs_util, spss_sys_util, spst_getopt, time_util
import string, sys

__version__ = "07/24/03"
__author__ = 'Alan Patterson'

def run(*args):
"""Selects from the TUT file TUT windows that meet specified parameters and
presents them as a time ordered list.

Usage:
do select_tut_windows -tdrs=xxx,... -service=yyy,...
-start=t1 -end=t2

where is the TUT file
xxx may be a comma separated list
of any of TDE, TDW, 171, TDS
yyy may be a comma separated list
of any of MAR, MAF, SSAF
t1 and t2 define the start and end
of a window. Only services
overlapping this window will be
reported
"""
if len(args) == 0:
print run.__doc__
return spss_sys_util.SUCCESS

allowed_options = ['tdrs=','service=','start=','end=','outfile=']

low_args = []
for a in args:
if a[0] == '-':
low_args.append(string.lower(a))
else:
low_args.append(a)

options, parms = spst_getopt.spst_getopt(low_args,allowed_options)
if len(parms) == 0:
print 'TUT file must be specified'
return not spss_sys_util.SUCCESS
tutfile = parms[0]

if options.has_key("-tdrs"):
tdrslist = string.split(string.upper(options["-tdrs"]),',')
for td in tdrslist:
if td not in tdrs_util.tdrs_list:
print 'Invalid TDRS specified %s' % td
return not spss_sys_util.SUCCESS
else:
print "TDRS must be specified"
return not spss_sys_util.SUCCESS
if options.has_key("-service"):
services = string.split(string.upper(options["-service"]),',')
for svc in services:
if svc not in ['MAR','MAF','SSAF']:
print 'Invalid service type specified %s' % svc
return not spss_sys_util.SUCCESS
else:
print "Service type must be specified"
return not spss_sys_util.SUCCESS
if options.has_key("-start"):
start = time_util.spss_time(options["-start"])
else:
print "Start time must be specified"
return not spss_sys_util.SUCCESS
if options.has_key("-end"):
end = time_util.spss_time(options["-end"])
else:
print "End time must be specified"
return not spss_sys_util.SUCCESS

tut_list = tdrs_util.get_tut_windows(tutfile)

res = []
for tut in tut_list:
if tut['tdrs'] in tdrslist and tut['type'] in services \
and tut['start'] < end and tut['end'] > start:
res.append((tut['start'],tut))
res.sort()
if options.has_key('-outfile'):
fout = open(options['-outfile'],'w')
for r in res:
tut = r[1]
fout.write('%s %s %s %4s %i\n' % \
(tut['tdrs'],tut['start'],tut['end'],tut['type'], \
tut['antenna']))
else:
for r in res:
tut = r[1]
print '%s %s %s %4s %i' % \
(tut['tdrs'],tut['start'],tut['end'],tut['type'], \
tut['antenna'])

return spss_sys_util.SUCCESS

if __name__ == "__main__":
if len(sys.argv) > 1:
apply(run, tuple(sys.argv[1:]))
else:
run()