From 042be032774f3ea2ae6a302a4875fb4439859b74 Mon Sep 17 00:00:00 2001 From: dfidalgo Date: Tue, 10 May 2016 19:19:30 +0800 Subject: [PATCH 1/3] * Updated enrico/fitmaker.py, enrico/energybin.py, enrico/config/default.conf: - Now you can specify a ltcube in the config file. Enrico will skip the calculation of the ltcube and use the given file instead. - When doing the analysis for the spectral points, Enrico will now use the ltcube from the global fit, or the ltcube specified in the config file. - Now you can choose if you want to calculate MINOS errors or not through the config file. --- enrico/config/default.conf | 7 +++++-- enrico/energybin.py | 3 +++ enrico/fitmaker.py | 14 +++++++++----- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/enrico/config/default.conf b/enrico/config/default.conf index 6e165b7..4629eaa 100644 --- a/enrico/config/default.conf +++ b/enrico/config/default.conf @@ -20,6 +20,7 @@ Submit = option('yes', 'no', default='no') event = string(default=events.lis) xml = string(default=model.xml) tag = string(default='') + ltcube = string(default='') [environ] # Analysis environment configuration @@ -104,6 +105,8 @@ Submit = option('yes', 'no', default='no') FrozenSpectralIndex = float(default=0, min=0, max=5) #Use the summed likelihood method SummedLike = option('yes', 'no', default='no') + # Calculate MINOS errors? + minos = option('yes', 'no', default='yes') [UpperLimit] @@ -186,8 +189,8 @@ Submit = option('yes', 'no', default='no') rad = float(default=1) # list of sources srclist = string(default="") - # number of photons to print - numberPhoton = integer(default=10) + # number of photons to print + numberPhoton = integer(default=10) [Contours] parname1 = string(default="Prefactor") diff --git a/enrico/energybin.py b/enrico/energybin.py index 0b91052..4edb9e5 100755 --- a/enrico/energybin.py +++ b/enrico/energybin.py @@ -53,6 +53,9 @@ def PrepareEbin(Fit, FitRunner): #Replace the evt file with the fits file produced before #in order to speed up the production of the fits files config['file']['event'] = FitRunner.obs.eventfile + # use ltcube from global fit to speed up analysis + if config['file']['ltcube'] == "": + config['file']['ltcube'] = FitRunner.obs.Cubename #update the config to allow the fit in energy bins config['UpperLimit']['envelope'] = 'no' config['Ebin']['NumEnergyBins'] = '0'#no new bin in energy! diff --git a/enrico/fitmaker.py b/enrico/fitmaker.py index f86f584..00271ac 100755 --- a/enrico/fitmaker.py +++ b/enrico/fitmaker.py @@ -54,8 +54,11 @@ def GenerateFits(self): self.obs.DiffResps()#run gtdiffresp self._log('gtbin', 'Create a count map') self.obs.Gtbin() - self._log('gtltcube', 'Make live time cube')#run gtexpcube - self.obs.ExpCube() + if self.config["file"]["ltcube"] == "": + self._log('gtltcube', 'Make live time cube')#run gtexpcube + self.obs.ExpCube() + else: + self.obs.Cubename = self.config["file"]["ltcube"] #Choose between the binned of the unbinned analysis if self.config['analysis']['likelihood'] == 'binned': #binned analysis chain @@ -204,7 +207,8 @@ def GetAndPrintResults(self, Fit): Scale = spectrum.getParam(par).getScale() Result[par] = ParValue * Scale Result['d'+par] = ParError * Scale - if ParError>0: # Compute MINOS errors for relevent parameters Fit.Ts(self.obs.srcname) > 5 and + # Compute MINOS errors for relevent parameters Fit.Ts(self.obs.srcname) > 5 and + if ParError>0 and self.config['Spectrum']['minos'] == 'yes': try: MinosErrors = Fit.minosError(self.obs.srcname, par) if self.config['verbose'] == 'yes' : @@ -218,8 +222,8 @@ def GetAndPrintResults(self, Fit): (ParValue, ParError, Scale)) else: if self.config['verbose'] == 'yes' : - print(par+" : %2.2f %2.0e" % - (ParValue, Scale)) + print(par+" : %2.2f +/- %2.2f %2.0e" % + (ParValue, ParError, Scale)) try: # get covariance matrix if self.config['verbose'] == 'yes' : From 031332c6824c9d3cb9888b2005e1f5ca8d625500 Mon Sep 17 00:00:00 2001 From: dfidalgo Date: Mon, 16 May 2016 18:01:05 +0800 Subject: [PATCH 2/3] - implemented the ltcube option in a more consistent way. --- enrico/energybin.py | 3 +-- enrico/fitmaker.py | 4 ++-- enrico/gtfunction.py | 2 ++ 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/enrico/energybin.py b/enrico/energybin.py index 4edb9e5..0476292 100755 --- a/enrico/energybin.py +++ b/enrico/energybin.py @@ -54,8 +54,7 @@ def PrepareEbin(Fit, FitRunner): #in order to speed up the production of the fits files config['file']['event'] = FitRunner.obs.eventfile # use ltcube from global fit to speed up analysis - if config['file']['ltcube'] == "": - config['file']['ltcube'] = FitRunner.obs.Cubename + config['file']['ltcube'] = FitRunner.obs.Cubename #update the config to allow the fit in energy bins config['UpperLimit']['envelope'] = 'no' config['Ebin']['NumEnergyBins'] = '0'#no new bin in energy! diff --git a/enrico/fitmaker.py b/enrico/fitmaker.py index 00271ac..0f88522 100755 --- a/enrico/fitmaker.py +++ b/enrico/fitmaker.py @@ -54,11 +54,11 @@ def GenerateFits(self): self.obs.DiffResps()#run gtdiffresp self._log('gtbin', 'Create a count map') self.obs.Gtbin() + self._log('gtltcube', 'Make live time cube')#run gtexpcube if self.config["file"]["ltcube"] == "": - self._log('gtltcube', 'Make live time cube')#run gtexpcube self.obs.ExpCube() else: - self.obs.Cubename = self.config["file"]["ltcube"] + print("Using live time cube from %s" % self.config["file"]["ltcube"]) #Choose between the binned of the unbinned analysis if self.config['analysis']['likelihood'] == 'binned': #binned analysis chain diff --git a/enrico/gtfunction.py b/enrico/gtfunction.py index 11dc06d..3dfc0bd 100755 --- a/enrico/gtfunction.py +++ b/enrico/gtfunction.py @@ -33,6 +33,8 @@ def __init__(self,folder,Configuration,tag=""): #Fits files self.eventfile = folder+'/'+self.srcname+inttag+"_Evt.fits" self.Cubename = folder+'/'+self.srcname+inttag+"_ltCube.fits" + if Configuration['file']['ltcube'] != "": + self.Cubename = Configuration['file']['ltcube'] self.Mapname = folder+'/'+self.srcname+inttag+"_ExpMap.fits" self.BinnedMapfile = folder+'/'+self.srcname+inttag+"_BinnedMap.fits" self.cmapfile = folder+'/'+self.srcname+inttag+"_CountMap.fits" From 3876260d9d05a9fe60620c456eec91ec203bca49 Mon Sep 17 00:00:00 2001 From: dfidalgo Date: Thu, 26 May 2016 09:35:50 +0800 Subject: [PATCH 3/3] - fix in xml_model.py: * For the spec model PLSuperExpCutoff the cutoff_min was to high for some sources in the 3FGL. Reduced it to 100. --- enrico/xml_model.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/enrico/xml_model.py b/enrico/xml_model.py index c66235f..969b56c 100755 --- a/enrico/xml_model.py +++ b/enrico/xml_model.py @@ -215,7 +215,7 @@ def addPSPLSuperExpCutoff(lib, name, ra, dec, eflux=0, index1_free=1, index1_value=-2.0, index1_min=-10.0, index1_max=-0., cutoff_free=1, cutoff_value=1e4, - cutoff_min=200, cutoff_max=3e5, + cutoff_min=100, cutoff_max=3e5, index2_free=0, index2_value=1.0, index2_min=0.0, index2_max=10.0,extendedName=""): """Add a source with a SUPEREXPCUTOFF model"""