Commit 67f4d26e4ebab67f5dcf351ca23316622164c550

Authored by Alexander Ziegler
1 parent e6c67ef2

Adaptions to ctlike to enable covariance matrix output

src/ctlike/ctlike.cpp
@@ -331,7 +331,13 @@ void ctlike::save(void) @@ -331,7 +331,13 @@ void ctlike::save(void)
331 331
332 // Write results out as XML model 332 // Write results out as XML model
333 m_obs.models().save(m_outmodel); 333 m_obs.models().save(m_outmodel);
  334 + }
  335 +
  336 + // Save covarianve matrix only if filename is valid
  337 + if (is_valid_filename(m_covmat)) {
334 338
  339 + // Save covarianve matrix
  340 + m_obs.save_covmat(m_covmat);
335 } 341 }
336 342
337 // ... otherwise signal that file was not saved 343 // ... otherwise signal that file was not saved
@@ -393,6 +399,7 @@ void ctlike::get_parameters(void) @@ -393,6 +399,7 @@ void ctlike::get_parameters(void)
393 m_apply_edisp = (*this)["edisp"].boolean(); 399 m_apply_edisp = (*this)["edisp"].boolean();
394 m_fix_spat_for_ts = (*this)["fix_spat_for_ts"].boolean(); 400 m_fix_spat_for_ts = (*this)["fix_spat_for_ts"].boolean();
395 m_chatter = static_cast<GChatter>((*this)["chatter"].integer()); 401 m_chatter = static_cast<GChatter>((*this)["chatter"].integer());
  402 + m_covmat = (*this)["covmat"].filename();
396 403
397 // Optionally read ahead parameters so that they get correctly 404 // Optionally read ahead parameters so that they get correctly
398 // dumped into the log file 405 // dumped into the log file
@@ -530,6 +537,7 @@ void ctlike::init_members(void) @@ -530,6 +537,7 @@ void ctlike::init_members(void)
530 { 537 {
531 // Initialise members 538 // Initialise members
532 m_outmodel.clear(); 539 m_outmodel.clear();
  540 + m_covmat.clear();
533 m_refit = false; 541 m_refit = false;
534 m_max_iter = 100; // Set maximum number of iterations 542 m_max_iter = 100; // Set maximum number of iterations
535 m_max_stall = 10; // Set maximum number of stalls 543 m_max_stall = 10; // Set maximum number of stalls
@@ -560,6 +568,7 @@ void ctlike::copy_members(const ctlike&amp; app) @@ -560,6 +568,7 @@ void ctlike::copy_members(const ctlike&amp; app)
560 // Copy attributes 568 // Copy attributes
561 m_refit = app.m_refit; 569 m_refit = app.m_refit;
562 m_outmodel = app.m_outmodel; 570 m_outmodel = app.m_outmodel;
  571 + m_covmat = app.m_covmat;
563 m_max_iter = app.m_max_iter; 572 m_max_iter = app.m_max_iter;
564 m_max_stall = app.m_max_stall; 573 m_max_stall = app.m_max_stall;
565 m_logL = app.m_logL; 574 m_logL = app.m_logL;
src/ctlike/ctlike.hpp
@@ -73,6 +73,7 @@ protected: @@ -73,6 +73,7 @@ protected:
73 bool m_apply_edisp; //!< Apply energy dispersion? 73 bool m_apply_edisp; //!< Apply energy dispersion?
74 bool m_fix_spat_for_ts; //!< Fix spatial parameters for TS computation? 74 bool m_fix_spat_for_ts; //!< Fix spatial parameters for TS computation?
75 GChatter m_chatter; //!< Chattiness 75 GChatter m_chatter; //!< Chattiness
  76 + GFilename m_covmat; //!< Covariance matrix output FITS file name
76 77
77 // Members 78 // Members
78 int m_max_iter; //!< Maximum number of iterations 79 int m_max_iter; //!< Maximum number of iterations
src/ctlike/ctlike.par
@@ -27,6 +27,7 @@ caldb, s, a, &quot;prod2&quot;,,, &quot;Calibration database&quot; @@ -27,6 +27,7 @@ caldb, s, a, &quot;prod2&quot;,,, &quot;Calibration database&quot;
27 irf, s, a, "South_0.5h",,, "Instrument response function" 27 irf, s, a, "South_0.5h",,, "Instrument response function"
28 edisp, b, h, no,,, "Apply energy dispersion?" 28 edisp, b, h, no,,, "Apply energy dispersion?"
29 outmodel, f, a, "crab_results.xml",,, "Output model XML file" 29 outmodel, f, a, "crab_results.xml",,, "Output model XML file"
  30 +covmat, f, h, "NONE",,, "Output covariance matrix FITS file"
30 31
31 # 32 #
32 # Maximisation parameters 33 # Maximisation parameters