def run(infile): from enrico import utils from enrico import energybin from enrico.config import get_config """Run an entire Fermi analysis (spectrum) by reading a config file""" config = get_config(infile) folder = config['out'] utils.create_dir(folder) FitRunner,Fit = GenAnalysisObjects(config) # create all the fit files and run gtlike FitRunner.PerformFit(Fit) Result = FitRunner.GetAndPrintResults(Fit)#Get and dump the target specific results utils.DumpResult(Result, config) #plot the SED and model map if possible and asked if config['Spectrum']['ResultPlots'] == 'yes' : from enrico.constants import SpectrumPath utils.create_dir("%s/%s/" %(config['out'],SpectrumPath)) if float(config['UpperLimit']['TSlimit']) < Fit.Ts(config['target']['name']): FitRunner.ComputeSED(Fit) outXml = utils._dump_xml(config) if config['Spectrum']['SummedLike'] != 'yes': # the possiblity of making the model map is checked inside the function FitRunner.ModelMap(outXml) # Make energy bins by running a *new* analysis Nbin = config['Ebin']['NumEnergyBins'] energybin.RunEbin(folder,Nbin,Fit,FitRunner) del(Result) del(FitRunner)
def run(infile): from enrico import utils from enrico import energybin from enrico.config import get_config from enrico import Loggin mes = Loggin.Message() """Run an entire Fermi analysis (spectrum) by reading a config file""" config = get_config(infile) folder = config['out'] utils.create_dir(folder) FitRunner,Fit = GenAnalysisObjects(config) # create all the fit files and run gtlike FitRunner.PerformFit(Fit) #plot the SED and model map if possible and asked if float(config['UpperLimit']['TSlimit']) < Fit.Ts(config['target']['name']): if config['Spectrum']['ResultPlots'] == 'yes': from enrico.constants import SpectrumPath utils.create_dir("%s/%s/" %(config['out'],SpectrumPath)) sedresult = FitRunner.ComputeSED(Fit,dump=True) else: sedresult = FitRunner.ComputeSED(Fit,dump=False) # Update the energy scale to decorrelation energy mes.info('Setting the decorrelation energy as new Scale for the spectral parameters') spectrum = Fit[FitRunner.obs.srcname].funcs['Spectrum'] modeltype = spectrum.genericName() if Fit.model.srcs[FitRunner.obs.srcname].spectrum().genericName()=="PowerLaw": varscale = "Scale" if Fit.model.srcs[FitRunner.obs.srcname].spectrum().genericName()=="PowerLaw2": varscale = None elif Fit.model.srcs[FitRunner.obs.srcname].spectrum().genericName()=="PLSuperExpCutoff": varscale = "Scale" elif Fit.model.srcs[FitRunner.obs.srcname].spectrum().genericName()=="LogParabola": varscale = "Eb" elif Fit.model.srcs[FitRunner.obs.srcname].spectrum().genericName()=="BrokenPowerLaw": varscale = "Eb" if varscale is not None: spectrum.getParam(varscale).setValue(sedresult.decE) FitRunner.PerformFit(Fit) if config['Spectrum']['ResultPlots'] == 'yes' : outXml = utils._dump_xml(config) if config['Spectrum']['SummedLike'] != 'yes': # the possiblity of making the model map is checked inside the function FitRunner.ModelMap(outXml) #Get and dump the target specific results Result = FitRunner.GetAndPrintResults(Fit) utils.DumpResult(Result, config) # Make energy bins by running a *new* analysis Nbin = config['Ebin']['NumEnergyBins'] energybin.RunEbin(folder,Nbin,Fit,FitRunner) del(Result) del(FitRunner)
def run(infile): from enrico import utils from enrico import energybin from enrico.config import get_config from enrico import Loggin mes = Loggin.Message() """Run an entire Fermi analysis (spectrum) by reading a config file""" config = get_config(infile) folder = config['out'] utils.create_dir(folder) FitRunner,Fit = GenAnalysisObjects(config) # create all the fit files and run gtlike FitRunner.PerformFit(Fit) sedresult = None #plot the SED and model map if possible and asked if float(config['UpperLimit']['TSlimit']) < Fit.Ts(config['target']['name']): if config['Spectrum']['ResultPlots'] == 'yes': from enrico.constants import SpectrumPath utils.create_dir("%s/%s/" %(config['out'],SpectrumPath)) sedresult = FitRunner.ComputeSED(Fit,dump=True) else: sedresult = FitRunner.ComputeSED(Fit,dump=False) if (config['energy']['decorrelation_energy'] == 'yes'): #Update the energy scale to decorrelation energy mes.info('Setting the decorrelation energy as new Scale for the spectral parameters') spectrum = Fit[FitRunner.obs.srcname].funcs['Spectrum'] modeltype = spectrum.genericName() genericName = Fit.model.srcs[FitRunner.obs.srcname].spectrum().genericName() varscale = None if genericName=="PowerLaw2": varscale = None elif genericName in ["PowerLaw", "PLSuperExpCutoff", "EblAtten::PLSuperExpCutoff"]: varscale = "Scale" elif genericName in ["LogParabola","EblAtten::LogParabola", \ "BrokenPowerLaw", "EblAtten::BrokenPowerLaw"]: varscale = "Eb" if varscale is not None: spectrum.getParam(varscale).setValue(sedresult.decE) FitRunner.PerformFit(Fit) #Get and dump the target specific results Result = FitRunner.GetAndPrintResults(Fit) utils.DumpResult(Result, config) if config['Spectrum']['ResultPlots'] == 'yes' : outXml = utils._dump_xml(config) # the possibility of making the model map is checked inside the function FitRunner.ModelMap(outXml) # Make energy bins by running a *new* analysis Nbin = config['Ebin']['NumEnergyBins'] energybin.RunEbin(folder,Nbin,Fit,FitRunner,sedresult) del(sedresult) del(Result) del(FitRunner)