Commit a1592060025356308d53f770069094013a401eb7

Authored by Jürgen Knödlseder
1 parent 813385c9

Log warning if edisp=no (#2842)

ChangeLog
1   -2019-02-15
  1 +2019-03-06
2 2  
3 3 * Version 1.6.0 released
4 4 ========================
5 5  
  6 + Log warning if edisp=no (#2842)
6 7 Add max_iter parameter to ctbutterfly, cterror, ctlike, cttsmap,
7 8 ctulimit and cstsmapsplit
8 9 ctbkgcube now requires an input counts cube (#2763)
... ...
1 1 New Features and Important Changes in ctools 1.6.0
2 2  
3   -5 February 2019
  3 +6 March 2019
4 4  
5 5  
6 6 Introduction
... ... @@ -42,6 +42,10 @@ None
42 42  
43 43 Base classes
44 44 ------------
  45 +The ctool base class now implements a log_parameters() method that overwrites
  46 +the base class method and that logs a warning if the tool has an "edisp"
  47 +parameter but the parameter is set to "no" (#2842).
  48 +
45 49 The ctool base class now loads the application parameters from the file provided
46 50 in the "syspfiles" folder and updates parameter values using the file found in
47 51 the user's "pfiles" folder, so that any change to the parameter file structure
... ...
doc/source/admin/release_history/1.6.rst
... ... @@ -44,6 +44,8 @@ Bug fixes
44 44 Improvements
45 45 ------------
46 46  
  47 +* [`2842 <https://cta-redmine.irap.omp.eu/issues/2842>`_] -
  48 + Log warning if ``edisp=no``
47 49 * Add ``max_iter`` parameter to :ref:`ctbutterfly`, :ref:`cterror`,
48 50 :ref:`ctlike`, :ref:`cttsmap`, :ref:`ctulimit`, and :ref:`cstsmapsplit`
49 51 to allow controlling the maximum number of fit iterations.
... ...
pyext/ctool.i
... ... @@ -225,6 +225,9 @@ public:
225 225 * @brief ctool base class Python extensions
226 226 ***************************************************************************/
227 227 %extend ctool {
  228 + void _log_parameters(const int& chatter) {
  229 + self->log_parameters(GChatter(chatter));
  230 + }
228 231 void _log_observations(const int& chatter,
229 232 const GObservations& obs,
230 233 const std::string& what = "Observation") {
... ...
src/support/ctool.cpp
... ... @@ -1085,6 +1085,49 @@ void ctool::require_inobs_nocube(const std::string&amp; method)
1085 1085  
1086 1086  
1087 1087 /***********************************************************************//**
  1088 + * @brief Log application parameters
  1089 + *
  1090 + * @param[in] chatter Minimum required chattiness
  1091 + *
  1092 + * Log all application parameters. If the ctools has an edisp parameter and
  1093 + * the edisp parameter is false then log a warning that energy dispersion
  1094 + * is not used.
  1095 + ***************************************************************************/
  1096 +void ctool::log_parameters(const GChatter& chatter)
  1097 +{
  1098 + // Use base class logger
  1099 + this->GApplication::log_parameters(chatter);
  1100 +
  1101 + // If application has an edisp parameter but edisp is set to now then
  1102 + // log a warning that indicates that energy dispersion is not used
  1103 + if (has_par("edisp") && !(*this)["edisp"].boolean()) {
  1104 +
  1105 + // Get chattiness of application
  1106 + GChatter chattiness = static_cast<GChatter>((&m_pars["chatter"])->integer());
  1107 +
  1108 + // Only write parameters if the chattiness is at least equal to the
  1109 + // minimum required chattiness
  1110 + if (chattiness >= chatter) {
  1111 +
  1112 + // Log warning
  1113 + log << std::endl;
  1114 + log << "WARNING: Energy dispersion will *NOT* be considered for the "
  1115 + "computation. To consider" << std::endl;
  1116 + log << " energy dispersion, please set the \"edisp\" "
  1117 + "parameter to \"yes\". Be aware that" << std::endl;
  1118 + log << " using energy dispersion will considerably slow "
  1119 + "down the computations." << std::endl;
  1120 +
  1121 + } // endif: chatter level was sufficient
  1122 +
  1123 + } // endif: application has edisp parameter and edisp=no
  1124 +
  1125 + // Return
  1126 + return;
  1127 +}
  1128 +
  1129 +
  1130 +/***********************************************************************//**
1088 1131 * @brief Log observation container
1089 1132 *
1090 1133 * @param[in] chatter Minimum required chattiness
... ...
src/support/ctool.hpp
... ... @@ -116,6 +116,7 @@ protected:
116 116 bool is_onoff(void);
117 117  
118 118 // Protected methods for logging
  119 + void log_parameters(const GChatter& chatter);
119 120 void log_observations(const GChatter& chatter,
120 121 const GObservations& obs,
121 122 const std::string& what = "Observation");
... ...