Документ взят из кэша поисковой машины. Адрес оригинального документа : http://www.stsci.edu/spst/UnixTransition/doc/ephem_check.py
Дата изменения: Fri Apr 8 12:46:11 2016
Дата индексирования: Sun Apr 10 23:48:19 2016
Кодировка:

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

**PURPOSE** --
This module contains a class that checks orbit file used for the
given calendar.

**DEVELOPER** --
Don Chance

**MODIFICATION HISTORY** --

o Initial implementation 9/21/00

o Changed calendar lead time to 2 weeks. drc 2/27/01

o Modified for T-11 calendar building. drc 9/10/01
o Correct 'most recent ephem' query for normal ephems only. mdr 2/17/15
o code cleanup. drc 12/7/15
"""
#***********************************************************************
from abstract_check import abstract_check
from checklist_init import sogs_db, EPHEM_LEAD_TIME, EPHEM_DUR, PASS, UNKNOWN
import stpydb
import time_util


class ephem_check(abstract_check):
"""Verify correct ephemeris was used
"""
def __str__(self):
return self.__doc__.rstrip() + " Orbit file = %s" % str(self.my_checklist.orbfile)

def run(self):
abstract_check.run(self)
file_pointer = open(self.outfile, "w")

orbfileobj = self.my_checklist.orbfile
orbfile = orbfileobj.orbit_file_name
orbver = orbfileobj.orbit_file_version
standard = 1

# Check that the ephem is the most recent
dbconnection = stpydb.stpydb(dbmsName=sogs_db)
dbconnection.query("select * from orbit_file_c where create_date = ")
dbconnection.query(" (select max(create_date) from orbit_file_c where file_type = 'N')")

latest_orb_file = {}

while dbconnection.execute(latest_orb_file):
pass

file_pointer.write("The orbit file for this calendar is %s\n" % orbfile)
file_pointer.write("The orbit file version number is %s\n" % orbver)

# The version is normally 1.
if orbver != 1:
file_pointer.write("The orbit file version is not 1. This is non-standard.\n")
standard = 0

if latest_orb_file['file_name'] == orbfile:
file_pointer.write("It is the latest normal orbitfile.\n")

if latest_orb_file['version_num'] != orbver:
file_pointer.write("The latest normal orbit file version is %s. This is non-standard.\n" %
latest_orb_file['version_num'])
standard = 0
else:
file_pointer.write("The latest normal orbit file is %s.\n" %
latest_orb_file['file_name'])

# Check that it was generated < 2 weeks before the calendar start date
create_date = time_util.spss_time(orbfileobj.orbitdata['create_date'])
if create_date + EPHEM_LEAD_TIME < self.my_checklist.calendar.get_begin_time():
file_pointer.write("The calendar begins at %s.\n" %
str(self.my_checklist.calendar.get_begin_time()))
file_pointer.write("This is more than 2 weeks after the orbit file generation date of %s.\n"
% str(create_date))
file_pointer.write("This is non-standard.\n")
standard = 0

# Check that the ephem is of the correct length (70 days)
ps_start = time_util.spss_time(orbfileobj.orbitdata['ps_start'])
ps_end = time_util.spss_time(orbfileobj.orbitdata['ps_end'])
length = ps_end - ps_start
if length != EPHEM_DUR:
file_pointer.write("This orbit file has a length of %s\n" % str(length))
file_pointer.write("Orbit files for flight calendars should be 70 days in length.\n")
standard = 0

# Check that the ephem start date + 2 weeks = the calendar start date
if ps_start + EPHEM_LEAD_TIME != self.my_checklist.calendar.get_begin_time():
file_pointer.write("The ephem start date (%s) normally is 2 weeks before the calendar start date (%s)\n"
% (str(ps_start), str(self.my_checklist.calendar.get_begin_time())))
file_pointer.write("This is non-standard.\n")
standard = 0

# Check that it has a name of the form ORyydddWv
if (orbfile[:2] != 'OR' or orbfile[-2] != 'W' or
orbfile[2:7] != ps_start.strftime("%y%j")):
file_pointer.write("Orbit files usually have a name in the form ORyydddWv\n")
file_pointer.write("This orbit file has a non-standard name.\n")
standard = 0

if standard:
self.pf_status = PASS
else:
self.pf_status = UNKNOWN
return self.pf_status


def run(calendar):
"""Run the check stand alone.
"""
import calchecklist
clist = calchecklist.cal(calendar, 'none', 1)
check = ephem_check(clist)
print "\n Output sent to file " + check.outfile
check.run()