Commit 34730b4b1dc81fbd397e0ca7a08b5bc7980184c0

Authored by Jürgen Knödlseder
1 parent 9a08012a

Add "like_accuracy" parameter to likelihood tools and scripts (#2662)

ChangeLog
1   -2018-09-10
  1 +2018-09-11
2 2  
3 3 * Version 1.6.0 released
4 4 ========================
5 5  
  6 + Add "like_accuracy" parameter to likelihood tools and scripts (#2662)
6 7 Do not skip bins with zero counts in csspec (#2671)
7 8 Use "ENERG" instead of "ETRUE" in energy dispersion axis names in csroot2caldb (#2670)
8 9 Add hidden "use_irf_bkg" parameter to csphagen (#2659)
... ...
1 1 New Features and Important Changes in ctools 1.6.0
2 2  
3   -10 September 2018
  3 +11 September 2018
4 4  
5 5  
6 6 Introduction
... ... @@ -61,7 +61,8 @@ None
61 61  
62 62 ctbutterfly - Generate butterfly diagrams
63 63 -----------------------------------------
64   -None
  64 +Add hidden "like_accuracy" parameter to allow control of the accuracy of
  65 +the maximum log-likelikelihood value (#2662).
65 66  
66 67  
67 68 ctcubemask - CTA cube filtering
... ... @@ -76,6 +77,9 @@ None
76 77  
77 78 cterror - Likelihood profile error computation
78 79 ----------------------------------------------
  80 +Add hidden "like_accuracy" parameter to allow control of the accuracy of
  81 +the maximum log-likelikelihood value (#2662).
  82 +
79 83 Add hidden "nthreads" parameter to control parallel computations (#2421).
80 84  
81 85  
... ... @@ -86,6 +90,9 @@ None
86 90  
87 91 ctlike - Maximum likelihood fitting
88 92 -----------------------------------
  93 +Add hidden "like_accuracy" parameter to allow control of the accuracy of
  94 +the maximum log-likelikelihood value (#2662).
  95 +
89 96 Add hidden "nthreads" parameter to control parallel computations (#2421).
90 97  
91 98  
... ... @@ -150,11 +157,15 @@ accurately computes the distances between sky map pixels (#2309).
150 157  
151 158 cttsmap - Generation of Test Statistic map
152 159 ------------------------------------------
153   -None
  160 +Add hidden "like_accuracy" parameter to allow control of the accuracy of
  161 +the maximum log-likelikelihood value (#2662).
154 162  
155 163  
156 164 ctulimit - Compute upper limit
157 165 ------------------------------
  166 +Add hidden "like_accuracy" parameter to allow control of the accuracy of
  167 +the maximum log-likelikelihood value (#2662).
  168 +
158 169 Add "parname" parameter to allow upper limit computations also for a node
159 170 function spectral model. In addition, it is now checked that the parameter
160 171 values actually bracket the upper limit (#2233).
... ... @@ -356,7 +367,8 @@ None
356 367  
357 368 cstsmapsplit - Prepare split Test Statistic computation
358 369 -------------------------------------------------------
359   -None
  370 +Add hidden "like_accuracy" parameter to allow control of the accuracy of
  371 +the maximum log-likelikelihood value (#2662).
360 372  
361 373  
362 374 csviscube - Generate visibility cube
... ...
cscripts/cstsmapsplit.par
... ... @@ -28,6 +28,7 @@ irf, s, a, South_0.5h,,, "Instrument response function"
28 28 edisp, b, h, no,,, "Apply energy dispersion?"
29 29 errors, b, h, no,,, "Compute/store parameter errors?"
30 30 statistic, s, h, DEFAULT,DEFAULT|CSTAT|WSTAT|CHI2,, "Optimization statistic"
  31 +like_accuracy, r, h, 0.005,1.0e-30,0.1, "Absolute accuracy of maximum likelihood value"
31 32 outmap, f, a, tsmap.fits,,, "Output Test Statistic map file"
32 33 bins_per_job, i, a, 5,,, "Number of TS map bins per task"
33 34 compute_null, b, a, yes,,,"Compute null hypothesis first?"
... ...
doc/source/admin/release_history/1.6.rst
... ... @@ -37,6 +37,10 @@ Improvements
37 37 * [`2670 <https://cta-redmine.irap.omp.eu/issues/2670>`_] -
38 38 Use ``ENERG`` instead of ``ETRUE`` in energy dispersion axis names in
39 39 :ref:`csroot2caldb`
  40 +* [`2662 <https://cta-redmine.irap.omp.eu/issues/2662>`_] -
  41 + Add ``like_accuracy`` parameter to :ref:`ctbutterfly`, :ref:`cterror`,
  42 + :ref:`ctlike`, :ref:`cttsmap`, :ref:`ctulimit`, and :ref:`cstsmapsplit`
  43 + to allow controlling the accuracy of the maximum likelihood computation
40 44 * [`2659 <https://cta-redmine.irap.omp.eu/issues/2659>`_] -
41 45 Add hidden ``use_irf_bkg`` parameter to :ref:`csphagen`
42 46 * [`2656 <https://cta-redmine.irap.omp.eu/issues/2656>`_] -
... ...
doc/source/users/reference_manual/cstsmapsplit.rst
... ... @@ -61,6 +61,12 @@ General parameters
61 61 observations, and ``CHI2`` uses the Chi squared statistic for all
62 62 binned or stacked observations.
63 63  
  64 +``(like_accuracy = 0.005) [real]``
  65 + Absolute accuracy of maximum likelihood value. Reducing this value will
  66 + increase the number of iterations and provide a more accurate maximum
  67 + log likelihood value. Converserly, decreasing the value will result in less
  68 + iterations at the expense of a less accurate maximum likelihood value.
  69 +
64 70 ``outmap [file]``
65 71 Output Test Statistic map file.
66 72  
... ...
doc/source/users/reference_manual/ctbutterfly.rst
... ... @@ -94,6 +94,12 @@ General parameters
94 94 observations, and ``CHI2`` uses the Chi squared statistic for all
95 95 binned or stacked observations.
96 96  
  97 +``(like_accuracy = 0.005) [real]``
  98 + Absolute accuracy of maximum likelihood value. Reducing this value will
  99 + increase the number of iterations and provide a more accurate maximum
  100 + log likelihood value. Converserly, decreasing the value will result in less
  101 + iterations at the expense of a less accurate maximum likelihood value.
  102 +
97 103 ``(matrix = "NONE") [file]``
98 104 Input covariance matrix file (not used)
99 105  
... ...
doc/source/users/reference_manual/cterror.rst
... ... @@ -75,9 +75,15 @@ General parameters
75 75 observations, and ``CHI2`` uses the Chi squared statistic for all
76 76 binned or stacked observations.
77 77  
  78 +``(like_accuracy = 0.005) [real]``
  79 + Absolute accuracy of maximum likelihood value. Reducing this value will
  80 + increase the number of iterations and provide a more accurate maximum
  81 + log likelihood value. Converserly, decreasing the value will result in less
  82 + iterations at the expense of a less accurate maximum likelihood value.
  83 +
78 84 ``(max_iter = 50) [integer]``
79   - Maximum number of iterations before stopping the likelihood
80   - profil computations.
  85 + Maximum number of iterations before stopping the likelihood profile
  86 + computations.
81 87  
82 88  
83 89 Standard parameters
... ...
doc/source/users/reference_manual/ctlike.rst
... ... @@ -105,6 +105,12 @@ General parameters
105 105 ``(refit = no) [boolean]``
106 106 Perform refitting of solution after initial fit.
107 107  
  108 +``(like_accuracy = 0.005) [real]``
  109 + Absolute accuracy of maximum likelihood value. Reducing this value will
  110 + increase the number of iterations and provide a more accurate maximum
  111 + log likelihood value. Converserly, decreasing the value will result in less
  112 + iterations at the expense of a less accurate maximum likelihood value.
  113 +
108 114 ``(fix_spat_for_ts = no) [boolean]``
109 115 Fix spatial parameters for TS computation.
110 116  
... ...
doc/source/users/reference_manual/cttsmap.rst
... ... @@ -74,6 +74,12 @@ General parameters
74 74 observations, and ``CHI2`` uses the Chi squared statistic for all
75 75 binned or stacked observations.
76 76  
  77 +``(like_accuracy = 0.005) [real]``
  78 + Absolute accuracy of maximum likelihood value. Reducing this value will
  79 + increase the number of iterations and provide a more accurate maximum
  80 + log likelihood value. Converserly, decreasing the value will result in less
  81 + iterations at the expense of a less accurate maximum likelihood value.
  82 +
77 83 ``(usepnt = no) [boolean]``
78 84 Use CTA pointing direction for map centre instead of xref/yref parameters?
79 85  
... ...
doc/source/users/reference_manual/ctulimit.rst
... ... @@ -87,6 +87,12 @@ General parameters
87 87 observations, and ``CHI2`` uses the Chi squared statistic for all
88 88 binned or stacked observations.
89 89  
  90 +``(like_accuracy = 0.005) [real]``
  91 + Absolute accuracy of maximum likelihood value. Reducing this value will
  92 + increase the number of iterations and provide a more accurate maximum
  93 + log likelihood value. Converserly, decreasing the value will result in less
  94 + iterations at the expense of a less accurate maximum likelihood value.
  95 +
90 96 ``(max_iter = 50) [integer]``
91 97 Maximum number of iterations before stopping the upper
92 98 limit computations.
... ...
src/ctbutterfly/ctbutterfly.cpp
... ... @@ -374,7 +374,6 @@ void ctbutterfly::init_members(void)
374 374 m_srcname.clear();
375 375 m_method.clear();
376 376 m_confidence = 0.68;
377   - m_max_iter = 50;
378 377 m_apply_edisp = false;
379 378 m_fit = false;
380 379 m_chatter = static_cast<GChatter>(2);
... ... @@ -389,10 +388,6 @@ void ctbutterfly::init_members(void)
389 388 m_max_intensities.clear();
390 389 m_csv.clear();
391 390  
392   - // Set optimizer parameters
393   - m_opt.max_iter(m_max_iter);
394   - m_opt.max_stalls(10);
395   -
396 391 // Return
397 392 return;
398 393 }
... ...
src/ctbutterfly/ctbutterfly.par
... ... @@ -32,10 +32,11 @@ method, s, h, GAUSSIAN, GAUSSIAN|ENVELOPE,,&quot;Butterfly computation method&quot;
32 32 #
33 33 # Butterfly parameters
34 34 #=====================
35   -fit, b, h, no,,, "Perform maximum likelihood fitting?"
36   -confidence, r, h, 0.68,0.0,1.0, "Confidence level"
37   -statistic, s, h, DEFAULT,DEFAULT|CSTAT|WSTAT|CHI2,, "Optimization statistic"
38   -matrix, f, h, NONE,,, "Input covariance Matrix FITS file"
  35 +fit, b, h, no,,, "Perform maximum likelihood fitting?"
  36 +confidence, r, h, 0.68,0.0,1.0, "Confidence level"
  37 +statistic, s, h, DEFAULT,DEFAULT|CSTAT|WSTAT|CHI2,, "Optimization statistic"
  38 +like_accuracy, r, h, 0.005,1.0e-30,0.1, "Absolute accuracy of maximum likelihood value"
  39 +matrix, f, h, NONE,,, "Input covariance Matrix FITS file"
39 40  
40 41 #
41 42 # Energy binning parameters
... ...
src/cterror/cterror.cpp
... ... @@ -399,10 +399,6 @@ void cterror::init_members(void)
399 399 m_best_logL = 0.0;
400 400 m_model_par = NULL;
401 401  
402   - // Set optimizer parameters
403   - m_opt.max_iter(m_max_iter);
404   - m_opt.max_stalls(10);
405   -
406 402 // Return
407 403 return;
408 404 }
... ...
src/cterror/cterror.par
... ... @@ -32,10 +32,11 @@ outmodel, f, a, results.xml,,, &quot;Output model definiton XML file&quot;
32 32 #
33 33 # Error calculation parameters
34 34 #=============================
35   -confidence, r, h, 0.68,0.0,1.0, "Confidence level"
36   -tol, r, h, 1e-3,,, "Computation tolerance"
37   -statistic, s, h, DEFAULT,DEFAULT|CSTAT|WSTAT|CHI2,, "Optimization statistic"
38   -max_iter, i, h, 50,1,1000, "Maximum number of iterations"
  35 +confidence, r, h, 0.68,0.0,1.0, "Confidence level"
  36 +tol, r, h, 1e-3,,, "Computation tolerance"
  37 +statistic, s, h, DEFAULT,DEFAULT|CSTAT|WSTAT|CHI2,, "Optimization statistic"
  38 +like_accuracy, r, h, 0.005,1.0e-30,0.1, "Absolute accuracy of maximum likelihood value"
  39 +max_iter, i, h, 50,1,1000, "Maximum number of iterations"
39 40  
40 41 #
41 42 # Standard parameters
... ...
src/ctlike/ctlike.cpp
... ... @@ -559,8 +559,6 @@ void ctlike::init_members(void)
559 559 m_outmodel.clear();
560 560 m_outcovmat.clear();
561 561 m_refit = false;
562   - m_max_iter = 100; // Set maximum number of iterations
563   - m_max_stall = 10; // Set maximum number of stalls
564 562 m_logL = 0.0;
565 563 m_apply_edisp = false;
566 564 m_fix_spat_for_ts = false;
... ... @@ -569,10 +567,6 @@ void ctlike::init_members(void)
569 567 // Set logger properties
570 568 log.date(true);
571 569  
572   - // Set optimizer parameters
573   - m_opt.max_iter(m_max_iter);
574   - m_opt.max_stalls(m_max_stall);
575   -
576 570 // Return
577 571 return;
578 572 }
... ... @@ -589,8 +583,6 @@ void ctlike::copy_members(const ctlike&amp; app)
589 583 m_refit = app.m_refit;
590 584 m_outmodel = app.m_outmodel;
591 585 m_outcovmat = app.m_outcovmat;
592   - m_max_iter = app.m_max_iter;
593   - m_max_stall = app.m_max_stall;
594 586 m_logL = app.m_logL;
595 587 m_apply_edisp = app.m_apply_edisp;
596 588 m_fix_spat_for_ts = app.m_fix_spat_for_ts;
... ...
src/ctlike/ctlike.hpp
1 1 /***************************************************************************
2 2 * ctlike - Maximum likelihood fitting tool *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2010-2017 by Juergen Knoedlseder *
  4 + * copyright (C) 2010-2018 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -75,8 +75,6 @@ protected:
75 75 GChatter m_chatter; //!< Chattiness
76 76  
77 77 // Members
78   - int m_max_iter; //!< Maximum number of iterations
79   - int m_max_stall; //!< Maximum number of stalls
80 78 double m_logL; //!< Maximum log likelihood
81 79 };
82 80  
... ...
src/ctlike/ctlike.par
... ... @@ -33,6 +33,7 @@ outcovmat, f, h, NONE,,, &quot;Output covariance matrix FITS file&quot;
33 33 #========================
34 34 statistic, s, h, DEFAULT,DEFAULT|CSTAT|WSTAT|CHI2,, "Optimization statistic"
35 35 refit, b, h, no,,, "Do refitting?"
  36 +like_accuracy, r, h, 0.005,1.0e-30,0.1, "Absolute accuracy of maximum likelihood value"
36 37 fix_spat_for_ts, b, h, no,,, "Fix spatial parameters for TS computation?"
37 38  
38 39 #
... ...
src/cttsmap/cttsmap.par
... ... @@ -31,8 +31,9 @@ outmap, f, a, tsmap.fits,,, &quot;Output Test Statistic map file&quot;
31 31 #
32 32 # TS map computation parameters
33 33 #==============================
34   -errors, b, h, no,,, "Compute and store parameter errors?"
35   -statistic, s, h, DEFAULT,DEFAULT|CSTAT|WSTAT|CHI2,, "Optimization statistic"
  34 +errors, b, h, no,,, "Compute and store parameter errors?"
  35 +statistic, s, h, DEFAULT,DEFAULT|CSTAT|WSTAT|CHI2,, "Optimization statistic"
  36 +like_accuracy, r, h, 0.005,1.0e-30,0.1, "Absolute accuracy of maximum likelihood value"
36 37  
37 38 #
38 39 # Spatial binning parameters
... ...
src/ctulimit/ctulimit.cpp
... ... @@ -372,10 +372,6 @@ void ctulimit::init_members(void)
372 372 m_diff_ulimit = 0.0;
373 373 m_eflux_ulimit = 0.0;
374 374  
375   - // Set optimizer parameters
376   - m_opt.max_iter(m_max_iter);
377   - m_opt.max_stalls(10);
378   -
379 375 // Return
380 376 return;
381 377 }
... ...
src/ctulimit/ctulimit.par
... ... @@ -31,15 +31,16 @@ edisp, b, h, no,,, &quot;Apply energy dispersion?&quot;
31 31 #
32 32 # Upper limit calculation parameters
33 33 #===================================
34   -confidence, r, h, 0.95,0.0,1.0, "Confidence level"
35   -sigma_min, r, h, 0.0,,, "Start minimum value (multiple sigmas above fit value)"
36   -sigma_max, r, h, 10.0,,, "Start maximum value (multiple sigmas above fit value)"
37   -eref, r, h, 1.0,,, "Reference energy for differential limit (TeV)"
38   -emin, r, h, 1.0,,, "Minimum energy for integral flux limit (TeV)"
39   -emax, r, h, 100.0,,, "Maximum energy for integral flux limit (TeV)"
40   -tol, r, h, 1e-5,,, "Computation tolerance"
41   -statistic, s, h, DEFAULT,DEFAULT|CSTAT|WSTAT|CHI2,, "Optimization statistic"
42   -max_iter, i, h, 50,1,1000, "Maximum number of iterations"
  34 +confidence, r, h, 0.95,0.0,1.0, "Confidence level"
  35 +sigma_min, r, h, 0.0,,, "Start minimum value (multiple sigmas above fit value)"
  36 +sigma_max, r, h, 10.0,,, "Start maximum value (multiple sigmas above fit value)"
  37 +eref, r, h, 1.0,,, "Reference energy for differential limit (TeV)"
  38 +emin, r, h, 1.0,,, "Minimum energy for integral flux limit (TeV)"
  39 +emax, r, h, 100.0,,, "Maximum energy for integral flux limit (TeV)"
  40 +tol, r, h, 1e-5,,, "Computation tolerance"
  41 +statistic, s, h, DEFAULT,DEFAULT|CSTAT|WSTAT|CHI2,, "Optimization statistic"
  42 +like_accuracy, r, h, 0.005,1.0e-30,0.1, "Absolute accuracy of maximum likelihood value"
  43 +max_iter, i, h, 50,1,1000, "Maximum number of iterations"
43 44  
44 45 #
45 46 # Standard parameters
... ...
src/support/ctlikelihood.cpp
... ... @@ -290,6 +290,19 @@ void ctlikelihood::init_members(void)
290 290 // Initialise members
291 291 m_opt.clear();
292 292  
  293 + // Initialise optimizer characteristics
  294 + m_opt.max_iter(50); // Maximum number of iterations
  295 + m_opt.max_stalls(10); // Maximum number of stalls
  296 + m_opt.eps(0.005); // Accuracy of maximum likelihood value
  297 +
  298 + // Set optimizer characteristics from optional user parameters
  299 + if (has_par("like_accuracy")) {
  300 + m_opt.eps((*this)["like_accuracy"].real());
  301 + }
  302 + if (has_par("max_iter")) {
  303 + m_opt.max_iter((*this)["max_iter"].integer());
  304 + }
  305 +
293 306 // Return
294 307 return;
295 308 }
... ...