Commit 654219f9d547c31d214bf78cea34862bcad8154c

Authored by Jürgen Knödlseder
1 parent 780713c2

Check for Value parameter name and remove outfile parameter from parfile.

doc/source/reference_manual/ctulimit.rst
@@ -9,8 +9,7 @@ Computes upper limit for a specific sky model component. @@ -9,8 +9,7 @@ Computes upper limit for a specific sky model component.
9 Synopsis 9 Synopsis
10 -------- 10 --------
11 11
12 -Computes the upper limit flux of a given source and stores the value  
13 -in an ASCII file. 12 +Computes the upper limit flux of a given source.
14 13
15 14
16 General parameters 15 General parameters
@@ -37,9 +36,6 @@ General parameters @@ -37,9 +36,6 @@ General parameters
37 ``irf [string]`` 36 ``irf [string]``
38 Instrumental response function. 37 Instrumental response function.
39 38
40 -``outfile [file]``  
41 - Output ASCII file name.  
42 -  
43 ``(confidence = 0.95) [real]`` 39 ``(confidence = 0.95) [real]``
44 Confidence Level of upper limit. 40 Confidence Level of upper limit.
45 41
src/ctulimit/ctulimit.cpp
@@ -337,7 +337,10 @@ void ctulimit::run(void) @@ -337,7 +337,10 @@ void ctulimit::run(void)
337 /***********************************************************************//** 337 /***********************************************************************//**
338 * @brief Save maps 338 * @brief Save maps
339 * 339 *
340 - * This method saves the upper limit to an ascii file 340 + * This method saves the upper limit to an ascii file.
  341 + *
  342 + * @todo No yet implemented as we have no clear use case yet for saving
  343 + * the result.
341 ***************************************************************************/ 344 ***************************************************************************/
342 void ctulimit::save(void) 345 void ctulimit::save(void)
343 { 346 {
@@ -347,6 +350,7 @@ void ctulimit::save(void) @@ -347,6 +350,7 @@ void ctulimit::save(void)
347 log.header1("Save upper limit"); 350 log.header1("Save upper limit");
348 } 351 }
349 352
  353 + /*
350 // Get output filename 354 // Get output filename
351 m_outfile = (*this)["outfile"].filename(); 355 m_outfile = (*this)["outfile"].filename();
352 356
@@ -359,7 +363,8 @@ void ctulimit::save(void) @@ -359,7 +363,8 @@ void ctulimit::save(void)
359 363
360 // Save CSV table 364 // Save CSV table
361 table.save(m_outfile, " ", clobber()); 365 table.save(m_outfile, " ", clobber());
362 - 366 + */
  367 +
