Commit 6b90750114f6451e9399bd0e0741817d44513957

Authored by Jürgen Knödlseder
1 parent ca874e05

Integrate code.

doc/source/reference_manual/ctlike.rst
@@ -53,7 +53,10 @@ General parameters @@ -53,7 +53,10 @@ General parameters
53 Applies energy dispersion to response computation. 53 Applies energy dispersion to response computation.
54 54
55 ``(refit = no) [boolean]`` 55 ``(refit = no) [boolean]``
56 - Performs refitting of solution after initial fit. 56 + Perform refitting of solution after initial fit.
  57 +
  58 +``(fix_spat_for_ts = no) [boolean]``
  59 + Fix spatial parameters for TS computation.
57 60
58 61
59 62
src/ctlike/ctlike.cpp
@@ -264,21 +264,23 @@ void ctlike::run(void) @@ -264,21 +264,23 @@ void ctlike::run(void)
264 264
265 // Fix spatial parameters if requested 265 // Fix spatial parameters if requested
266 if (m_fix_spat_for_ts) { 266 if (m_fix_spat_for_ts) {
267 - for(int i = 0; i < models.size(); ++i) { 267 +
  268 + // Loop over all models
  269 + for (int i = 0; i < models.size(); ++i) {
268 270
269 // Continue only if model is skymodel 271 // Continue only if model is skymodel
270 GModelSky* sky= dynamic_cast<GModelSky*>(models[i]); 272 GModelSky* sky= dynamic_cast<GModelSky*>(models[i]);
271 if (sky != NULL) { 273 if (sky != NULL) {
272 274
273 // Fix spatial parameters 275 // Fix spatial parameters
274 - GModelSpatial* spat = sky->spatial();  
275 - for (int j = 0; j < spat->size(); j++) {  
276 - (*spat)[j].fix();  
277 - } // endfor: loop over spatial parameters 276 + GModelSpatial* spatial = sky->spatial();
  277 + for (int j = 0; j < spatial->size(); j++) {
  278 + (*spatial)[j].fix();
  279 + } // endfor: looped over spatial parameters
278 280
279 } // endif: there was a sky model 281 } // endif: there was a sky model
280 282
281 - } // endfor: Loop over models 283 + } // endfor: looped over models
282 284
283 } // endif: spatial parameter should be fixed 285 } // endif: spatial parameter should be fixed
284 286
@@ -412,8 +414,8 @@ void ctlike::get_parameters(void) @@ -412,8 +414,8 @@ void ctlike::get_parameters(void)
412 } // endif: no models were associated with observations 414 } // endif: no models were associated with observations
413 415
414 // Get other parameters 416 // Get other parameters
415 - m_refit = (*this)["refit"].boolean();  
416 - m_apply_edisp = (*this)["edisp"].boolean(); 417 + m_refit = (*this)["refit"].boolean();
  418 + m_apply_edisp = (*this)["edisp"].boolean();
417 m_fix_spat_for_ts = (*this)["fix_spat_for_ts"].boolean(); 419 m_fix_spat_for_ts = (*this)["fix_spat_for_ts"].boolean();
418 420
419 // Optionally read ahead parameters so that they get correctly 421 // Optionally read ahead parameters so that they get correctly
@@ -563,12 +565,13 @@ void ctlike::init_members(void) @@ -563,12 +565,13 @@ void ctlike::init_members(void)
563 // Initialise members 565 // Initialise members
564 m_outmodel.clear(); 566 m_outmodel.clear();
565 m_obs.clear(); 567 m_obs.clear();
566 - m_refit = false;  
567 - m_max_iter = 100; // Set maximum number of iterations  
568 - m_max_stall = 10; // Set maximum number of stalls  
569 - m_logL = 0.0;  
570 - m_opt = NULL;  
571 - m_apply_edisp = false; 568 + m_refit = false;
  569 + m_max_iter = 100; // Set maximum number of iterations
  570 + m_max_stall = 10; // Set maximum number of stalls
  571 + m_logL = 0.0;
  572 + m_opt = NULL;
  573 + m_apply_edisp = false;
  574 + m_fix_spat_for_ts = false;
572 575
573 // Set logger properties 576 // Set logger properties
574 log.date(true); 577 log.date(true);
@@ -596,14 +599,15 @@ void ctlike::init_members(void) @@ -596,14 +599,15 @@ void ctlike::init_members(void)
596 void ctlike::copy_members(const ctlike& app) 599 void ctlike::copy_members(const ctlike& app)
597 { 600 {
598 // Copy attributes 601 // Copy attributes
599 - m_refit = app.m_refit;  
600 - m_outmodel = app.m_outmodel;  
601 - m_obs = app.m_obs;  
602 - m_max_iter = app.m_max_iter;  
603 - m_max_stall = app.m_max_stall;  
604 - m_logL = app.m_logL;  
605 - m_opt = app.m_opt->clone();  
606 - m_apply_edisp = app.m_apply_edisp; 602 + m_refit = app.m_refit;
  603 + m_outmodel = app.m_outmodel;
  604 + m_obs = app.m_obs;
  605 + m_max_iter = app.m_max_iter;
  606 + m_max_stall = app.m_max_stall;
  607 + m_logL = app.m_logL;
  608 + m_opt = app.m_opt->clone();
  609 + m_apply_edisp = app.m_apply_edisp;
  610 + m_fix_spat_for_ts = app.m_fix_spat_for_ts;
607 611
608 // Return 612 // Return
609 return; 613 return;
src/ctlike/ctlike.hpp
@@ -73,9 +73,9 @@ protected: @@ -73,9 +73,9 @@ protected:
73 double reoptimize_lm(void); 73 double reoptimize_lm(void);
74 74
75 // User parameters 75 // User parameters
76 - bool m_refit; //!< Refitting  
77 - std::string m_outmodel; //!< Source model output XML file  
78 - bool m_apply_edisp; //!< Apply energy dispersion? 76 + bool m_refit; //!< Refitting
  77 + std::string m_outmodel; //!< Source model output XML file
  78 + bool m_apply_edisp; //!< Apply energy dispersion?
79 bool m_fix_spat_for_ts; //!< Fix spatial parameters for TS computation? 79 bool m_fix_spat_for_ts; //!< Fix spatial parameters for TS computation?
80 80
81 // Members 81 // Members
src/ctlike/ctlike.par
@@ -17,18 +17,18 @@ @@ -17,18 +17,18 @@
17 # 17 #
18 # General parameters 18 # General parameters
19 #=================== 19 #===================
20 -inobs, f, a, "events.fits",,, "Event list, counts cube or observation definition file"  
21 -inmodel, f, a, "$CTOOLS/share/models/crab.xml",,, "Source model"  
22 -expcube, f, a, "NONE",,, "Exposure cube file (only needed for stacked analysis)"  
23 -psfcube, f, a, "NONE",,, "PSF cube file (only needed for stacked analysis)"  
24 -bkgcube, f, a, "NONE",,, "Background cube file (only needed for stacked analysis)"  
25 -caldb, s, a, "prod2",,, "Calibration database"  
26 -irf, s, a, "South_50h",,, "Instrument response function"  
27 -outmodel, f, a, "crab_results.xml",,, "Source model output file"  
28 -stat, s, h, "POISSON",,, "Optimization statistics"  
29 -edisp, b, h, no,,, "Apply energy dispersion?"  
30 -refit, b, h, no,,, "Do refitting?"  
31 -fix_spat_for_ts,b,h,no,,,"Fix spatial parameters for TS computation?" 20 +inobs, f, a, "events.fits",,, "Event list, counts cube or observation definition file"
  21 +inmodel, f, a, "$CTOOLS/share/models/crab.xml",,, "Source model"
  22 +expcube, f, a, "NONE",,, "Exposure cube file (only needed for stacked analysis)"
  23 +psfcube, f, a, "NONE",,, "PSF cube file (only needed for stacked analysis)"
  24 +bkgcube, f, a, "NONE",,, "Background cube file (only needed for stacked analysis)"
  25 +caldb, s, a, "prod2",,, "Calibration database"
  26 +irf, s, a, "South_50h",,, "Instrument response function"
  27 +outmodel, f, a, "crab_results.xml",,, "Source model output file"
  28 +stat, s, h, "POISSON",,, "Optimization statistics"
  29 +edisp, b, h, no,,, "Apply energy dispersion?"
  30 +refit, b, h, no,,, "Do refitting?"
  31 +fix_spat_for_ts, b, h, no,,,"Fix spatial parameters for TS computation?"
32 32
33 # 33 #
34 # Standard parameters 34 # Standard parameters