From a1592060025356308d53f770069094013a401eb7 Mon Sep 17 00:00:00 2001 From: Jürgen Knödlseder Date: Wed, 6 Mar 2019 15:21:04 +0100 Subject: [PATCH] Log warning if edisp=no (#2842) --- ChangeLog | 3 ++- NEWS | 6 +++++- doc/source/admin/release_history/1.6.rst | 2 ++ pyext/ctool.i | 3 +++ src/support/ctool.cpp | 43 +++++++++++++++++++++++++++++++++++++++++++ src/support/ctool.hpp | 1 + 6 files changed, 56 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 36627cd..cff2e5c 100755 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,9 @@ -2019-02-15 +2019-03-06 * Version 1.6.0 released ======================== + Log warning if edisp=no (#2842) Add max_iter parameter to ctbutterfly, cterror, ctlike, cttsmap, ctulimit and cstsmapsplit ctbkgcube now requires an input counts cube (#2763) diff --git a/NEWS b/NEWS index 114f8c4..88d0ef1 100755 --- a/NEWS +++ b/NEWS @@ -1,6 +1,6 @@ New Features and Important Changes in ctools 1.6.0 -5 February 2019 +6 March 2019 Introduction @@ -42,6 +42,10 @@ None Base classes ------------ +The ctool base class now implements a log_parameters() method that overwrites +the base class method and that logs a warning if the tool has an "edisp" +parameter but the parameter is set to "no" (#2842). + The ctool base class now loads the application parameters from the file provided in the "syspfiles" folder and updates parameter values using the file found in the user's "pfiles" folder, so that any change to the parameter file structure diff --git a/doc/source/admin/release_history/1.6.rst b/doc/source/admin/release_history/1.6.rst index dd06c03..c043c7f 100644 --- a/doc/source/admin/release_history/1.6.rst +++ b/doc/source/admin/release_history/1.6.rst @@ -44,6 +44,8 @@ Bug fixes Improvements ------------ +* [`2842 `_] - + Log warning if ``edisp=no`` * Add ``max_iter`` parameter to :ref:`ctbutterfly`, :ref:`cterror`, :ref:`ctlike`, :ref:`cttsmap`, :ref:`ctulimit`, and :ref:`cstsmapsplit` to allow controlling the maximum number of fit iterations. diff --git a/pyext/ctool.i b/pyext/ctool.i index b915dbb..799b021 100755 --- a/pyext/ctool.i +++ b/pyext/ctool.i @@ -225,6 +225,9 @@ public: * @brief ctool base class Python extensions ***************************************************************************/ %extend ctool { + void _log_parameters(const int& chatter) { + self->log_parameters(GChatter(chatter)); + } void _log_observations(const int& chatter, const GObservations& obs, const std::string& what = "Observation") { diff --git a/src/support/ctool.cpp b/src/support/ctool.cpp index 16d9a95..843e679 100755 --- a/src/support/ctool.cpp +++ b/src/support/ctool.cpp @@ -1085,6 +1085,49 @@ void ctool::require_inobs_nocube(const std::string& method) /***********************************************************************//** + * @brief Log application parameters + * + * @param[in] chatter Minimum required chattiness + * + * Log all application parameters. If the ctools has an edisp parameter and + * the edisp parameter is false then log a warning that energy dispersion + * is not used. + ***************************************************************************/ +void ctool::log_parameters(const GChatter& chatter) +{ + // Use base class logger + this->GApplication::log_parameters(chatter); + + // If application has an edisp parameter but edisp is set to now then + // log a warning that indicates that energy dispersion is not used + if (has_par("edisp") && !(*this)["edisp"].boolean()) { + + // Get chattiness of application + GChatter chattiness = static_cast((&m_pars["chatter"])->integer()); + + // Only write parameters if the chattiness is at least equal to the + // minimum required chattiness + if (chattiness >= chatter) { + + // Log warning + log << std::endl; + log << "WARNING: Energy dispersion will *NOT* be considered for the " + "computation. To consider" << std::endl; + log << " energy dispersion, please set the \"edisp\" " + "parameter to \"yes\". Be aware that" << std::endl; + log << " using energy dispersion will considerably slow " + "down the computations." << std::endl; + + } // endif: chatter level was sufficient + + } // endif: application has edisp parameter and edisp=no + + // Return + return; +} + + +/***********************************************************************//** * @brief Log observation container * * @param[in] chatter Minimum required chattiness diff --git a/src/support/ctool.hpp b/src/support/ctool.hpp index f4cc39e..61a24f6 100755 --- a/src/support/ctool.hpp +++ b/src/support/ctool.hpp @@ -116,6 +116,7 @@ protected: bool is_onoff(void); // Protected methods for logging + void log_parameters(const GChatter& chatter); void log_observations(const GChatter& chatter, const GObservations& obs, const std::string& what = "Observation"); -- libgit2 0.21.4