Commit 4d3a0338b697063bc9916a296eeee7dabe3a2241

Authored by Jürgen Knödlseder
1 parent 7c0b42c3

Do not use cube response for unbinned observations

Showing 1 changed file with 11 additions and 35 deletions
cscripts/csresspec.py
... ... @@ -253,42 +253,15 @@ class csresspec(ctools.csobservation):
253 253 cntcube['ebinfile'] = self['ebinfile'].filename()
254 254 else:
255 255 cntcube['enumbins'] = self['enumbins'].integer()
256   - cntcube['emin'] = self['emin'].real()
257   - cntcube['emax'] = self['emax'].real()
  256 + cntcube['emin'] = self['emin'].real()
  257 + cntcube['emax'] = self['emax'].real()
258 258 cntcube.run()
259 259  
260 260 # Retrieve the binned observation container
261 261 binned_obs = cntcube.obs().copy()
262 262  
263   - # Log response computation
264   - self._log_string(gammalib.EXPLICIT, 'Computing binned response')
265   -
266   - # Compute binned response
267   - response = obsutils.get_stacked_response(obs, ra, dec,
268   - binsz=0.02,
269   - nxpix=npix,
270   - nypix=npix,
271   - coordsys='CEL',
272   - proj='TAN',
273   - emin=self['emin'].real(),
274   - emax=self['emax'].real(),
275   - edisp=self['edisp'].boolean())
276   -
277   - if self['edisp'].boolean():
278   - binned_obs[0].response(response['expcube'], response['psfcube'],
279   - response['edispcube'], response['bkgcube'])
280   - else:
281   - binned_obs[0].response(response['expcube'], response['psfcube'],
282   - response['bkgcube'])
283   -
284   - # Get new models
285   - models = response['models']
286   -
287   - # Set models for observation container
288   - binned_obs.models(models)
289   -
290   - # Check if energy boundaries provided by user extend beyond
291   - # the content of the event list
  263 + # Check if energy boundaries provided by user extend beyond the
  264 + # content of the event list
292 265 if self['emin'].real() > obs[0].events().emin().TeV():
293 266 emin = 'INDEF'
294 267 else:
... ... @@ -601,21 +574,24 @@ class csresspec(ctools.csobservation):
601 574 # Calculate models of individual components if requested
602 575 if self['components'].boolean():
603 576 for component in obs.models():
  577 +
  578 + # Log component
604 579 self._log_value(gammalib.NORMAL,
605   - 'Computing model for component',
  580 + 'Computing model component',
606 581 component.name())
607   - # Set model cube models to
608   - # individual component
  582 +
  583 + # Set model cube models to individual component
609 584 model_cont = gammalib.GModels()
610 585 model_cont.append(component)
611 586 modelcube.obs().models(model_cont)
612 587  
613 588 # Run model cube
  589 + modelcube['edisp'] = self['edisp'].boolean()
614 590 modelcube.run()
615 591  
616 592 # Extract spectrum of individual component
617 593 modcube = modelcube.cube().copy()
618   - model = self._cube_to_spectrum(modcube, evlist_info)
  594 + model = self._cube_to_spectrum(modcube, evlist_info)
619 595  
620 596 # append component to table
621 597 table = self._append_column(table, component.name(),
... ...