Commit df8fe410693a3d48b1d74731319be09c8c2e1409

Authored by Jürgen Knödlseder
1 parent 297614c4

Enhance csspec debugging capabilities

Showing 1 changed file with 27 additions and 1 deletions
cscripts/csspec.py
... ... @@ -555,6 +555,13 @@ class csspec(ctools.csobservation):
555 555 cubemask['rad'] = 'UNDEFINED'
556 556 cubemask['emin'] = emin.TeV()
557 557 cubemask['emax'] = emax.TeV()
  558 +
  559 + # If chatter level is verbose and debugging is requested then
  560 + # switch also on the debug model in ctcubemask
  561 + if self._logVerbose() and self._logDebug():
  562 + cubemask['debug'] = True
  563 +
  564 + # Select layers
558 565 cubemask.run()
559 566  
560 567 # Set new binned observation
... ... @@ -593,6 +600,13 @@ class csspec(ctools.csobservation):
593 600 select['emax'] = emax.TeV()
594 601 select['tmin'] = 'UNDEFINED'
595 602 select['tmax'] = 'UNDEFINED'
  603 +
  604 + # If chatter level is verbose and debugging is requested then
  605 + # switch also on the debug model in ctselect
  606 + if self._logVerbose() and self._logDebug():
  607 + select['debug'] = True
  608 +
  609 + # Run ctselect
596 610 select.run()
597 611  
598 612 # Retrieve observation
... ... @@ -640,10 +654,17 @@ class csspec(ctools.csobservation):
640 654 # Write header for fitting
641 655 self._log_header3(gammalib.EXPLICIT, 'Performing fit')
642 656  
643   - # Perform maximum likelihood fit
  657 + # Setup maximum likelihood fit
644 658 like = ctools.ctlike(obs)
645 659 like['edisp'] = self['edisp'].boolean()
646 660 like['nthreads'] = 1 # Avoids OpenMP conflict
  661 +
  662 + # If chatter level is verbose and debugging is requested then
  663 + # switch also on the debug model in ctlike
  664 + if self._logVerbose() and self._logDebug():
  665 + like['debug'] = True
  666 +
  667 + # Perform maximum likelihood fit
647 668 like.run()
648 669  
649 670 # Continue only if log-likelihood is non-zero
... ... @@ -674,6 +695,11 @@ class csspec(ctools.csobservation):
674 695 ulimit['srcname'] = self['srcname'].string()
675 696 ulimit['eref'] = elogmean.TeV()
676 697  
  698 + # If chatter level is verbose and debugging is requested
  699 + # then switch also on the debug model in ctulimit
  700 + if self._logVerbose() and self._logDebug():
  701 + ulimit['debug'] = True
  702 +
677 703 # Try to run upper limit and catch exceptions
678 704 try:
679 705 ulimit.run()
... ...