Package helpers :: Module CreateReleaseFileList
[hide private]

Source Code for Module helpers.CreateReleaseFileList

 1  #! /usr/bin/env python 
 2  #------------------------------------------------------------------------------ 
 3  # $Id: CreateReleaseFileList.py 10172 2013-12-22 14:26:58Z NicholasCross $ 
 4  """ 
 5     Calculates constants for the Filter table. Based on the filter curve 
 6     properties and already calibrated catalogues. These constants are the 50% 
 7     cut-on and cut-offs, the A/E(B-V) extinction values, the VegaToAB and 1s 
 8     magnitude limit in Vega. The output is written to a file, not the database, 
 9     because some of the numbers in the DB come from external sources and should 
10     not be overwritten. 
11   
12     @author: N.J.G. Cross 
13     @org:    WFAU, IfA, University of Edinburgh 
14   
15     @newfield contributors: Contributors, Contributors (Alphabetical Order) 
16     @contributors: R.S. Collins 
17  """ 
18  #------------------------------------------------------------------------------ 
19  import os 
20   
21   
22  from   wsatools.CLI                 import CLI 
23  from   wsatools.DbConnect.CuSession import CuSession 
24  from   wsatools.Logger              import Logger 
25  #------------------------------------------------------------------------------ 
26  #------------------------------------------------------------------------------ 
27   
28 -class CreateReleaseFileList(CuSession):
29 """ 30 List of tilestack files in release: 31 fileName, object, filterName 32 """ 33 34 frameTypeList = None 35 dateRange = CuSession.sysc.obsCal.dateRange() 36 outputFile = None 37
38 - def _onRun(self):
39 """ 40 """ 41 42 fileList = self.archive.query( 43 selectStr="fileName,object,filterName,deprecated", 44 fromStr="Multiframe as m,ProgrammeFrame as p", 45 whereStr="p.programmeID=%s and m.multiframeID=p.multiframeID and " 46 "frameType in ('%s') and utDate BETWEEN '%s' AND '%s' and " 47 "deprecated<128" 48 % (self.programmeID, self.frameTypeList, self.dateRange[0], self.dateRange[1]), 49 orderBy="object,filterName,utdate") 50 outFileList = ["# FileName object filterName deprecated\n"] 51 outFileList += ["%s %s %s %s\n" % (os.path.basename(fileName), objectStr, filtName, depr) 52 for fileName, objectStr, filtName, depr in fileList] 53 file(self.outputFile, "w").writelines(outFileList)
54 55 56 #------------------------------------------------------------------------------ 57 # Entry point for script. 58 59 # Allow module to be imported as well as executed from the command line 60 if __name__ == "__main__": 61 CLI.progArgs +=[ 62 CLI.Argument("programmeID", "VVV"), 63 CLI.Argument("outputFile", "/disk47/sys/njc/VVV_DR2_releaseList.txt"), 64 CLI.Argument("begin_date", "05A", isValOK=CLI.isDateOK), 65 CLI.Argument("end_date", "05A", isValOK=CLI.isDateOK)] 66 67 CLI.progOpts += [ 68 CLI.Option('f', "frameTypes", 69 "Frame types of files", "LIST")] 70 71 72 cli = CLI("CreateReleaseFileList", "$Revision: 10172 $", __doc__) 73 Logger.isVerbose = False 74 Logger.addMessage(cli.getProgDetails()) 75 cu = CreateReleaseFileList(cli.getArg("programmeID"), cli=cli) 76 cu.outputFile = cli.getArg("outputFile") 77 try: 78 cu.dateRange = cu.sysc.obsCal.dateRange(cli.getArg("begin_date"), 79 cli.getArg("end_date")) 80 except Exception as error: 81 eType = "Invalid Option" 82 Logger.addExceptionMessage(error, eType) 83 raise SystemExit(eType + ": see log " + cu._log.pathName) 84 if cli.getOpt("frameTypes"): 85 cu.frameTypeList = cli.getOpt("frameTypes") 86 87 88 cu.run() 89 90 #----------------------------------------------------------------------------- 91 # Change log: 92 # 93 # 28-Oct-2009, NJC: Original version. 94