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

Поисковые слова: р п р п р п р п р п р п р п р п р п
#MODULE orbfile_send
#
#*******************************************************************
"""

**PURPOSE** --
replaces DO ORBGEN, and DO ORB_TO_SPB and all associated isql/sqr...

**DEVELOPER** --

Greg Wenzel

**MODIFICATION HISTORY** --

Initial implementation 08/25/2000 GWW.
Allow option to generate reports but not distribute 11/21/07 mdr

**USAGE** --

do orbfile_send [-nodistribute]
or
orbfile_send.run(, [-nodistribute])
"""
#*******************************************************************
import stpydb,spss_sys_util,time_util,os,sys,orbit_util, spst_getopt
from boolean import *
import string

def run(*args):
"""creates two output reports. Sends notification to distribution list.
replaces DO ORBGEN, and DO ORB_TO_SPB and all associated isql/sqr...
"""

# Parse the arguments
allowed_options = ['nodistribute']
options, parms = spst_getopt.spst_getopt(args, allowed_options)
print 'parms = ', parms
print 'options = ', options

# Deal with the parameters
orbit_file = parms[0]
if orbit_file is None:
raise IOError, "\n\nYou must enter a valid orbit file!"
orbit_file = string.upper(orbit_file)

# Deal with the optional switches
if (options.has_key('-nodistribute')):
distribute = 0
else:
distribute = 1
# end if

time_of_report = time_util.spss_time().strftime("%d-%b-%Y (%Y.%j)")

#get info for report file from database.
orbit_inst = orbit_util.orbit_file(orbit_file)
orbit_inst.get_fitdata()
orbit_inst.get_orbitdata()

if orbit_inst.fitdata == {} or orbit_inst.fitdata is None:
raise IOError,"\n\ndatabase query on %s returned nothing!" % orbit_file

#create report of ephem parameters
report_lines = []
report_lines.append(
"\n Notification of New ST Orbital Parameters")
report_lines.append(
"\n %s" % time_of_report)
report_lines.append(
"\n\n SPSS has received new ephemeris data and produced a new orbit")
report_lines.append(
"\n file (%s) using this data. Any calendars made after today" % \
orbit_file)
report_lines.append(
"\n within the period %s-%s will use"
% (time_util.spss_time(orbit_inst.fitdata['fit_start']),
time_util.spss_time(orbit_inst.fitdata['fit_end'])))
report_lines.append(
"\n this orbit file.")

