diff --git a/NEWS b/NEWS index 44c11bf..97e5291 100644 --- a/NEWS +++ b/NEWS @@ -164,7 +164,7 @@ None cslightcrv - Generate light curve --------------------------------- -The script now derived from the cslikelihood base class. A "statistic" +The script now derived from the csobservation base class. A "statistic" parameter was added to allow setting the optimizer statistic for the light curve generation (#2237). @@ -220,14 +220,14 @@ The script was added to allow the generation of PHA, ARF and RMF datasets for cl csphasecrv - Generate phase curve --------------------------------- -The script now derived from the cslikelihood base class. A "statistic" +The script now derived from the csobservation base class. A "statistic" parameter was added to allow setting the optimizer statistic for the light curve generation (#2237). cspull - Generate pull distributions ------------------------------------ -The script now derived from the cslikelihood base class. A "statistic" +The script now derived from the csobservation base class. A "statistic" parameter was added to allow setting the optimizer statistic for the pull distribution generation (#2237). @@ -247,14 +247,14 @@ None cssens - Computes sensitivity curve ----------------------------------- -The script now derived from the cslikelihood base class. A "statistic" +The script now derived from the csobservation base class. A "statistic" parameter was added to allow setting the optimizer statistic for the sensitivity computation (#2237). csspec - Generates Spectral Energy Distribution ----------------------------------------------- -The script now derived from the cslikelihood base class. A "statistic" +The script now derived from the csobservation base class. A "statistic" parameter was added to allow setting the optimizer statistic for the spectrum generation (#2237). @@ -275,7 +275,7 @@ None cstsdist - Computes Test Statistic distribution ----------------------------------------------- -The script now derived from the cslikelihood base class. A "statistic" +The script now derived from the csobservation base class. A "statistic" parameter was added to allow setting the optimizer statistic for the Test Statistic distribution generation (#2237). diff --git a/cscripts/cslightcrv.py b/cscripts/cslightcrv.py index 245700a..307410c 100755 --- a/cscripts/cslightcrv.py +++ b/cscripts/cslightcrv.py @@ -28,7 +28,7 @@ from cscripts import ioutils # ================ # # cslightcrv class # # ================ # -class cslightcrv(ctools.cslikelihood): +class cslightcrv(ctools.csobservation): """ Generates a lightcurve @@ -69,7 +69,7 @@ class cslightcrv(ctools.cslikelihood): Constructor """ # Initialise application by calling the appropriate class constructor - self._init_cslikelihood('cslightcrv', ctools.__version__, argv) + self._init_csobservation('cslightcrv', ctools.__version__, argv) # Initialise some members self._srcname = '' diff --git a/cscripts/csphasecrv.py b/cscripts/csphasecrv.py index 57a1906..008158f 100755 --- a/cscripts/csphasecrv.py +++ b/cscripts/csphasecrv.py @@ -28,7 +28,7 @@ from cscripts import ioutils # ================ # # csphasecrv class # # ================ # -class csphasecrv(ctools.cslikelihood): +class csphasecrv(ctools.csobservation): """ Generates spectra in phase bins @@ -57,7 +57,7 @@ class csphasecrv(ctools.cslikelihood): Constructor """ # Initialise application by calling the appropriate class constructor - self._init_cslikelihood('csphasecrv', ctools.__version__, argv) + self._init_csobservation('csphasecrv', ctools.__version__, argv) # Initialise some members. Phases are stored in a nested list # [[ph1min,ph1max], [ph2min,ph2max],..] diff --git a/cscripts/cspull.py b/cscripts/cspull.py index 4a466cc..5c1893a 100755 --- a/cscripts/cspull.py +++ b/cscripts/cspull.py @@ -28,7 +28,7 @@ from cscripts import ioutils # ============ # # cspull class # # ============ # -class cspull(ctools.cslikelihood): +class cspull(ctools.csobservation): """ Generates pull distributions for a model """ @@ -38,7 +38,7 @@ class cspull(ctools.cslikelihood): Constructor """ # Initialise application by calling the appropriate class constructor - self._init_cslikelihood('cspull', ctools.__version__, argv) + self._init_csobservation('cspull', ctools.__version__, argv) # Initialise some members self._edisp = False diff --git a/cscripts/cssens.py b/cscripts/cssens.py index a1981e8..dd6ff23 100755 --- a/cscripts/cssens.py +++ b/cscripts/cssens.py @@ -30,7 +30,7 @@ from cscripts import ioutils # ============ # # cssens class # # ============ # -class cssens(ctools.cslikelihood): +class cssens(ctools.csobservation): """ Computes the CTA sensitivity @@ -48,7 +48,7 @@ class cssens(ctools.cslikelihood): Constructor. """ # Initialise application by calling the appropriate class constructor - self._init_cslikelihood('cssens', ctools.__version__, argv) + self._init_csobservation('cssens', ctools.__version__, argv) # Initialise class members self._ebounds = gammalib.GEbounds() diff --git a/cscripts/csspec.py b/cscripts/csspec.py index 9c80f8e..957826b 100755 --- a/cscripts/csspec.py +++ b/cscripts/csspec.py @@ -26,7 +26,7 @@ import ctools # ============ # # csspec class # # ============ # -class csspec(ctools.cslikelihood): +class csspec(ctools.csobservation): """ Generates a spectrum @@ -40,7 +40,7 @@ class csspec(ctools.cslikelihood): Constructor """ # Initialise application by calling the appropriate class constructor - self._init_cslikelihood('csspec', ctools.__version__, argv) + self._init_csobservation('csspec', ctools.__version__, argv) # Initialise data members self._ebounds = gammalib.GEbounds() diff --git a/cscripts/cstsdist.py b/cscripts/cstsdist.py index 46c754a..1b8a481 100755 --- a/cscripts/cstsdist.py +++ b/cscripts/cstsdist.py @@ -29,7 +29,7 @@ from cscripts import ioutils # ============== # # cstsdist class # # ============== # -class cstsdist(ctools.cslikelihood): +class cstsdist(ctools.csobservation): """ Generates Test Statistic distribution for a model """ @@ -40,7 +40,7 @@ class cstsdist(ctools.cslikelihood): Constructor. """ # Initialise application by calling the appropriate class constructor - self._init_cslikelihood('cstsdist', ctools.__version__, argv) + self._init_csobservation('cstsdist', ctools.__version__, argv) # Initialise some members self._srcname = '' diff --git a/pyext/ctlikelihood.i b/pyext/ctlikelihood.i index fb0bd4c..cf7da7d 100644 --- a/pyext/ctlikelihood.i +++ b/pyext/ctlikelihood.i @@ -91,12 +91,10 @@ public: const GOptimizer* opt(void) const; // Make methods protected in Python by prepending an underscore - %rename(_evaluate) evaluate; - %rename(_set_obs_statistic) set_obs_statistic; + %rename(_evaluate) evaluate; // Protected methods double evaluate(GModelPar& par, const double& value); - void set_obs_statistic(const std::string& statistic); }; diff --git a/pyext/ctobservation.i b/pyext/ctobservation.i index 23e3578..9270a21 100644 --- a/pyext/ctobservation.i +++ b/pyext/ctobservation.i @@ -90,15 +90,22 @@ public: // Public methods void obs(const GObservations& obs); const GObservations& obs(void) const; - void write_ogip_keywords(GFitsHDU* hdu) const; // Make methods private in Python by prepending an underscore %rename(_first_unbinned_observation) first_unbinned_observation; %rename(_next_unbinned_observation) next_unbinned_observation; + %rename(_write_ogip_keywords) write_ogip_keywords; + %rename(_set_obs_statistic) set_obs_statistic; + %rename(_save_events_fits) save_events_fits; + %rename(_save_events_xml) save_events_xml; // Protected methods GCTAObservation* first_unbinned_observation(void); GCTAObservation* next_unbinned_observation(void); + void write_ogip_keywords(GFitsHDU* hdu) const; + void set_obs_statistic(const std::string& statistic); + void save_events_fits(void); + void save_events_xml(void); }; diff --git a/src/support/ctlikelihood.cpp b/src/support/ctlikelihood.cpp index f7869a8..6efcd7e 100644 --- a/src/support/ctlikelihood.cpp +++ b/src/support/ctlikelihood.cpp @@ -196,49 +196,11 @@ ctlikelihood& ctlikelihood::operator=(const ctlikelihood& app) /*========================================================================== = = - = Private methods = + = Protected methods exposed in Python = = = ==========================================================================*/ /***********************************************************************//** - * @brief Initialise class members - ***************************************************************************/ -void ctlikelihood::init_members(void) -{ - // Initialise members - m_opt.clear(); - - // Return - return; -} - - -/***********************************************************************//** - * @brief Copy class members - * - * @param[in] app Likelihood tool. - ***************************************************************************/ -void ctlikelihood::copy_members(const ctlikelihood& app) -{ - // Copy members - m_opt = app.m_opt; - - // Return - return; -} - - -/***********************************************************************//** - * @brief Delete class members - ***************************************************************************/ -void ctlikelihood::free_members(void) -{ - // Return - return; -} - - -/***********************************************************************//** * @brief Evaluates the log-likelihood function * * @param[in] par Model parameter @@ -254,8 +216,8 @@ double ctlikelihood::evaluate(GModelPar& par, const double& value) // Throw an exception if the parameter is below the minimum boundary if (par.has_min() && value < par.factor_min()) { - std::string msg = "Value "+gammalib::str(value)+" of parameter \""+ - par.name()+"\" is below its minimum boundary "+ + std::string msg = "Parameter \""+par.name()+"\" value"+ + gammalib::str(value)+" is below its minimum boundary "+ gammalib::str(par.factor_min())+". To omit this " "error please lower the minimum parameter boundary."; throw GException::invalid_value(G_EVALUATE, msg); @@ -263,8 +225,8 @@ double ctlikelihood::evaluate(GModelPar& par, const double& value) // Throw an exception if the parameter is above the maximum boundary if (par.has_max() && value > par.factor_max()) { - std::string msg = "Value "+gammalib::str(value)+" of parameter \""+ - par.name()+"\" is above its maximum boundary "+ + std::string msg = "Parameter \""+par.name()+"\" value"+ + gammalib::str(value)+" is above its maximum boundary "+ gammalib::str(par.factor_max())+". To omit this " "error please raise the maximum parameter boundary."; throw GException::invalid_value(G_EVALUATE, msg); @@ -290,57 +252,45 @@ double ctlikelihood::evaluate(GModelPar& par, const double& value) } +/*========================================================================== + = = + = Protected methods = + = = + ==========================================================================*/ + /***********************************************************************//** - * @brief Set fit statistic for CTA observations - * - * @param[in] statistic Requested fit statistic. - * - * Sets the fit statistic for all CTA observations. The method handles - * regular CTA observations as well as On/Off observations. - * - * For regular CTA observations of type GCTAObservation the fit statistic is - * only set for binned or stacked observations. Possible values are - * @c POISSON, @c GAUSSIAN or @c CHI2 (case insensitive). - * - * For On/Off CTA observations of type GCTAOnOffObservation the fit statistic - * is always set. Possible values are @c POISSON, @c CSTAT or @c WSTAT (case - * insensitive). + * @brief Initialise class members + ***************************************************************************/ +void ctlikelihood::init_members(void) +{ + // Initialise members + m_opt.clear(); + + // Return + return; +} + + +/***********************************************************************//** + * @brief Copy class members * - * If @p statistic is any other string the fit statistic of the observations - * will not be modified. + * @param[in] app Likelihood tool. ***************************************************************************/ -void ctlikelihood::set_obs_statistic(const std::string& statistic) +void ctlikelihood::copy_members(const ctlikelihood& app) { - // Convert statistic to upper case - std::string ustatistic = gammalib::toupper(statistic); - - // Flag which observation types are handled - bool handle_cta = ((ustatistic == "POISSON") || - (ustatistic == "GAUSSIAN") || - (ustatistic == "CHI2")); - bool handle_onoff = ((ustatistic == "POISSON") || - (ustatistic == "CSTAT") || - (ustatistic == "WSTAT")); - - // Loop over all observation in container - for (int i = 0; i < m_obs.size(); ++i) { - - // For regular CTA observations only set statistic for binned or - // stacked observations - if ((m_obs[i]->classname() == "GCTAObservation") && handle_cta) { - if (m_obs[i]->events()->classname() == "GCTAEventCube") { - m_obs[i]->statistic(statistic); - } - } - - // For On/Off CTA observations always set statistic - else if ((m_obs[i]->classname() == "GCTAOnOffObservation") && - handle_onoff) { - m_obs[i]->statistic(statistic); - } - - } // endfor: looped over all observations + // Copy members + m_opt = app.m_opt; + + // Return + return; +} + +/***********************************************************************//** + * @brief Delete class members + ***************************************************************************/ +void ctlikelihood::free_members(void) +{ // Return return; } diff --git a/src/support/ctlikelihood.hpp b/src/support/ctlikelihood.hpp index d6c48ee..399b80d 100644 --- a/src/support/ctlikelihood.hpp +++ b/src/support/ctlikelihood.hpp @@ -66,7 +66,6 @@ protected: #endif // Protected methods in C++, public in SWIG interface double evaluate(GModelPar& par, const double& value); - void set_obs_statistic(const std::string& statistic); protected: // Protected methods diff --git a/src/support/ctobservation.cpp b/src/support/ctobservation.cpp index 2e03c6d..d65304c 100644 --- a/src/support/ctobservation.cpp +++ b/src/support/ctobservation.cpp @@ -192,119 +192,14 @@ ctobservation& ctobservation::operator=(const ctobservation& app) = = ==========================================================================*/ -/***********************************************************************//** - * @brief Write OGIP keywords in FITS HDU - * - * @param[in,out] hdu Pointer to FITS HDU. - * - * Writes OGIP keywords in FITS HDU. - ***************************************************************************/ -void ctobservation::write_ogip_keywords(GFitsHDU* hdu) const -{ - // Continue only if pointer is valid - if (hdu != NULL) { - - // Set creator - std::string creator = this->name() + " v" + this->version(); - - // Compute times - std::string utc_obs = m_ogip_tstart.utc(); - std::string utc_end = m_ogip_tstop.utc(); - std::string date_obs = utc_obs.substr(0, 10); - std::string time_obs = utc_obs.substr(11, 8); - std::string date_end = utc_end.substr(0, 10); - std::string time_end = utc_end.substr(11, 8); - - // Compute deadtime correction - double deadc = (m_ogip_ontime > 0.0) ? m_ogip_livetime / m_ogip_ontime : 1.0; - - // Set observation information - hdu->card("CREATOR", creator, "Program which created the file"); - hdu->card("TELESCOP", m_ogip_telescope, "Telescope"); - - // Set observation time information - hdu->card("DATE_OBS", date_obs, "Observation start date"); - hdu->card("TIME_OBS", time_obs, "Observation start time"); - hdu->card("DATE_END", date_end, "Observation end date"); - hdu->card("TIME_END", time_end, "Observation end time"); - hdu->card("TELAPSE", m_ogip_telapse, "[s] Elapsed time"); - hdu->card("ONTIME", m_ogip_ontime, "[s] Total good time including deadtime"); - hdu->card("LIVETIME", m_ogip_livetime, "[s] Total livetime"); - hdu->card("EXPOSURE", m_ogip_exposure, "[s] Exposure time"); - hdu->card("DEADC", deadc, "Deadtime correction factor"); - - } // endif: pointer was valid - - // Return - return; -} - /*========================================================================== = = - = Private methods = + = Protected methods exposed in Python = = = ==========================================================================*/ /***********************************************************************//** - * @brief Initialise class members - ***************************************************************************/ -void ctobservation::init_members(void) -{ - // Initialise protected members - m_obs.clear(); - - // Initialise private members - m_ogip_telescope.clear(); - m_ogip_tstart.clear(); - m_ogip_tstop.clear(); - m_ogip_telapse = 0.0; - m_ogip_exposure = 0.0; - m_ogip_ontime = 0.0; - m_ogip_livetime = 0.0; - m_index_unbinned = 0; - - // Return - return; -} - - -/***********************************************************************//** - * @brief Copy class members - * - * @param[in] app Observation tool. - ***************************************************************************/ -void ctobservation::copy_members(const ctobservation& app) -{ - // Copy protected members - m_obs = app.m_obs; - - // Copy private members - m_ogip_telescope = app.m_ogip_telescope; - m_ogip_tstart = app.m_ogip_tstart; - m_ogip_tstop = app.m_ogip_tstop; - m_ogip_telapse = app.m_ogip_telapse; - m_ogip_exposure = app.m_ogip_exposure; - m_ogip_ontime = app.m_ogip_ontime; - m_ogip_livetime = app.m_ogip_livetime; - m_index_unbinned = app.m_index_unbinned; - - // Return - return; -} - - -/***********************************************************************//** - * @brief Delete class members - ***************************************************************************/ -void ctobservation::free_members(void) -{ - // Return - return; -} - - -/***********************************************************************//** * @brief Return first unbinned CTA observation (const version) * * @return Const pointer to first unbinned CTA observation @@ -424,6 +319,110 @@ const GCTAObservation* ctobservation::next_unbinned_observation(void) const /***********************************************************************//** + * @brief Write OGIP keywords in FITS HDU + * + * @param[in,out] hdu Pointer to FITS HDU. + * + * Writes OGIP keywords in FITS HDU. + ***************************************************************************/ +void ctobservation::write_ogip_keywords(GFitsHDU* hdu) const +{ + // Continue only if pointer is valid + if (hdu != NULL) { + + // Set creator + std::string creator = this->name() + " v" + this->version(); + + // Compute times + std::string utc_obs = m_ogip_tstart.utc(); + std::string utc_end = m_ogip_tstop.utc(); + std::string date_obs = utc_obs.substr(0, 10); + std::string time_obs = utc_obs.substr(11, 8); + std::string date_end = utc_end.substr(0, 10); + std::string time_end = utc_end.substr(11, 8); + + // Compute deadtime correction + double deadc = (m_ogip_ontime > 0.0) ? m_ogip_livetime / m_ogip_ontime : 1.0; + + // Set observation information + hdu->card("CREATOR", creator, "Program which created the file"); + hdu->card("TELESCOP", m_ogip_telescope, "Telescope"); + + // Set observation time information + hdu->card("DATE_OBS", date_obs, "Observation start date"); + hdu->card("TIME_OBS", time_obs, "Observation start time"); + hdu->card("DATE_END", date_end, "Observation end date"); + hdu->card("TIME_END", time_end, "Observation end time"); + hdu->card("TELAPSE", m_ogip_telapse, "[s] Elapsed time"); + hdu->card("ONTIME", m_ogip_ontime, "[s] Total good time including deadtime"); + hdu->card("LIVETIME", m_ogip_livetime, "[s] Total livetime"); + hdu->card("EXPOSURE", m_ogip_exposure, "[s] Exposure time"); + hdu->card("DEADC", deadc, "Deadtime correction factor"); + + } // endif: pointer was valid + + // Return + return; +} + + +/***********************************************************************//** + * @brief Set fit statistic for CTA observations + * + * @param[in] statistic Requested fit statistic. + * + * Sets the fit statistic for all CTA observations. The method handles + * regular CTA observations as well as On/Off observations. + * + * For regular CTA observations of type GCTAObservation the fit statistic is + * only set for binned or stacked observations. Possible values are + * @c POISSON, @c GAUSSIAN or @c CHI2 (case insensitive). + * + * For On/Off CTA observations of type GCTAOnOffObservation the fit statistic + * is always set. Possible values are @c POISSON, @c CSTAT or @c WSTAT (case + * insensitive). + * + * If @p statistic is any other string the fit statistic of the observations + * will not be modified. + ***************************************************************************/ +void ctobservation::set_obs_statistic(const std::string& statistic) +{ + // Convert statistic to upper case + std::string ustatistic = gammalib::toupper(statistic); + + // Flag which observation types are handled + bool handle_cta = ((ustatistic == "POISSON") || + (ustatistic == "GAUSSIAN") || + (ustatistic == "CHI2")); + bool handle_onoff = ((ustatistic == "POISSON") || + (ustatistic == "CSTAT") || + (ustatistic == "WSTAT")); + + // Loop over all observation in container + for (int i = 0; i < m_obs.size(); ++i) { + + // For regular CTA observations only set statistic for binned or + // stacked observations + if ((m_obs[i]->classname() == "GCTAObservation") && handle_cta) { + if (m_obs[i]->events()->classname() == "GCTAEventCube") { + m_obs[i]->statistic(statistic); + } + } + + // For On/Off CTA observations always set statistic + else if ((m_obs[i]->classname() == "GCTAOnOffObservation") && + handle_onoff) { + m_obs[i]->statistic(statistic); + } + + } // endfor: looped over all observations + + // Return + return; +} + + +/***********************************************************************//** * @brief Save event list in FITS format. * * Save the event list as a FITS file. The file name of the FITS file is @@ -541,3 +540,67 @@ void ctobservation::save_events_xml(void) // Return return; } + + +/*========================================================================== + = = + = Protected methods = + = = + ==========================================================================*/ + +/***********************************************************************//** + * @brief Initialise class members + ***************************************************************************/ +void ctobservation::init_members(void) +{ + // Initialise protected members + m_obs.clear(); + + // Initialise private members + m_ogip_telescope.clear(); + m_ogip_tstart.clear(); + m_ogip_tstop.clear(); + m_ogip_telapse = 0.0; + m_ogip_exposure = 0.0; + m_ogip_ontime = 0.0; + m_ogip_livetime = 0.0; + m_index_unbinned = 0; + + // Return + return; +} + + +/***********************************************************************//** + * @brief Copy class members + * + * @param[in] app Observation tool. + ***************************************************************************/ +void ctobservation::copy_members(const ctobservation& app) +{ + // Copy protected members + m_obs = app.m_obs; + + // Copy private members + m_ogip_telescope = app.m_ogip_telescope; + m_ogip_tstart = app.m_ogip_tstart; + m_ogip_tstop = app.m_ogip_tstop; + m_ogip_telapse = app.m_ogip_telapse; + m_ogip_exposure = app.m_ogip_exposure; + m_ogip_ontime = app.m_ogip_ontime; + m_ogip_livetime = app.m_ogip_livetime; + m_index_unbinned = app.m_index_unbinned; + + // Return + return; +} + + +/***********************************************************************//** + * @brief Delete class members + ***************************************************************************/ +void ctobservation::free_members(void) +{ + // Return + return; +} diff --git a/src/support/ctobservation.hpp b/src/support/ctobservation.hpp index 9a3f9f8..ea823e6 100644 --- a/src/support/ctobservation.hpp +++ b/src/support/ctobservation.hpp @@ -64,24 +64,25 @@ public: // Methods void obs(const GObservations& obs); const GObservations& obs(void) const; - void write_ogip_keywords(GFitsHDU* hdu) const; #ifndef SWIG protected: #endif - // Iterator methods and members + // Protected methods GCTAObservation* first_unbinned_observation(void); GCTAObservation* next_unbinned_observation(void); const GCTAObservation* first_unbinned_observation(void) const; const GCTAObservation* next_unbinned_observation(void) const; + void write_ogip_keywords(GFitsHDU* hdu) const; + void set_obs_statistic(const std::string& statistic); + void save_events_fits(void); + void save_events_xml(void); protected: // Protected methods void init_members(void); void copy_members(const ctobservation& app); void free_members(void); - void save_events_fits(void); - void save_events_xml(void); // Protected members GObservations m_obs; //!< Observation container diff --git a/test/test_cscript.py b/test/test_cscript.py index 996bc79..f4e58da 100755 --- a/test/test_cscript.py +++ b/test/test_cscript.py @@ -166,32 +166,6 @@ class ctobservation_test(ctools.csobservation): def check_next_unbinned_observation(self): return self._next_unbinned_observation() - -# ======================= # -# ctlikelihood_test class # -# ======================= # -class ctlikelihood_test(ctools.cslikelihood): - """ - Test class for the ctlikelihood base class - """ - # Constructor - def __init__(self, *argv): - """ - Constructor - """ - # Initialise application by calling the appropriate class constructor - self._init_cslikelihood('ctlikelihood_test', ctools.__version__, argv) - - # Return - return - - # Check evaluate() method - def check_evaluate(self, value): - par = gammalib.GModelPar() - par.value(2.0) - par.range(1.0, 3.0) - return self._evaluate(par, value) - # Check set_obs_statistic() method for unbinned observation def check_set_obs_statistic_unbinned(self, statistic): obs = gammalib.GObservations() @@ -224,6 +198,32 @@ class ctlikelihood_test(ctools.cslikelihood): return gammalib.toupper(self.obs()[0].statistic()) +# ======================= # +# ctlikelihood_test class # +# ======================= # +class ctlikelihood_test(ctools.cslikelihood): + """ + Test class for the ctlikelihood base class + """ + # Constructor + def __init__(self, *argv): + """ + Constructor + """ + # Initialise application by calling the appropriate class constructor + self._init_cslikelihood('ctlikelihood_test', ctools.__version__, argv) + + # Return + return + + # Check evaluate() method + def check_evaluate(self, value): + par = gammalib.GModelPar() + par.value(2.0) + par.range(1.0, 3.0) + return self._evaluate(par, value) + + # ============================ # # Test class for base classes # # ============================ # @@ -616,33 +616,6 @@ class Test(test): self.test_assert(empty.check_next_unbinned_observation() is None, 'Check next_unbinned_observation() method') - # Return - return - - # Test ctlikelihood base class - def _test_ctlikelihood(self): - """ - Test ctlikelihood base class - """ - # Allocate empty - empty = ctlikelihood_test() - - # Test evaluate() method for minimum value violation - self.test_try('Check evaluate() for minimum value violation') - try: - empty.check_evaluate(0.0) - self.test_try_failure('Exception not thrown') - except ValueError: - self.test_try_success() - - # Test evaluate() method for maximum value violation - self.test_try('Check evaluate() for maximum value violation') - try: - empty.check_evaluate(4.0) - self.test_try_failure('Exception not thrown') - except ValueError: - self.test_try_success() - # Test set_obs_statistic() method for unbinned observation self.test_value(empty.check_set_obs_statistic_unbinned('CSTAT'), 'CSTAT', @@ -687,3 +660,30 @@ class Test(test): # Return return + + # Test ctlikelihood base class + def _test_ctlikelihood(self): + """ + Test ctlikelihood base class + """ + # Allocate empty + empty = ctlikelihood_test() + + # Test evaluate() method for minimum value violation + self.test_try('Check evaluate() for minimum value violation') + try: + empty.check_evaluate(0.0) + self.test_try_failure('Exception not thrown') + except ValueError: + self.test_try_success() + + # Test evaluate() method for maximum value violation + self.test_try('Check evaluate() for maximum value violation') + try: + empty.check_evaluate(4.0) + self.test_try_failure('Exception not thrown') + except ValueError: + self.test_try_success() + + # Return + return