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

Поисковые слова: http www.astronomy.ru forum index.php topic 4644.0.html
#
#MODULE cos_g140l_1280_check
#
#***********************************************************************
"""

**PURPOSE** --
This module contains a class that checks that there is no usage of
COS G140L with a central wavelength setting of 1280 A.

**DEVELOPER** --
Don Chance

**MODIFICATION HISTORY** --
o Initial implementation drc 6/22/10
"""
#***********************************************************************
from abstract_check import *
import calendar_util
import alignment_util

__version__ = "6/22/10"

class cos_g140l_1280_check(abstract_check):
"""Check for usage of COS G140L central wavelength 1280 A
"""
def run(self):
abstract_check.run(self)
file_pointer = open(self.outfile, "w")
self.pf_status = PASS

# Find the COS G140L lambda_c = 1280 A on this calendar from the pmdb
zeroth_order_specs = self.get_cos_g140l_1280()

# Find when all alignments are scheduled from the calendar display
cal_aligns = calendar_util.cal_display().get_scheduled_alignments()

# Populate zeroth_order_spec with the window when they are scheduled
for zeroth_order_spec in zeroth_order_specs:
for cal_align in cal_aligns:
if zeroth_order_spec == cal_align:
zeroth_order_spec['sched_window'] = time_util.window(cal_align['begin_time'], cal_align['end_time'])
self.pf_status = FAIL
file_pointer.write("ERROR -- COS/FUV G140L with central wavelenth = 1280 A\n")
file_pointer.write(" in alignment %s\n" % zeroth_order_spec)
file_pointer.write(" %s begin time: %s, end time: %s\n" % (zeroth_order_spec,
zeroth_order_spec['sched_window'].starttime(),
zeroth_order_spec['sched_window'].endtime()))

if self.pf_status == PASS:
file_pointer.write("No COS G140L central wave 1280 Ang alignments found.\n")

return self.pf_status


def get_cos_g140l_1280(self):
"""Find all the COS G140L 1280 Ang alignments scheduled on the calendar.
"""
result = {}
dbconnection = stpydb.stpydb(dbmsName=sogs_db)
dbconnection.query("select distinct qel.proposal_id,")
dbconnection.query(" qel.obset_id,")
dbconnection.query(" qel.alignment_id,")
dbconnection.query(" qel.exposure_id,")
dbconnection.query(" qel.version_num")

dbconnection.query("from qelogsheet qel,")
dbconnection.query(" qsbranching qsb,")
dbconnection.query(" wistat_sunit wis")

dbconnection.query("where wis.sunit_status > 2")
dbconnection.query(" and wis.cc_or_sms_na = @cal")
dbconnection.query(" and wis.cc_or_sms_vn = @ver")
dbconnection.query(" and wis.sunit_id = qsb.sunit_id")
dbconnection.query(" and wis.version_num = qsb.version_num")
dbconnection.query(" and qel.proposal_id = qsb.proposal_id")
dbconnection.query(" and qel.obset_id = qsb.obset_id")
dbconnection.query(" and qel.config = 'COS/FUV'")
dbconnection.query(" and qel.sp_1 = 'G140L'")
dbconnection.query(" and qel.minwave = 1280.0")
dbconnection.setParam([["cal", self.my_checklist.calendar.get_name()],
["ver", self.my_checklist.calendar.get_version()]])

align_list = []
while dbconnection.execute(result):
align_list.append(alignment_util.alignment(result))

return align_list


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

if __name__ == '__main__':
run(sys.argv[1])