From 6022837c635d7d9cf258fec9ddd1af21401c34d0 Mon Sep 17 00:00:00 2001 From: Jürgen Knödlseder Date: Thu, 14 Jun 2018 12:22:33 +0200 Subject: [PATCH] Transparently update parameter files (#2513) --- ChangeLog | 3 ++- NEWS | 7 ++++++- doc/source/admin/release_history/1.6.rst | 3 +++ doc/source/help/faq.rst | 18 ------------------ src/ctools-setup.in | 13 ------------- src/support/ctool.cpp | 9 +++++++++ 6 files changed, 20 insertions(+), 33 deletions(-) diff --git a/ChangeLog b/ChangeLog index 651ff1a..19fb85f 100755 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,9 @@ -2018-06-13 +2018-06-14 * Version 1.6.0 released ======================== + Transparently update parameter files (#2513) Change formula for number of true energy bins in csphagen (#2490) Remove ctools::is_valid_filename() method Fix bug when using precomputed model in csresspec (#2448) diff --git a/NEWS b/NEWS index 14e629e..89c5dd1 100755 --- a/NEWS +++ b/NEWS @@ -1,6 +1,6 @@ New Features and Important Changes in ctools 1.6.0 -13 June 2018 +14 June 2018 Introduction @@ -26,6 +26,11 @@ None Base classes ------------ +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 +is handled transparently and no longer leads to an exception (#2513). + The ctool::time_reference constant was removed since it is not required anymore. The time reference is now transparently handled by the tools, and if there is a choice, a "mjdref" parameter was added to the tools (#2054). diff --git a/doc/source/admin/release_history/1.6.rst b/doc/source/admin/release_history/1.6.rst index 8c14f55..1e0f163 100644 --- a/doc/source/admin/release_history/1.6.rst +++ b/doc/source/admin/release_history/1.6.rst @@ -11,6 +11,7 @@ ctools 1.6 is a major release that adds significant functionality. In particular, this release provides: * Support for Xspec spectral analysis +* Improved computation speed for :ref:`ctskymap` and :ref:`csphagen` Bug fixes @@ -25,6 +26,8 @@ Bug fixes Improvements ------------ +* [`2513 `_] - + Transparently update parameter files * [`2490 `_] - Change formula for number of true energy bins in :ref:`csphagen` * [`2404 `_] - diff --git a/doc/source/help/faq.rst b/doc/source/help/faq.rst index c775af1..c57b4b0 100755 --- a/doc/source/help/faq.rst +++ b/doc/source/help/faq.rst @@ -15,7 +15,6 @@ asked. - :ref:`What is the difference between ctools and GammaLib? ` - :ref:`Are ctools and GammaLib specific to CTA? ` - :ref:`I want to upgrade ctools, do I have to upgrade GammaLib? ` -- :ref:`Why does my ctool complain about missing parameters? ` - :ref:`Should I used binned or unbinned analysis? ` - :ref:`How precise are ctools? ` @@ -82,23 +81,6 @@ asked. ctools should then become more independent from GammaLib. -.. _faq_pars: - -.. topic:: Why does my ctool complain about missing parameters? - - After upgrading to a new ctools version, a ctool may issue the following - error - - ``*** ERROR in GApplicationPars::operator[](std::string&): Invalid - argument. Parameter "XXX" has not been found in parameter file. - Please specify a valid parameter name.`` - - This error may occur if some parameters have been added to a ctool and - you still have the old parameter file without that parameter sitting in - your pfiles folder. Simply erasing all files in the pfiles folder should - fix this problem. - - .. _faq_analysis: .. topic:: Should I used binned or unbinned analysis? diff --git a/src/ctools-setup.in b/src/ctools-setup.in index 5c460c8..11baaf8 100755 --- a/src/ctools-setup.in +++ b/src/ctools-setup.in @@ -76,19 +76,6 @@ if [ -d $prefix/syspfiles/. ]; then syspfiles="$prefix/syspfiles$syspfiles" fi - # updates any existing PFILES if syspfiles are newer - for filename in $HOME/pfiles/*.par - do - parfile=`basename $filename` - sys_parfile=$prefix/syspfiles/$parfile - if [ -e "$sys_parfile" ]; then - if test "$sys_parfile" -nt "$filename" - then - cp -f "$sys_parfile" "$filename" - fi - fi - done - # Set PFILES and PFCLOBBER environment variable PFILES="$locpfiles;$syspfiles" PFCLOBBER=1 diff --git a/src/support/ctool.cpp b/src/support/ctool.cpp index 4de40dd..4cca3b5 100755 --- a/src/support/ctool.cpp +++ b/src/support/ctool.cpp @@ -258,6 +258,15 @@ void ctool::init_members(void) // Set language to english to make sure that a dot is a dot std::setlocale(LC_ALL, "en_US.UTF-8"); + // Set parameter syspfiles and reload parameter file + char* ptr = std::getenv("CTOOLS"); + if (ptr != NULL) { + std::string path = std::string(ptr) + "/syspfiles"; + m_pars.clear(); + m_pars.syspfiles(path); + m_pars.load(par_filename()); + } + // Return return; } -- libgit2 0.21.4