Commit 6022837c635d7d9cf258fec9ddd1af21401c34d0

Authored by Jürgen Knödlseder
1 parent cdb1e9ba

Transparently update parameter files (#2513)

ChangeLog
1 -2018-06-13 1 +2018-06-14
2 2
3 * Version 1.6.0 released 3 * Version 1.6.0 released
4 ======================== 4 ========================
5 5
  6 + Transparently update parameter files (#2513)
6 Change formula for number of true energy bins in csphagen (#2490) 7 Change formula for number of true energy bins in csphagen (#2490)
7 Remove ctools::is_valid_filename() method 8 Remove ctools::is_valid_filename() method
8 Fix bug when using precomputed model in csresspec (#2448) 9 Fix bug when using precomputed model in csresspec (#2448)
1 New Features and Important Changes in ctools 1.6.0 1 New Features and Important Changes in ctools 1.6.0
2 2
3 -13 June 2018 3 +14 June 2018
4 4
5 5
6 Introduction 6 Introduction
@@ -26,6 +26,11 @@ None @@ -26,6 +26,11 @@ None
26 26
27 Base classes 27 Base classes
28 ------------ 28 ------------
  29 +The ctool base class now loads the application parameters from the file provided
  30 +in the "syspfiles" folder and updates parameter values using the file found in
  31 +the user's "pfiles" folder, so that any change to the parameter file structure
  32 +is handled transparently and no longer leads to an exception (#2513).
  33 +
29 The ctool::time_reference constant was removed since it is not required 34 The ctool::time_reference constant was removed since it is not required
30 anymore. The time reference is now transparently handled by the tools, and 35 anymore. The time reference is now transparently handled by the tools, and
31 if there is a choice, a "mjdref" parameter was added to the tools (#2054). 36 if there is a choice, a "mjdref" parameter was added to the tools (#2054).
doc/source/admin/release_history/1.6.rst
@@ -11,6 +11,7 @@ ctools 1.6 is a major release that adds significant functionality. @@ -11,6 +11,7 @@ ctools 1.6 is a major release that adds significant functionality.
11 In particular, this release provides: 11 In particular, this release provides:
12 12
13 * Support for Xspec spectral analysis 13 * Support for Xspec spectral analysis
  14 +* Improved computation speed for :ref:`ctskymap` and :ref:`csphagen`
14 15
15 16
16 Bug fixes 17 Bug fixes
@@ -25,6 +26,8 @@ Bug fixes @@ -25,6 +26,8 @@ Bug fixes
25 Improvements 26 Improvements
26 ------------ 27 ------------
27 28
  29 +* [`2513 <https://cta-redmine.irap.omp.eu/issues/2513>`_] -
  30 + Transparently update parameter files
28 * [`2490 <https://cta-redmine.irap.omp.eu/issues/2490>`_] - 31 * [`2490 <https://cta-redmine.irap.omp.eu/issues/2490>`_] -
29 Change formula for number of true energy bins in :ref:`csphagen` 32 Change formula for number of true energy bins in :ref:`csphagen`
30 * [`2404 <https://cta-redmine.irap.omp.eu/issues/2404>`_] - 33 * [`2404 <https://cta-redmine.irap.omp.eu/issues/2404>`_] -
doc/source/help/faq.rst
@@ -15,7 +15,6 @@ asked. @@ -15,7 +15,6 @@ asked.
15 - :ref:`What is the difference between ctools and GammaLib? <faq_ctools_gammalib>` 15 - :ref:`What is the difference between ctools and GammaLib? <faq_ctools_gammalib>`
16 - :ref:`Are ctools and GammaLib specific to CTA? <faq_instruments>` 16 - :ref:`Are ctools and GammaLib specific to CTA? <faq_instruments>`
17 - :ref:`I want to upgrade ctools, do I have to upgrade GammaLib? <faq_upgrade>` 17 - :ref:`I want to upgrade ctools, do I have to upgrade GammaLib? <faq_upgrade>`
18 -- :ref:`Why does my ctool complain about missing parameters? <faq_pars>`  
19 - :ref:`Should I used binned or unbinned analysis? <faq_analysis>` 18 - :ref:`Should I used binned or unbinned analysis? <faq_analysis>`
20 - :ref:`How precise are ctools? <faq_precision>` 19 - :ref:`How precise are ctools? <faq_precision>`
21 20
@@ -82,23 +81,6 @@ asked. @@ -82,23 +81,6 @@ asked.
82 ctools should then become more independent from GammaLib. 81 ctools should then become more independent from GammaLib.
83 82
84 83
85 -.. _faq_pars:  
86 -  
87 -.. topic:: Why does my ctool complain about missing parameters?  
88 -  
89 - After upgrading to a new ctools version, a ctool may issue the following  
90 - error  
91 -  
92 - ``*** ERROR in GApplicationPars::operator[](std::string&): Invalid  
93 - argument. Parameter "XXX" has not been found in parameter file.  
94 - Please specify a valid parameter name.``  
95 -  
96 - This error may occur if some parameters have been added to a ctool and  
97 - you still have the old parameter file without that parameter sitting in  
98 - your pfiles folder. Simply erasing all files in the pfiles folder should  
99 - fix this problem.  
100 -  
101 -  
102 .. _faq_analysis: 84 .. _faq_analysis:
103 85
104 .. topic:: Should I used binned or unbinned analysis? 86 .. topic:: Should I used binned or unbinned analysis?
src/ctools-setup.in
@@ -76,19 +76,6 @@ if [ -d $prefix/syspfiles/. ]; then @@ -76,19 +76,6 @@ if [ -d $prefix/syspfiles/. ]; then
76 syspfiles="$prefix/syspfiles$syspfiles" 76 syspfiles="$prefix/syspfiles$syspfiles"
77 fi 77 fi
78 78
79 - # updates any existing PFILES if syspfiles are newer  
80 - for filename in $HOME/pfiles/*.par  
81 - do  
82 - parfile=`basename $filename`  
83 - sys_parfile=$prefix/syspfiles/$parfile  
84 - if [ -e "$sys_parfile" ]; then  
85 - if test "$sys_parfile" -nt "$filename"  
86 - then  
87 - cp -f "$sys_parfile" "$filename"  
88 - fi  
89 - fi  
90 - done  
91 -  
92 # Set PFILES and PFCLOBBER environment variable 79 # Set PFILES and PFCLOBBER environment variable
93 PFILES="$locpfiles;$syspfiles" 80 PFILES="$locpfiles;$syspfiles"
94 PFCLOBBER=1 81 PFCLOBBER=1
src/support/ctool.cpp
@@ -258,6 +258,15 @@ void ctool::init_members(void) @@ -258,6 +258,15 @@ void ctool::init_members(void)
258 // Set language to english to make sure that a dot is a dot 258 // Set language to english to make sure that a dot is a dot
259 std::setlocale(LC_ALL, "en_US.UTF-8"); 259 std::setlocale(LC_ALL, "en_US.UTF-8");
260 260
  261 + // Set parameter syspfiles and reload parameter file
  262 + char* ptr = std::getenv("CTOOLS");
  263 + if (ptr != NULL) {
  264 + std::string path = std::string(ptr) + "/syspfiles";
  265 + m_pars.clear();
  266 + m_pars.syspfiles(path);
  267 + m_pars.load(par_filename());
  268 + }
  269 +
261 // Return 270 // Return
262 return; 271 return;
263 } 272 }