From c01c64f273f169c25020ac8c98ad521bbdfb0324 Mon Sep 17 00:00:00 2001 From: sohm Date: Tue, 8 Jul 2014 17:38:13 +0200 Subject: [PATCH] sim() function now returns both, the ctbin and ctobssim object. Before it returned the ctbin output in case of a binned analysis, which screwed up the cntmap function --- scripts/obsutils.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/scripts/obsutils.py b/scripts/obsutils.py index 73fc8f0..0f01841 100755 --- a/scripts/obsutils.py +++ b/scripts/obsutils.py @@ -61,10 +61,15 @@ def sim(obs, log=False, debug=False, edisp=False, seed=0, nbins=0, # events are not added together, they still apply to each observation # separately. sim.run() + + # Make a deep copy of the observation that will be returned + # (the ctobssim object will go out of scope one the function is + # left) + obssim = sim.obs().copy() + obsbin = None # Binned option? if nbins > 0: - # Determine common energy boundaries for observations emin = None emax = None @@ -79,7 +84,7 @@ def sim(obs, log=False, debug=False, edisp=False, seed=0, nbins=0, emax = run_emax elif run_emax > emax: emax = run_emax - + # Allocate ctbin application and set parameters bin = ctools.ctbin(sim.obs()) bin["ebinalg"].string("LOG") @@ -108,20 +113,13 @@ def sim(obs, log=False, debug=False, edisp=False, seed=0, nbins=0, # Make a deep copy of the observation that will be returned # (the ctbin object will go out of scope one the function is # left) - obs = bin.obs().copy() + obsbin = bin.obs().copy() - else: - - # Make a deep copy of the observation that will be returned - # (the ctobssim object will go out of scope one the function is - # left) - obs = sim.obs().copy() - # Delete the simulation del sim # Return observation container - return obs + return obsbin,obssim # ================ # -- libgit2 0.21.4