Package helpers :: Module SetupProgramme
[hide private]

Source Code for Module helpers.SetupProgramme

 1  #! /usr/bin/env python 
 2  #------------------------------------------------------------------------------ 
 3  # $Id: SetupProgramme.py 9072 2012-02-28 16:08:40Z NicholasCross $ 
 4  """ 
 5     Takes Multiframe info to calculate RequiredStacks for new survey. 
 6     Doesn't overwrite previous centres - if it finds a stack position 
 7     defined close to it's best position, it will defer to the given location 
 8     unless overwrite option is used. 
 9   
10     @author: N.J.G. Cross 
11     @org:    WFAU, IfA, University of Edinburgh 
12   
13     @newfield contributors: Contributors, Contributors (Alphabetical Order) 
14     @contributors: R.S. Collins 
15  """ 
16  #------------------------------------------------------------------------------ 
17  from wsatools.CLI              import CLI 
18  from wsatools.Logger           import Logger 
19  from wsatools.ProgrammeBuilder import ProgrammeBuilder 
20  #------------------------------------------------------------------------------ 
21  # Entry point for script. 
22   
23  # Allow module to be imported as well as executed from the command line 
24  if __name__ == "__main__": 
25      CLI.progArgs.append(CLI.Argument("programmeID", "DXS")) 
26      CLI.progArgs.append(CLI.Argument("begin_date", "05A", isValOK=CLI.isDateOK)) 
27      CLI.progArgs.append(CLI.Argument("end_date", "07A", isValOK=CLI.isDateOK)) 
28      CLI.progOpts += [ 
29        CLI.Option('b', "bm_crit", 
30          "Band-merging criterion (defaults to database value if available)", 
31          "NUMBER"), 
32        CLI.Option('d', "displayDeeps", 
33          "Display which pointings have multiple-epochs"), 
34        CLI.Option('k', "keep_old", 
35          "Keep old pointings when adding new ones"), 
36        CLI.Option('m', 'max_stacks', 
37          "Set the maximum number of components of a deep stack", 
38          "NUMBER", str(ProgrammeBuilder.numberStks), isValOK=lambda x: x.isdigit()), 
39        CLI.Option('n', "new_pointings", 
40          "Only modifies RequiredStack with new pointings"), 
41        CLI.Option('r', "recreate", 
42          "Recreate existing database schema"), 
43        CLI.Option('v', "verbose", 
44          "Make logging verbose")] 
45   
46      cli = CLI(ProgrammeBuilder, "$Revision: 9072 $") 
47      Logger.isVerbose = cli.getOpt("verbose") 
48      Logger.addMessage(cli.getProgDetails()) 
49   
50      cu = ProgrammeBuilder(cli.getArg("programmeID"), cli=cli) 
51      if cli.getOpt("bm_crit"): 
52          cu.bandMergeCrit = float(cli.getOpt("bm_crit")) 
53      try: 
54          cu.dateRange = cu.sysc.obsCal.dateRange(cli.getArg("begin_date"), 
55                                                  cli.getArg("end_date")) 
56      except Exception as error: 
57          eType = "Invalid Option" 
58          Logger.addExceptionMessage(error, eType) 
59          raise SystemExit(eType + ": see log " + cu._log.pathName) 
60   
61      cu.newPoints = cli.getOpt("new_pointings") 
62      cu.numberStks = int(cli.getOpt("max_stacks")) 
63      cu.redoSchema = cli.getOpt("recreate") 
64      cu.redoSetup = not cli.getOpt("keep_old") 
65      cu.displayDeeps = cli.getOpt("displayDeeps") 
66      cu.run() 
67   
68  #----------------------------------------------------------------------------- 
69  # Change log: 
70  # 
71  # 20-Jun-2008,  NJC: Original version. 
72  #  6-Jul-2008,  NJC: Updated to use registration info. Added better logging 
73  #                    and improved algorithm. Fixed bugs. 
74  #  8-Jul-2008,  NJC: Parses main schema, neighbour table schema and 
75  #                    indices schema and sets up tables. Neatened up. Updates 
76  #                    Programme and ProgrammeTable too. 
77  # 10-Jul-2008,  NJC: Refactored into OO code. This now runs as a CuSession. 
78  #                    It is much cleaner and handles repeat runs better. 
79  #                    Included totalExpTime in calculation. 
80  # 16-Sep-2008,  RSC: Revised in preparation for automatic non-survey curation. 
81