Commit a5cfc4d81cf31a90c172b5ac5e10c74afc08f535

Authored by Jürgen Knödlseder
1 parent aa44445c

Do not skip bins with zero counts in csspec (#2672)

ChangeLog
@@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
3 * Version 1.6.0 released 3 * Version 1.6.0 released
4 ======================== 4 ========================
5 5
  6 + Do not skip bins with zero counts in csspec (#2672)
6 Use "ENERG" instead of "ETRUE" in energy dispersion axis names in csroot2caldb (#2670) 7 Use "ENERG" instead of "ETRUE" in energy dispersion axis names in csroot2caldb (#2670)
7 Add hidden "use_irf_bkg" parameter to csphagen (#2659) 8 Add hidden "use_irf_bkg" parameter to csphagen (#2659)
8 Use full RMF true energy range for On/Off analysis in csspec (#2656) 9 Use full RMF true energy range for On/Off analysis in csspec (#2656)
@@ -315,6 +315,8 @@ Add hidden "nthreads" parameter and implement parallelisation of computations @@ -315,6 +315,8 @@ Add hidden "nthreads" parameter and implement parallelisation of computations
315 315
316 csspec - Generates Spectral Energy Distribution 316 csspec - Generates Spectral Energy Distribution
317 ----------------------------------------------- 317 -----------------------------------------------
  318 +The script no longer skips energy bins with zero counts (#2672).
  319 +
318 The full true energy range of the RMF is now used in an On/Off analysis to 320 The full true energy range of the RMF is now used in an On/Off analysis to
319 prevent cutting off the tails of the energy dispersion, which happened before 321 prevent cutting off the tails of the energy dispersion, which happened before
320 when the script was used for the analysis of H.E.S.S. data (#2656). 322 when the script was used for the analysis of H.E.S.S. data (#2656).
cscripts/csspec.py
@@ -640,15 +640,14 @@ class csspec(ctools.csobservation): @@ -640,15 +640,14 @@ class csspec(ctools.csobservation):
640 # Write header for fitting 640 # Write header for fitting
641 self._log_header3(gammalib.EXPLICIT, 'Performing fit') 641 self._log_header3(gammalib.EXPLICIT, 'Performing fit')
642 642
643 - # Perform maximum likelihood fit. Skip bins that have no events. 643 + # Perform maximum likelihood fit
644 like = ctools.ctlike(obs) 644 like = ctools.ctlike(obs)
645 like['edisp'] = self['edisp'].boolean() 645 like['edisp'] = self['edisp'].boolean()
646 like['nthreads'] = 1 # Avoids OpenMP conflict 646 like['nthreads'] = 1 # Avoids OpenMP conflict
647 - if like.obs().nobserved() > 0:  
648 - like.run() 647 + like.run()
649 648
650 # Continue only if log-likelihood is non-zero 649 # Continue only if log-likelihood is non-zero
651 - if like.obs().logL() != 0.0 and like.obs().nobserved() > 0: 650 + if like.obs().logL() != 0.0:
652 651
653 # Get results 652 # Get results
654 fitted_models = like.obs().models() 653 fitted_models = like.obs().models()
@@ -715,7 +714,7 @@ class csspec(ctools.csobservation): @@ -715,7 +714,7 @@ class csspec(ctools.csobservation):
715 # ... otherwise if logL is zero then signal that bin is 714 # ... otherwise if logL is zero then signal that bin is
716 # skipped 715 # skipped
717 else: 716 else:
718 - value = 'No event in this bin. Likelihood is zero. Bin is skipped.' 717 + value = 'Likelihood is zero. Bin is skipped.'
719 self._log_value(gammalib.TERSE, 'Bin '+str(i+1), value) 718 self._log_value(gammalib.TERSE, 'Bin '+str(i+1), value)
720 719
721 # Return result 720 # Return result
doc/source/admin/release_history/1.6.rst
@@ -32,6 +32,8 @@ Bug fixes @@ -32,6 +32,8 @@ Bug fixes
32 Improvements 32 Improvements
33 ------------ 33 ------------
34 34
  35 +* [`2672 <https://cta-redmine.irap.omp.eu/issues/2672>`_] -
  36 + Do not skip bins with zero counts in :ref:`csspec`
35 * [`2670 <https://cta-redmine.irap.omp.eu/issues/2670>`_] - 37 * [`2670 <https://cta-redmine.irap.omp.eu/issues/2670>`_] -
36 Use ``ENERG`` instead of ``ETRUE`` in energy dispersion axis names in 38 Use ``ENERG`` instead of ``ETRUE`` in energy dispersion axis names in
37 :ref:`csroot2caldb` 39 :ref:`csroot2caldb`