From 744353cd5e740343e4d7a4e02085932896765b3d Mon Sep 17 00:00:00 2001 From: Mireia Nievas Date: Thu, 28 Feb 2019 14:06:17 +0100 Subject: [PATCH] Attempt to fix https://github.com/gammapy/enrico/issues/130#issuecomment-468256917 --- enrico/RunGTlike.py | 18 ++++++++++-------- enrico/lightcurve.py | 4 +++- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/enrico/RunGTlike.py b/enrico/RunGTlike.py index 1047af2..9035f75 100755 --- a/enrico/RunGTlike.py +++ b/enrico/RunGTlike.py @@ -181,21 +181,23 @@ def run(infile): #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'] + FitRunner.config['file']['parent_config'] = infile + + if config['Spectrum']['ResultParentPlots'] == "yes": + plot_sed_fromconfig(get_config(config['file']['parent_config']),ignore_missing_bins=True) + 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) - FitRunner.config['Spectrum']['ResultParentPlots'] = "yes" + if Nbin>0: + FitRunner.config['Spectrum']['ResultParentPlots'] = "yes" plot_sed_fromconfig(get_config(infile),ignore_missing_bins=True) - if config['Spectrum']['ResultParentPlots'] == "yes": - plot_sed_fromconfig(get_config(config['file']['parent_config']),ignore_missing_bins=True) - - # Make energy bins by running a *new* analysis - Nbin = config['Ebin']['NumEnergyBins'] - energybin.RunEbin(folder,Nbin,Fit,FitRunner,sedresult) del(sedresult) diff --git a/enrico/lightcurve.py b/enrico/lightcurve.py index 68b14d3..1be8b85 100755 --- a/enrico/lightcurve.py +++ b/enrico/lightcurve.py @@ -49,8 +49,9 @@ def __init__(self, config, parent_filename=""): self.config['UpperLimit']['TSlimit'] = self.config['LightCurve']['TSLightCurve'] self.folder = self.config['out'] - + # Do not create plots self.config['Spectrum']['ResultPlots'] = 'no' # no + self.config['Spectrum']['ResultParentPlots'] = 'no' # no self.config['Ebin']['NumEnergyBins'] = 0 self.config['energy']['decorrelation_energy'] = 'yes' # no self.config['UpperLimit']['envelope'] = 'no' @@ -126,6 +127,7 @@ def PrepareLC(self,write = 'no'): str(self.config['time']['tmin']) + "_" + str(self.config['time']['tmax'])) + ".xml" #Name of the xml file self.config['file']['xml'] = xmlfilename + # Do not produce spectral plots if len(self.gtifile)==1: self.config['time']['file']=self.gtifile[0]