Esempio n. 1
0
    def __init__(self,
                 base = 'MySource',
                 configFile = False,
                 curveConfig = {'tstart'  : 0,
                                'tstop'   : 0,
                                'tstep'   : 86400,
                                'tsmin'   : 1,
                                'model'   : 'my_model.xml',
                                'summary' : 'lc_summary.dat',
                                'output'  : 'lc.pickle',
                                'ulfluxdf' : 2.0,
                                'ulbayes'  : 4.0,
                                'ulchi2'  : 4,
                                'ulcl'    : 0.95,
                                'opt'     : 'MINUIT',
                                'sliding' : False,
                                'rebin'   : 1},
                 analysisConfig = {"ra" : 0,
                                   "dec" : 0,
                                   "rad" : 10,
                                   "tmin" : "INDEF",
                                   "tmax" : "INDEF",
                                   "emin" : 100,
                                   "emax" : 300000,
                                   "zmax" : 100,
                                   "ltzmax" : 180,
                                   "binsize" : 0.1,
                                   "convtype" : -1,
                                   "filter" : "DATA_QUAL==1 && LAT_CONFIG==1",
                                   "roicut" : "yes"},
                 likelihoodConfig = {"model" : "MySource_model.xml",
                                     "sourcename" : "Source Name",
                                     "drmtol" : 0.1,
                                     "mintol" : 1e-4},
                 commonConfig = {"base" : 'MySource',
                                 "eventclass" : 2,
                                 "binned" : False,
                                 "irfs" : "P7REP_SOURCE_V15",
                                 "verbosity" : 0}):
        
        commonConfig['base'] = base
        
        self.logger = qU.initLogger(base, 'quickCurve')
        
        if(configFile):
            try:
                commonConfigRead,analysisConfigRead,\
                    likelihoodConfigRead,plotConfigRead,curveConfigRead = qU.readConfig(self.logger,base)
            except(qU.FileNotFound):
                self.logger.critical("One or more needed files do not exist")
                return
            try:
                commonConfig = qU.checkConfig(self.logger,commonConfig,commonConfigRead)
            except(KeyError):
                return
            try:
                likelihoodConfig = qU.checkConfig(self.logger,likelihoodConfig,likelihoodConfigRead)
            except(KeyError):
                return
            try:
                analysisConfig = qU.checkConfig(self.logger,analysisConfig,analysisConfigRead)
            except(KeyError):
                return
            try:
                curveConfig = qU.checkConfig(self.logger,curveConfig,curveConfigRead)
            except(KeyError):
                return

        self.commonConf = commonConfig
        self.curveConf = curveConfig
        self.likelihoodConf = likelihoodConfig
        self.analysisConf = analysisConfig

        self.model = self.curveConf['model']
        self.ft2 = self.commonConf['base']+"_SC.fits"
        self.irfs = self.commonConf['irfs']
        self.optimizer = self.curveConf['opt']

        self.lc = []
        self.obsfiles=[]
Esempio n. 2
0
    def __init__(self,
                 base = 'MySource',
                 configFile = False,
                 curveConfig = {'tstart' : 0,
                                'tstop' : 0,
                                'tstep' : 86400,
                                'tsmin' : 4,
                                'model' : 'my_model.xml'},
                 analysisConfig = {"ra" : 0,
                                   "dec" : 0,
                                   "rad" : 10,
                                   "tmin" : "INDEF",
                                   "tmax" : "INDEF",
                                   "emin" : 100,
                                   "emax" : 300000,
                                   "zmax" : 100,
                                   "binsize" : 0.1,
                                   "convtype" : -1},
                 likelihoodConfig = {"model" : "MySource_model.xml",
                                     "sourcename" : "Source Name",
                                     "drmtol" : 0.1,
                                     "mintol" : 1e-4},
                 commonConfig = {"base" : 'MySource',
                                 "eventclass" : 2,
                                 "binned" : False,
                                 "irfs" : "P7SOURCE_V6",
                                 "verbosity" : 0}):
        
        commonConfig['base'] = base
        
        self.logger = qU.initLogger(base, 'quickCurve')
        
        if(configFile):
            try:
                commonConfigRead,analysisConfigRead,likelihoodConfigRead,plotConfigRead,curveConfigRead = qU.readConfig(self.logger,base)
            except(qU.FileNotFound):
                self.logger.critical("One or more needed files do not exist")
                return
            try:
                commonConfig = qU.checkConfig(self.logger,commonConfig,commonConfigRead)
            except(KeyError):
                return
            try:
                likelihoodConfig = qU.checkConfig(self.logger,likelihoodConfig,likelihoodConfigRead)
            except(KeyError):
                return
            try:
                analysisConfig = qU.checkConfig(self.logger,analysisConfig,analysisConfigRead)
            except(KeyError):
                return
            try:
                curveConfig = qU.checkConfig(self.logger,curveConfig,curveConfigRead)
            except(KeyError):
                return

        self.commonConf = commonConfig
        self.curveConf = curveConfig
        self.likelihoodConf = likelihoodConfig
        self.analysisConf = analysisConfig
