From a5cfc4d81cf31a90c172b5ac5e10c74afc08f535 Mon Sep 17 00:00:00 2001 From: Jürgen Knödlseder Date: Fri, 7 Sep 2018 16:04:21 +0200 Subject: [PATCH] Do not skip bins with zero counts in csspec (#2672) --- ChangeLog | 1 + NEWS | 2 ++ cscripts/csspec.py | 9 ++++----- doc/source/admin/release_history/1.6.rst | 2 ++ 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 80bf4e7..a7ca8b9 100755 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,7 @@ * Version 1.6.0 released ======================== + Do not skip bins with zero counts in csspec (#2672) Use "ENERG" instead of "ETRUE" in energy dispersion axis names in csroot2caldb (#2670) Add hidden "use_irf_bkg" parameter to csphagen (#2659) Use full RMF true energy range for On/Off analysis in csspec (#2656) diff --git a/NEWS b/NEWS index 6b09d07..1629754 100755 --- a/NEWS +++ b/NEWS @@ -315,6 +315,8 @@ Add hidden "nthreads" parameter and implement parallelisation of computations csspec - Generates Spectral Energy Distribution ----------------------------------------------- +The script no longer skips energy bins with zero counts (#2672). + The full true energy range of the RMF is now used in an On/Off analysis to prevent cutting off the tails of the energy dispersion, which happened before when the script was used for the analysis of H.E.S.S. data (#2656). diff --git a/cscripts/csspec.py b/cscripts/csspec.py index de3c716..1790122 100755 --- a/cscripts/csspec.py +++ b/cscripts/csspec.py @@ -640,15 +640,14 @@ class csspec(ctools.csobservation): # Write header for fitting self._log_header3(gammalib.EXPLICIT, 'Performing fit') - # Perform maximum likelihood fit. Skip bins that have no events. + # Perform maximum likelihood fit like = ctools.ctlike(obs) like['edisp'] = self['edisp'].boolean() like['nthreads'] = 1 # Avoids OpenMP conflict - if like.obs().nobserved() > 0: - like.run() + like.run() # Continue only if log-likelihood is non-zero - if like.obs().logL() != 0.0 and like.obs().nobserved() > 0: + if like.obs().logL() != 0.0: # Get results fitted_models = like.obs().models() @@ -715,7 +714,7 @@ class csspec(ctools.csobservation): # ... otherwise if logL is zero then signal that bin is # skipped else: - value = 'No event in this bin. Likelihood is zero. Bin is skipped.' + value = 'Likelihood is zero. Bin is skipped.' self._log_value(gammalib.TERSE, 'Bin '+str(i+1), value) # Return result diff --git a/doc/source/admin/release_history/1.6.rst b/doc/source/admin/release_history/1.6.rst index 40a50dc..8e30765 100644 --- a/doc/source/admin/release_history/1.6.rst +++ b/doc/source/admin/release_history/1.6.rst @@ -32,6 +32,8 @@ Bug fixes Improvements ------------ +* [`2672 `_] - + Do not skip bins with zero counts in :ref:`csspec` * [`2670 `_] - Use ``ENERG`` instead of ``ETRUE`` in energy dispersion axis names in :ref:`csroot2caldb` -- libgit2 0.21.4