report_lines.append("\n\n The names of the fits used in creating this orbit file are:")
report_lines.append(
"\n\n ST: %s" % \
(orbit_inst.orbitdata['st_fit']))
report_lines.append(
"\n TDRS East: %s" % \
(orbit_inst.orbitdata['tdrse_fit']))
report_lines.append(
"\n TDRS West: %s" % \
(orbit_inst.orbitdata['tdrsw_fit']))
report_lines.append(
"\n\n The fits to these ephemerides have produced the following results:")
report_lines.append(
"\n\n Epoch: %s" % \
(time_util.spss_time(orbit_inst.fitdata['fit_start'])))
report_lines.append(
"\n Semi-major axis: %7.2f km" % \
orbit_inst.fitdata['f2_1'])
report_lines.append(
"\n Nodal period: %10.8f hours" % \
(0.1/orbit_inst.fitdata['g2']))
report_lines.append(
"\n Orbital inclination: %7.3f degrees" % \
orbit_inst.fitdata['f4_1'])
report_lines.append(
"\n RA of Ascending Node: %6.2f degrees" % \
orbit_inst.fitdata['f3_1'])
report_lines.append(
"\n Rate of change of Ascending Node: %12.5E degrees/sec" % \
orbit_inst.fitdata['f3_2'])
report_lines.append(
"\n\n These parameters supercede any previous parameters for the same epoch.")
report_lines.append(
"\n\n\n The following are the fit coefficients for the ST fit:")
report_lines.append(
"\n\n Coefficient Value Definition")
report_lines.append(
"\n ___________ ______________ __________")
report_lines.append(
"\n\n G1 %15.8E Arg. of Latitude @ begin of fit (degrees)" % \
orbit_inst.fitdata['g1'])
report_lines.append(
"\n G2 %15.8E Rate of change of G1 (degrees/sec)" % \
orbit_inst.fitdata['g2'])
report_lines.append(
"\n G3 %15.8E Rate of change of G2 (degrees/sec)" % \
orbit_inst.fitdata['g3'])
report_lines.append(
"\n\n\n F1 F2 F3 F4")
report_lines.append(
"\n Arg of latitude Range Long of Asc Node Inclination")
report_lines.append(
"\n\nt**0 %15.8E %15.8E %15.8E %15.8E" % \
(orbit_inst.fitdata['f1_1'],orbit_inst.fitdata['f2_1'],orbit_inst.fitdata['f3_1'],orbit_inst.fitdata['f4_1']))
report_lines.append(
"\nt**1 %15.8E %15.8E %15.8E %15.8E" % \
(orbit_inst.fitdata['f1_2'],orbit_inst.fitdata['f2_2'],orbit_inst.fitdata['f3_2'],orbit_inst.fitdata['f4_2']))
report_lines.append(
"\nt**2 %15.8E %15.8E %15.8E %15.8E" % \
(orbit_inst.fitdata['f1_3'],orbit_inst.fitdata['f2_3'],orbit_inst.fitdata['f3_3'],orbit_inst.fitdata['f4_3']))
report_lines.append(
"\ncosg %15.8E %15.8E %15.8E %15.8E" % \
(orbit_inst.fitdata['f1_4'],orbit_inst.fitdata['f2_4'],orbit_inst.fitdata['f3_4'],orbit_inst.fitdata['f4_4']))
report_lines.append(
"\nsing %15.8E %15.8E %15.8E %15.8E" % \
(orbit_inst.fitdata['f1_5'],orbit_inst.fitdata['f2_5'],orbit_inst.fitdata['f3_5'],orbit_inst.fitdata['f4_5']))
report_lines.append(
"\ncos2g %15.8E %15.8E %15.8E %15.8E" % \
(orbit_inst.fitdata['f1_6'],orbit_inst.fitdata['f2_6'],orbit_inst.fitdata['f3_6'],orbit_inst.fitdata['f4_6']))
report_lines.append(
"\nsin2g %15.8E %15.8E %15.8E %15.8E" % \
(orbit_inst.fitdata['f1_7'],orbit_inst.fitdata['f2_7'],orbit_inst.fitdata['f3_7'],orbit_inst.fitdata['f4_7']))

report_file_name = string.lower("%s.rpt" % orbit_file)
report_file = open(report_file_name, 'w')
report_file.writelines(report_lines)
report_file.close()

#mail ephem report
distribution_file = "orb.dis"
distribution_dir = spss_sys_util.resolver("PE_DAT")
distribution_path = \
string.lower(os.path.join(distribution_dir,distribution_file))

#test the overwrite distribution_path
#distribution_path = '/spss_data/planinst/wenzel/python/orb.dis'
if (distribute == 1):
spss_sys_util.mail(distribution_path,
'New orbit file: %s' % orbit_inst.orbitdata['file_name'],
report_file_name,true)
os.remove(report_file_name)
# endif

#create northpoint report
north_point_list = []
t = time_util.spss_time(orbit_inst.fitdata['fit_start'])
for i in range(0,70):
north_point_list.append((t,orbit_inst.get_ra_northpoint(t)))
t = t + 86400.0

northpoint_file_name = "%s_nrthpnt.rpt" % ( orbit_file)
northpoint_file_dir = spss_sys_util.resolver("SPBDIR")
if (distribute == 1):
northpoint_file_path = \
string.lower(os.path.join(northpoint_file_dir,northpoint_file_name))
else:
northpoint_file_path = northpoint_file_name
# end if

#test then over write northpoint_file_path
#northpoint_file_path = '/spss_data/planinst/wenzel/python/%s' % northpoint_file_name

lines = []
lines.append(
"\n\n HST northpoint right ascension from orbit file %s" % \
orbit_file)
lines.append(
"\n\n\n\n RA of")
lines.append(
"\n Epoch Northpoint")
lines.append(
"\n ----------- ----------\n")
for tup in north_point_list:
lines.append("\n %s %11.2f" % \
(tup[0].strftime("%Y.%j:%H"),tup[1]))

if (distribute == 1):
while os.path.exists(northpoint_file_path):
os.remove(northpoint_file_path)
# endif
report_file = open(northpoint_file_path, 'w')
report_file.writelines(lines)
report_file.close()

return
# end def run


# to run on commandline
if __name__ == '__main__':
import sys
if len(sys.argv) > 1:
print sys.argv
apply(run, tuple(sys.argv[1:]))
else:
run()