Esempio n. 3
0
    def __init__(
        self,
        base='MySource',
        configFile=False,
        likelihoodConfig={
            "model": "MySource_model.xml",
            "sourcename": "Source Name",
            "drmtol": 0.1,
            "mintol": 1e-4
        },
        commonConfig={
            "base": 'MySource',
            "eventclass": 2,
            "binned": False,
            "irfs": "P7SOURCE_V6",
            "verbosity": 0,
            "multicore": 0
        }):

        commonConfig['base'] = base

        self.logger = qU.initLogger(base, 'quickLike')

        if (configFile):
            try:
                commonConfigRead, analysisConfigRead, likelihoodConfigRead, plotConfigRead, curveConfigRead = qU.readConfig(
                    self.logger, base)
            except (qU.FileNotFound):
                self.logger.critical("One or more needed files do not exist")
                return
            try:
                commonConfig = qU.checkConfig(self.logger, commonConfig,
                                              commonConfigRead)
            except (KeyError):
                return
            try:
                likelihoodConfig = qU.checkConfig(self.logger,
                                                  likelihoodConfig,
                                                  likelihoodConfigRead)
            except (KeyError):
                return

        self.commonConf = commonConfig
        self.likelihoodConf = likelihoodConfig

        self.ret = re.compile('\n')
        self.fitbit = False
        self.Print()