363 // Return 368 // Return
364 return; 369 return;
365 } 370 }
@@ -377,7 +382,6 @@ void ctulimit::save(void) @@ -377,7 +382,6 @@ void ctulimit::save(void)
377 void ctulimit::init_members(void) 382 void ctulimit::init_members(void)
378 { 383 {
379 // Initialise user parameters 384 // Initialise user parameters
380 - m_outfile.clear();  
381 m_srcname.clear(); 385 m_srcname.clear();
382 m_confidence = 0.95; 386 m_confidence = 0.95;
383 m_sigma_min = 0.0; 387 m_sigma_min = 0.0;
@@ -411,7 +415,6 @@ void ctulimit::init_members(void) @@ -411,7 +415,6 @@ void ctulimit::init_members(void)
411 void ctulimit::copy_members(const ctulimit& app) 415 void ctulimit::copy_members(const ctulimit& app)
412 { 416 {
413 // Copy user parameters 417 // Copy user parameters
414 - m_outfile = app.m_outfile;  
415 m_srcname = app.m_srcname; 418 m_srcname = app.m_srcname;
416 m_confidence = app.m_confidence; 419 m_confidence = app.m_confidence;
417 m_sigma_min = app.m_sigma_min; 420 m_sigma_min = app.m_sigma_min;
@@ -515,12 +518,6 @@ void ctulimit::get_parameters(void) @@ -515,12 +518,6 @@ void ctulimit::get_parameters(void)
515 m_tol = (*this)["tol"].real(); 518 m_tol = (*this)["tol"].real();
516 m_max_iter = (*this)["max_iter"].integer(); 519 m_max_iter = (*this)["max_iter"].integer();
517 520
518 - // Optionally read ahead parameters so that they get correctly  
519 - // dumped into the log file  
520 - if (read_ahead()) {  
521 - m_outfile = (*this)["outfile"].filename();  
522 - }  
523 -  
524 // Return 521 // Return
525 return; 522 return;
526 } 523 }
@@ -558,11 +555,14 @@ void ctulimit::get_model_parameter(void) @@ -558,11 +555,14 @@ void ctulimit::get_model_parameter(void)
558 else if (m_skymodel->spectral()->has_par("Integral")) { 555 else if (m_skymodel->spectral()->has_par("Integral")) {
559 m_model_par = &(m_skymodel->spectral()->operator[]("Integral")); 556 m_model_par = &(m_skymodel->spectral()->operator[]("Integral"));
560 } 557 }
  558 + else if (m_skymodel->spectral()->has_par("Value")) {
  559 + m_model_par = &(m_skymodel->spectral()->operator[]("Value"));
  560 + }
561 else { 561 else {
562 std::string msg = "Require spectral parameter \"Normalization\", " 562 std::string msg = "Require spectral parameter \"Normalization\", "
563 - "\"Prefactor\" or \"Integral\" for upper limit "  
564 - "computation. The specified source \""+m_srcname+  
565 - "\" does not have such a parameter."; 563 + "\"Prefactor\", \"Integral\" or \"Value\" for "
  564 + "upper limit computation. The specified source "
  565 + "\""+m_srcname+"\" does not have such a parameter.";
566 throw GException::invalid_value(G_GET_MODEL_PARAMETER, msg); 566 throw GException::invalid_value(G_GET_MODEL_PARAMETER, msg);
567 } 567 }
568 568
src/ctulimit/ctulimit.hpp
@@ -84,7 +84,6 @@ protected: @@ -84,7 +84,6 @@ protected:
84 84
85 // User parameters 85 // User parameters
86 std::string m_srcname; //!< Name of source which is moved around 86 std::string m_srcname; //!< Name of source which is moved around
87 - std::string m_outfile; //!< Output ascii file  
88 double m_confidence; //!< Confidence level 87 double m_confidence; //!< Confidence level
89 double m_sigma_min; //!< Starting value minimum (multiple fit errors above fit values) 88 double m_sigma_min; //!< Starting value minimum (multiple fit errors above fit values)
90 double m_sigma_max; //!< Starting value maximum (multiple fit errors above fit values) 89 double m_sigma_max; //!< Starting value maximum (multiple fit errors above fit values)
src/ctulimit/ctulimit.par
@@ -24,7 +24,6 @@ expcube, f, a, &quot;NONE&quot;,,, &quot;Exposure cube file (only needed for stacked analysis) @@ -24,7 +24,6 @@ expcube, f, a, &quot;NONE&quot;,,, &quot;Exposure cube file (only needed for stacked analysis)
24 psfcube, f, a, "NONE",,, "PSF cube file (only needed for stacked analysis)" 24 psfcube, f, a, "NONE",,, "PSF cube file (only needed for stacked analysis)"
25 caldb, s, a, "dummy",,, "Calibration database" 25 caldb, s, a, "dummy",,, "Calibration database"
26 irf, s, a, "cta_dummy_irf",,, "Instrument response function" 26 irf, s, a, "cta_dummy_irf",,, "Instrument response function"
27 -outfile, f, a, "upperlimit.txt",,, "Output ASCII file"  
28 27
29 # 28 #
30 # Upper limit calculation parameters 29 # Upper limit calculation parameters
test/test_ctools.sh
@@ -608,15 +608,14 @@ $ECHO -n &quot;Test ctulimit: &quot; @@ -608,15 +608,14 @@ $ECHO -n &quot;Test ctulimit: &quot;
608 $ctulimit inobs="data/crab_events.fits.gz" \ 608 $ctulimit inobs="data/crab_events.fits.gz" \
609 inmodel="data/crab.xml" \ 609 inmodel="data/crab.xml" \
610 srcname="Crab" \ 610 srcname="Crab" \
611 - outfile="ulimit.dat" \  
612 caldb="irf" \ 611 caldb="irf" \
613 irf="cta_dummy_irf" 612 irf="cta_dummy_irf"
614 $ECHO -n "." 613 $ECHO -n "."
615 -if [ -s "ulimit.dat" ] 614 +if [ -s "ctulimit.log" ]
616 then 615 then
617 $ECHO -n "." 616 $ECHO -n "."
618 else 617 else
619 - $ECHO " ulimit.dat file is not found" 618 + $ECHO " ctulimit.log file is not found"
620 exit 1 619 exit 1
621 fi 620 fi
622 $ECHO " ok" 621 $ECHO " ok"
test/test_ctulimit.py
@@ -72,7 +72,6 @@ class Test(gammalib.GPythonTestSuite): @@ -72,7 +72,6 @@ class Test(gammalib.GPythonTestSuite):
72 ulimit["srcname"].string("Crab") 72 ulimit["srcname"].string("Crab")
73 ulimit["caldb"].string(self.caldb) 73 ulimit["caldb"].string(self.caldb)
74 ulimit["irf"].string(self.irf) 74 ulimit["irf"].string(self.irf)
75 - ulimit["outfile"].filename("ulimit.dat")  
76 75
77 # Run tool 76 # Run tool
78 self.test_try("Run ctulimit") 77 self.test_try("Run ctulimit")