Commit c01c64f273f169c25020ac8c98ad521bbdfb0324
1 parent
b1679652
sim() function now returns both, the ctbin and ctobssim object. Before it return…
…ed the ctbin output in case of a binned analysis, which screwed up the cntmap function
Showing
1 changed file
with
9 additions
and
11 deletions
scripts/obsutils.py
| ... | ... | @@ -61,10 +61,15 @@ def sim(obs, log=False, debug=False, edisp=False, seed=0, nbins=0, |
| 61 | 61 | # events are not added together, they still apply to each observation |
| 62 | 62 | # separately. |
| 63 | 63 | sim.run() |
| 64 | + | |
| 65 | + # Make a deep copy of the observation that will be returned | |
| 66 | + # (the ctobssim object will go out of scope one the function is | |
| 67 | + # left) | |
| 68 | + obssim = sim.obs().copy() | |
| 69 | + obsbin = None | |
| 64 | 70 | |
| 65 | 71 | # Binned option? |
| 66 | 72 | if nbins > 0: |
| 67 | - | |
| 68 | 73 | # Determine common energy boundaries for observations |
| 69 | 74 | emin = None |
| 70 | 75 | emax = None |
| ... | ... | @@ -79,7 +84,7 @@ def sim(obs, log=False, debug=False, edisp=False, seed=0, nbins=0, |
| 79 | 84 | emax = run_emax |
| 80 | 85 | elif run_emax > emax: |
| 81 | 86 | emax = run_emax |
| 82 | - | |
| 87 | + | |
| 83 | 88 | # Allocate ctbin application and set parameters |
| 84 | 89 | bin = ctools.ctbin(sim.obs()) |
| 85 | 90 | bin["ebinalg"].string("LOG") |
| ... | ... | @@ -108,20 +113,13 @@ def sim(obs, log=False, debug=False, edisp=False, seed=0, nbins=0, |
| 108 | 113 | # Make a deep copy of the observation that will be returned |
| 109 | 114 | # (the ctbin object will go out of scope one the function is |
| 110 | 115 | # left) |
| 111 | - obs = bin.obs().copy() | |
| 116 | + obsbin = bin.obs().copy() | |
| 112 | 117 | |
| 113 | - else: | |
| 114 | - | |
| 115 | - # Make a deep copy of the observation that will be returned | |
| 116 | - # (the ctobssim object will go out of scope one the function is | |
| 117 | - # left) | |
| 118 | - obs = sim.obs().copy() | |
| 119 | - | |
| 120 | 118 | # Delete the simulation |
| 121 | 119 | del sim |
| 122 | 120 | |
| 123 | 121 | # Return observation container |
| 124 | - return obs | |
| 122 | + return obsbin,obssim | |
| 125 | 123 | |
| 126 | 124 | |
| 127 | 125 | # ================ # | ... | ... |