Esempio n. 4
0
    def __init__(self,
                 base = 'MySource',
                 configFile = False,
                 likelihoodConfig = {"model" : "MySource_model.xml",
                                     "sourcename" : "Source Name",
                                     "drmtol" : 0.1,
                                     "mintol" : 1e-4},
                 commonConfig = {"base" : 'MySource',
                                 "eventclass" : 2,
                                 "binned" : False,
                                 "irfs" : "P7SOURCE_V6",
                                 "verbosity" : 0,
                                 "multicore" : 0}):
                                  
        commonConfig['base'] = base

        self.logger = qU.initLogger(base, 'quickLike')

        if(configFile):
            try:
                commonConfigRead,analysisConfigRead,likelihoodConfigRead,plotConfigRead,curveConfigRead = qU.readConfig(self.logger,base)
            except(qU.FileNotFound):
                self.logger.critical("One or more needed files do not exist")
                return
            try:
                commonConfig = qU.checkConfig(self.logger,commonConfig,commonConfigRead)
            except(KeyError):
                return
            try:
                likelihoodConfig = qU.checkConfig(self.logger,likelihoodConfig,likelihoodConfigRead)
            except(KeyError):
                return

        self.commonConf = commonConfig
        self.likelihoodConf = likelihoodConfig
        
        self.ret = re.compile('\n')
        self.fitbit = False
        self.Print()
    def __init__(self,
                 base='MySource',
                 configFile = False,
                 analysisConfig = {"ra" : 0,
                                   "dec" : 0,
                                   "rad" : 10,
                                   "tmin" : "INDEF",
                                   "tmax" : "INDEF",
                                   "emin" : 100,
                                   "emax" : 300000,
                                   "zmax" : 100,
                                   "ltzmax" : 180,
                                   "binsize" : 0.1,
                                   "convtype" : -1,
                                   "filter" : "DATA_QUAL==1 && LAT_CONFIG==1",
                                   "roicut" : "yes"},
                 commonConfig = {"base" : 'MySource',
                                 "binned" : False,
                                 "eventclass" : 2,
                                 "irfs" : "P7REP_SOURCE_V15",
                                 "verbosity" : 0,
                                 "multicore": 0}):

        commonConfig['base'] = base

        self.logger = qU.initLogger(base, 'quickAnalysis')

        if(configFile):
            try:
                commonConfigRead,analysisConfigRead,likelihoodConfigRead,plotConfigRead,curveConfigRead = qU.readConfig(self.logger,base)
            except(qU.FileNotFound):
                self.logger.critical("One or more needed files do not exist.")
                sys.exit()
            try:
                commonConfig = qU.checkConfig(self.logger,commonConfig,commonConfigRead)
            except(KeyError):
                sys.exit()
            try:
                analysisConfig = qU.checkConfig(self.logger,analysisConfig,analysisConfigRead)
            except(KeyError):
                sys.exit()

        self.commonConf = commonConfig
        self.analysisConf = analysisConfig

        logString = "Created quickAnalysis object: "
        for variable, value in commonConfig.iteritems():
            logString += variable+"="+str(value)+","
        for variable, value in analysisConfig.iteritems():
            logString += variable+"="+str(value)+","
        self.logger.info(logString)
    def __init__(self,
                 base='MySource',
                 configFile = False,
                 analysisConfig = dC.defaultAnalysisConfig,
                 commonConfig = dC.defaultCommonConfig):

        commonConfig['base'] = base
        
        #Fills in missing items from the config arguments with default values
        for k in dC.defaultCommonConfig:
            commonConfig.setdefault(k, dC.defaultCommonConfig[k])
        for k in dC.defaultAnalysisConfig:
            analysisConfig.setdefault(k, dC.defaultAnalysisConfig[k])

        self.logger = Logger(base, self.__class__.__name__,ll(commonConfig['verbosity'])).get()
        self.logger.info("This is quickLike version {}.".format(__version__))

        if(configFile):
            try:
                commonConfigRead,analysisConfigRead,likelihoodConfigRead,plotConfigRead,curveConfigRead = qU.readConfig(self.logger,base)
            except(qU.FileNotFound):
                self.logger.critical("One or more needed files do not exist.")
                sys.exit()
            try:
                commonConfig = qU.checkConfig(self.logger,commonConfig,commonConfigRead)
            except(KeyError):
                sys.exit()
            #Reset the verboisty from the config file if needed
            if ll(commonConfig['verbosity']) != self.logger.handlers[1].level:
                self.logger.info("Resetting the log level on the console to {}.".format(commonConfig['verbosity']))
                self.logger.handlers[1].setLevel(ll(commonConfig['verbosity']))
            try:
                analysisConfig = qU.checkConfig(self.logger,analysisConfig,analysisConfigRead)
            except(KeyError):
                sys.exit()
        
        self.commonConf = commonConfig
        self.analysisConf = analysisConfig
        
        logString = "Created quickAnalysis object: "
        for variable, value in commonConfig.iteritems():
            logString += variable+"="+str(value)+","
        for variable, value in analysisConfig.iteritems():
            logString += variable+"="+str(value)+","
        self.logger.info(logString)
    def __init__(self,
                 base='MySource',
                 configFile = False,
                 analysisConfig = {"ra" : 0,
                                   "dec" : 0,
                                   "rad" : 10,
                                   "tmin" : "INDEF",
                                   "tmax" : "INDEF",
                                   "emin" : 100,
                                   "emax" : 300000,
                                   "zmax" : 100,
                                   "ltzmax" : 180,
                                   "binsize" : 0.1,
                                   "convtype" : -1,
                                   "nxpix" : -1,
                                   "nypix" : -1,
                                   "filter" : "DATA_QUAL==1 && LAT_CONFIG==1",
                                   "roicut" : "yes"},
                 commonConfig = {"base" : 'MySource',
                                 "binned" : False,
                                 "eventclass" : 2,
                                 "irfs" : "P7REP_SOURCE_V15",
                                 "verbosity" : 0,
                                 "multicore": 0}):

        commonConfig['base'] = base

        self.logger = qU.initLogger(base, 'quickAnalysis')

        if(configFile):
            try:
                commonConfigRead,analysisConfigRead,likelihoodConfigRead,plotConfigRead,curveConfigRead = qU.readConfig(self.logger,base)
            except(qU.FileNotFound):
                self.logger.critical("One or more needed files do not exist.")
                sys.exit()
            try:
                commonConfig = qU.checkConfig(self.logger,commonConfig,commonConfigRead)
            except(KeyError):
                sys.exit()
            try:
                analysisConfig = qU.checkConfig(self.logger,analysisConfig,analysisConfigRead)
            except(KeyError):
                sys.exit()

        self.commonConf = commonConfig
        self.analysisConf = analysisConfig

        logString = "Created quickAnalysis object: "
        for variable, value in commonConfig.iteritems():
            logString += variable+"="+str(value)+","
        for variable, value in analysisConfig.iteritems():
            logString += variable+"="+str(value)+","
        self.logger.info(logString)