def cli():
    """Command-line interface.  Call this without any options for usage notes."""
    import getopt
    
    try:
        opts, args = getopt.getopt(sys.argv[1:], 'hiamxcb:n:', ['help',
                                                                'analyze',
                                                                'initialize',
                                                                ])
        #Loop through first and check for the basename
        haveBase = False
        basename = 'example'
        for opt,val in opts:
            if opt in ('-n','--basename'):
                haveBase = True
                basename = val

        for opt, val in opts:
            if opt in ('-h', '--help'):
                printCLIHelp()
                return
            elif opt in ('-a', '--analyze'):
                if not haveBase: raise getopt.GetoptError("Must specify basename, printing help.")
                qA = quickAnalysis(basename, True)
                qA.runAll(True)         
                return
            elif opt in ('-i', '--initialize'):
                print "Creating example configuration file called example.cfg"
                qA = quickAnalysis(basename)
                qA.writeConfig()
                return
            elif opt in ('-m','--modelmap'):
                if not haveBase: raise getopt.GetoptError("Must specify basename, printing help.")
                print "Creating model map"
                qA = quickAnalysis(basename, True)
                qU.runModel(qA.logger,qA.commonConf['base'],qA.commonConf['irfs'])
                return
            elif opt in ('--sourcemap'):
                if not haveBase: raise getopt.GetoptError("Must specify basename, printing help.")
                print "Creating source map"
                qA = quickAnalysis(basename, True)
                qA.runSrcMaps()
                return
            elif opt in ('--ccube'):
                if not haveBase: raise getopt.GetoptError("Must specify basename, printing help.")
                print "Creating counts cube"
                qA = quickAnalysis(basename, True)
                qA.runCCUBE()
                return
            elif opt in ('--bexpmap'):
                if not haveBase: raise getopt.GetoptError("Must specify basename, printing help.")
                print "Creating binned exposure map"
                qA = quickAnalysis(basename, True)
                qA.runExpCube()
                return
            elif opt in ('--filter'):
                if not haveBase: raise getopt.GetoptError("Must specify basename, printing help.")
                print "Creating filtered (selected and GTI'd) file"
                qA = quickAnalysis(basename, True)
                qA.runSelect()
                qA.runGTI()
                return
            elif opt in ('-x', '--xml'):
                if not haveBase: raise getopt.GetoptError("Must specify basename, printing help.")
                print "Creating XML model file from 2FGL"
                qA = quickAnalysis(basename, True)
                qA.generateXMLmodel()
                return
            elif opt in ('-c', '--cmap'):
                if not haveBase: raise getopt.GetoptError("Must specify basename, printing help.")
                print "Creating counts map"
                qA = quickAnalysis(basename, True)
                for option,value in opts:
                    if option in ('-b', '--binsize'): qA.analysisConf['binsize'] = value
                qA.runCMAP()
                return
                
        if not opts: raise getopt.GetoptError("Must specify an option, printing help.")

    except getopt.error as e:
        print "Command Line Error: " + e.msg
        printCLIHelp()
Ejemplo n.º 2
0
def cli():
    """Command-line interface.  Call this without any options for usage notes."""
    import getopt
    
    try:
        opts, args = getopt.getopt(sys.argv[1:], 'hiamxcb:n:', ['help',
                                                                'analyze',
                                                                'initialize',
                                                                'ccube',
                                                                'cmap',
                                                                'sourcemap',
                                                                'modelmap',
                                                                'ccube',
                                                                'bexpmap',
                                                                'filter',
                                                                'xml',
                                                                'binsize'
                                                                ])
        #Loop through first and check for the basename
        haveBase = False
        basename = 'example'
        for opt,val in opts:
            if opt in ('-n','--basename'):
                haveBase = True
                basename = val

        for opt, val in opts:
            if opt in ('-h', '--help'):
                printCLIHelp()
                return
            elif opt in ('-a', '--analyze'):
                if not haveBase: raise getopt.GetoptError("Must specify basename, printing help.")
                qA = quickAnalysis(basename, True)
                qA.runAll(True)         
                return
            elif opt in ('-i', '--initialize'):
                print "Creating example configuration file called example.cfg"
                qA = quickAnalysis(basename)
                qA.writeConfig()
                return
            elif opt in ('-m','--modelmap'):
                if not haveBase: raise getopt.GetoptError("Must specify basename, printing help.")
                print "Creating model map"
                qA = quickAnalysis(basename, True)
                qU.runModel(qA.logger,qA.commonConf['base'],qA.commonConf['irfs'])
                return
            elif opt in ('--sourcemap'):
                if not haveBase: raise getopt.GetoptError("Must specify basename, printing help.")
                print "Creating source map"
                qA = quickAnalysis(basename, True)
                qA.runSrcMaps()
                return
            elif opt in ('--ccube'):
                if not haveBase: raise getopt.GetoptError("Must specify basename, printing help.")
                print "Creating counts cube"
                qA = quickAnalysis(basename, True)
                qA.runCCUBE()
                return
            elif opt in ('--bexpmap'):
                if not haveBase: raise getopt.GetoptError("Must specify basename, printing help.")
                print "Creating binned exposure map"
                qA = quickAnalysis(basename, True)
                qA.runExpCube()
                return
            elif opt in ('--filter'):
                if not haveBase: raise getopt.GetoptError("Must specify basename, printing help.")
                print "Creating filtered (selected and GTI'd) file"
                qA = quickAnalysis(basename, True)
                qA.runSelect()
                qA.runGTI()
                return
            elif opt in ('-x', '--xml'):
                if not haveBase: raise getopt.GetoptError("Must specify basename, printing help.")
                print "Creating XML model file from 2FGL"
                qA = quickAnalysis(basename, True)
                qA.generateXMLmodel()
                return
            elif opt in ('-c', '--cmap'):
                if not haveBase: raise getopt.GetoptError("Must specify basename, printing help.")
                print "Creating counts map"
                qA = quickAnalysis(basename, True)
                for option,value in opts:
                    if option in ('-b', '--binsize'): qA.analysisConf['binsize'] = value
                qA.runCMAP()
                return
                
        if not opts: raise getopt.GetoptError("Must specify an option, printing help.")

    except getopt.error as e:
        print "Command Line Error: " + e.msg
        printCLIHelp()
    def runModel(self, run=True):

        """Wrapper for the same function in quickUtils"""

        qU.runModel(self.logger,self.commonConf['base'],self.commonConf['irfs'],run)
Ejemplo n.º 4
0
    def runModel(self, run=True):

        """Wrapper for the same function in quickUtils"""

        qU.runModel(self.logger,self.commonConf['base'],self.commonConf['irfs'],run)