Commit 80d3f320405a1f2f8bfc05c8a986d00c76b87c8c

Authored by Jürgen Knödlseder
1 parent eea337bd

Changed GObservation::statistics() to GObservation::statistic() (#2238)

ChangeLog
@@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
3 * Version 1.5.0 released 3 * Version 1.5.0 released
4 ========================= 4 =========================
5 5
  6 + Changed GObservation::statistics() to statistic() (#2238)
6 Prevent negative response values for COMPTEL IRF (#2234) 7 Prevent negative response values for COMPTEL IRF (#2234)
7 Add GCTAOnOffObservation PHA, ARF and RMF constructor (#2231) 8 Add GCTAOnOffObservation PHA, ARF and RMF constructor (#2231)
8 Implement observation stacking in GCTAOnOffObservation (#2228) 9 Implement observation stacking in GCTAOnOffObservation (#2228)
@@ -84,7 +84,8 @@ The following methods have been removed: @@ -84,7 +84,8 @@ The following methods have been removed:
84 - n.a. 84 - n.a.
85 85
86 The following methods have been renamed: 86 The following methods have been renamed:
87 -- n.a. 87 +- GObservation::statistic() was GObservation::statistics()
  88 +- GObservation::statistic(std::string&) was GObservation::statistics(std::string&)
88 89
89 The arguments for the following methods have been changed: 90 The arguments for the following methods have been changed:
90 - GCOMResponse(GCaldb&, std::string&) 91 - GCOMResponse(GCaldb&, std::string&)
doc/source/admin/release_history/1.5.rst
@@ -78,4 +78,6 @@ New features @@ -78,4 +78,6 @@ New features
78 Clean up 78 Clean up
79 -------- 79 --------
80 80
81 -* None 81 +* [`2238 <https://cta-redmine.irap.omp.eu/issues/2238>`_] -
  82 + Changed ``GObservation::statistics()`` to ``GObservation::statistic()``
  83 +
include/GObservation.hpp
1 /*************************************************************************** 1 /***************************************************************************
2 * GObservation.hpp - Abstract observation base class * 2 * GObservation.hpp - Abstract observation base class *
3 * ----------------------------------------------------------------------- * 3 * ----------------------------------------------------------------------- *
4 - * copyright (C) 2008-2016 by Juergen Knoedlseder * 4 + * copyright (C) 2008-2017 by Juergen Knoedlseder *
5 * ----------------------------------------------------------------------- * 5 * ----------------------------------------------------------------------- *
6 * * 6 * *
7 * This program is free software: you can redistribute it and/or modify * 7 * This program is free software: you can redistribute it and/or modify *
@@ -115,10 +115,10 @@ public: @@ -115,10 +115,10 @@ public:
115 // Implemented methods 115 // Implemented methods
116 void name(const std::string& name); 116 void name(const std::string& name);
117 void id(const std::string& id); 117 void id(const std::string& id);
118 - void statistics(const std::string& statistics); 118 + void statistic(const std::string& statistic);
119 const std::string& name(void) const; 119 const std::string& name(void) const;
120 const std::string& id(void) const; 120 const std::string& id(void) const;
121 - const std::string& statistics(void) const; 121 + const std::string& statistic(void) const;
122 122
123 protected: 123 protected:
124 // Protected methods 124 // Protected methods
@@ -209,7 +209,7 @@ protected: @@ -209,7 +209,7 @@ protected:
209 // Protected data area 209 // Protected data area
210 std::string m_name; //!< Observation name 210 std::string m_name; //!< Observation name
211 std::string m_id; //!< Observation identifier 211 std::string m_id; //!< Observation identifier
212 - std::string m_statistics; //!< Optimizer statistics (default=Poisson) 212 + std::string m_statistic; //!< Optimizer statistic (default=Poisson)
213 GEvents* m_events; //!< Pointer to event container 213 GEvents* m_events; //!< Pointer to event container
214 }; 214 };
215 215
@@ -245,16 +245,16 @@ void GObservation::id(const std::string&amp; id) @@ -245,16 +245,16 @@ void GObservation::id(const std::string&amp; id)
245 245
246 246
247 /***********************************************************************//** 247 /***********************************************************************//**
248 - * @brief Set optimizer statistics 248 + * @brief Set optimizer statistic
249 * 249 *
250 - * @param[in] statistics Optimizer statistics. 250 + * @param[in] statistic Optimizer statistic.
251 * 251 *
252 - * Set optimizer statistics for the observation. 252 + * Set optimizer statistic for the observation.
253 ***************************************************************************/ 253 ***************************************************************************/
254 inline 254 inline
255 -void GObservation::statistics(const std::string& statistics) 255 +void GObservation::statistic(const std::string& statistic)
256 { 256 {
257 - m_statistics = statistics; 257 + m_statistic = statistic;
258 return; 258 return;
259 } 259 }
260 260
@@ -284,14 +284,14 @@ const std::string&amp; GObservation::id(void) const @@ -284,14 +284,14 @@ const std::string&amp; GObservation::id(void) const
284 284
285 285
286 /***********************************************************************//** 286 /***********************************************************************//**
287 - * @brief Return optimizer statistics 287 + * @brief Return optimizer statistic
288 * 288 *
289 - * @return Optimizer statistics. 289 + * @return Optimizer statistic.
290 ***************************************************************************/ 290 ***************************************************************************/
291 inline 291 inline
292 -const std::string& GObservation::statistics(void) const 292 +const std::string& GObservation::statistic(void) const
293 { 293 {
294 - return (m_statistics); 294 + return (m_statistic);
295 } 295 }
296 296
297 #endif /* GOBSERVATION_HPP */ 297 #endif /* GOBSERVATION_HPP */
inst/com/src/GCOMObservation.cpp
@@ -696,7 +696,7 @@ std::string GCOMObservation::print(const GChatter&amp; chatter) const @@ -696,7 +696,7 @@ std::string GCOMObservation::print(const GChatter&amp; chatter) const
696 result.append("\n"+gammalib::parformat("Name")+name()); 696 result.append("\n"+gammalib::parformat("Name")+name());
697 result.append("\n"+gammalib::parformat("Identifier")+id()); 697 result.append("\n"+gammalib::parformat("Identifier")+id());
698 result.append("\n"+gammalib::parformat("Instrument")+instrument()); 698 result.append("\n"+gammalib::parformat("Instrument")+instrument());
699 - result.append("\n"+gammalib::parformat("Statistics")+statistics()); 699 + result.append("\n"+gammalib::parformat("Statistic")+statistic());
700 result.append("\n"+gammalib::parformat("Ontime")); 700 result.append("\n"+gammalib::parformat("Ontime"));
701 result.append(gammalib::str(ontime())+" sec"); 701 result.append(gammalib::str(ontime())+" sec");
702 result.append("\n"+gammalib::parformat("Livetime")); 702 result.append("\n"+gammalib::parformat("Livetime"));
inst/cta/src/GCTAObservation.cpp
@@ -1397,7 +1397,7 @@ std::string GCTAObservation::print(const GChatter&amp; chatter) const @@ -1397,7 +1397,7 @@ std::string GCTAObservation::print(const GChatter&amp; chatter) const
1397 result.append("\n"+gammalib::parformat("Instrument")+instrument()); 1397 result.append("\n"+gammalib::parformat("Instrument")+instrument());
1398 result.append("\n"+gammalib::parformat("Event file")+eventfile().url()); 1398 result.append("\n"+gammalib::parformat("Event file")+eventfile().url());
1399 result.append("\n"+gammalib::parformat("Event type")+eventtype()); 1399 result.append("\n"+gammalib::parformat("Event type")+eventtype());
1400 - result.append("\n"+gammalib::parformat("Statistics")+statistics()); 1400 + result.append("\n"+gammalib::parformat("Statistic")+statistic());
1401 result.append("\n"+gammalib::parformat("Ontime")); 1401 result.append("\n"+gammalib::parformat("Ontime"));
1402 result.append(gammalib::str(ontime())+" s"); 1402 result.append(gammalib::str(ontime())+" s");
1403 result.append("\n"+gammalib::parformat("Livetime")); 1403 result.append("\n"+gammalib::parformat("Livetime"));
inst/cta/src/GCTAOnOffObservation.cpp
@@ -668,7 +668,7 @@ void GCTAOnOffObservation::write(GXmlElement&amp; xml) const @@ -668,7 +668,7 @@ void GCTAOnOffObservation::write(GXmlElement&amp; xml) const
668 * @return Log-likelihood value. 668 * @return Log-likelihood value.
669 * 669 *
670 * @exception GException::invalid_value 670 * @exception GException::invalid_value
671 - * Invalid statistics encountered. 671 + * Invalid statistic encountered.
672 ***************************************************************************/ 672 ***************************************************************************/
673 double GCTAOnOffObservation::likelihood(const GModels& models, 673 double GCTAOnOffObservation::likelihood(const GModels& models,
674 GVector* gradient, 674 GVector* gradient,
@@ -678,22 +678,22 @@ double GCTAOnOffObservation::likelihood(const GModels&amp; models, @@ -678,22 +678,22 @@ double GCTAOnOffObservation::likelihood(const GModels&amp; models,
678 // Initialise likelihood value 678 // Initialise likelihood value
679 double value = 0.0; 679 double value = 0.0;
680 680
681 - // Extract statistics for this observation  
682 - std::string statistics = gammalib::toupper(this->statistics()); 681 + // Extract statistic for this observation
  682 + std::string statistic = gammalib::toupper(this->statistic());
683 683
684 - // Poisson statistics with modeled background  
685 - if ((statistics == "POISSON") || (statistics == "CSTAT")) { 684 + // Poisson statistic with modeled background
  685 + if ((statistic == "POISSON") || (statistic == "CSTAT")) {
686 value = likelihood_cstat(models, gradient, curvature, npred); 686 value = likelihood_cstat(models, gradient, curvature, npred);
687 } 687 }
688 688
689 - // ... or Poisson statistics with measured background  
690 - else if (statistics == "WSTAT") { 689 + // ... or Poisson statistic with measured background
  690 + else if (statistic == "WSTAT") {
691 value = likelihood_wstat(models, gradient, curvature, npred); 691 value = likelihood_wstat(models, gradient, curvature, npred);
692 } 692 }
693 693
694 // ... or unsupported 694 // ... or unsupported
695 else { 695 else {
696 - std::string msg = "Invalid statistics \""+statistics+"\" encountered. " 696 + std::string msg = "Invalid statistic \""+statistic+"\" encountered. "
697 "Either specify \"POISSON\", \"CSTAT\" or " 697 "Either specify \"POISSON\", \"CSTAT\" or "
698 "\"WSTAT\"."; 698 "\"WSTAT\".";
699 throw GException::invalid_value(G_LIKELIHOOD, msg); 699 throw GException::invalid_value(G_LIKELIHOOD, msg);
@@ -761,8 +761,8 @@ void GCTAOnOffObservation::init_members(void) @@ -761,8 +761,8 @@ void GCTAOnOffObservation::init_members(void)
761 m_rmf.clear(); 761 m_rmf.clear();
762 m_logetrue.clear(); 762 m_logetrue.clear();
763 763
764 - // Overwrite base class statistics  
765 - m_statistics = "POISSON"; 764 + // Overwrite base class statistic
  765 + m_statistic = "Poisson";
766 766
767 // Return 767 // Return
768 return; 768 return;
@@ -2005,7 +2005,7 @@ double GCTAOnOffObservation::likelihood_cstat(const GModels&amp; models, @@ -2005,7 +2005,7 @@ double GCTAOnOffObservation::likelihood_cstat(const GModels&amp; models,
2005 std::cout << "Number of bins with zero data: " << n_zero_data << std::endl; 2005 std::cout << "Number of bins with zero data: " << n_zero_data << std::endl;
2006 std::cout << "Sum of data (On): " << sum_data << std::endl; 2006 std::cout << "Sum of data (On): " << sum_data << std::endl;
2007 std::cout << "Sum of model (On): " << sum_model << std::endl; 2007 std::cout << "Sum of model (On): " << sum_model << std::endl;
2008 - std::cout << "Statistics: " << value << std::endl; 2008 + std::cout << "Statistic: " << value << std::endl;
2009 #endif 2009 #endif
2010 2010
2011 // Optionally dump gradient and curvature matrix 2011 // Optionally dump gradient and curvature matrix
inst/cta/test/test_CTA.cpp
@@ -231,9 +231,9 @@ void TestGCTAOptimize::set(void) @@ -231,9 +231,9 @@ void TestGCTAOptimize::set(void)
231 append(static_cast<pfunction>(&TestGCTAOptimize::test_stacked_optimizer), 231 append(static_cast<pfunction>(&TestGCTAOptimize::test_stacked_optimizer),
232 "Test stacked optimizer"); 232 "Test stacked optimizer");
233 append(static_cast<pfunction>(&TestGCTAOptimize::test_onoff_optimizer_cstat), 233 append(static_cast<pfunction>(&TestGCTAOptimize::test_onoff_optimizer_cstat),
234 - "Test On/Off optimizer using CSTAT statistics"); 234 + "Test On/Off optimizer using CSTAT statistic");
235 append(static_cast<pfunction>(&TestGCTAOptimize::test_onoff_optimizer_wstat), 235 append(static_cast<pfunction>(&TestGCTAOptimize::test_onoff_optimizer_wstat),
236 - "Test On/Off optimizer using WSTAT statistics"); 236 + "Test On/Off optimizer using WSTAT statistic");
237 237
238 // Return 238 // Return
239 return; 239 return;
@@ -2165,9 +2165,9 @@ void TestGCTAOptimize::test_onoff_optimizer_cstat(void) @@ -2165,9 +2165,9 @@ void TestGCTAOptimize::test_onoff_optimizer_cstat(void)
2165 // Load On/Off CTA observation 2165 // Load On/Off CTA observation
2166 GObservations obs(cta_onoff_obs); 2166 GObservations obs(cta_onoff_obs);
2167 2167
2168 - // Set fit statistics 2168 + // Set fit statistic
2169 for (int i = 0; i < obs.size(); ++i){ 2169 for (int i = 0; i < obs.size(); ++i){
2170 - obs[i]->statistics("CSTAT"); 2170 + obs[i]->statistic("CSTAT");
2171 } 2171 }
2172 2172
2173 // Load models from XML file 2173 // Load models from XML file
@@ -2207,9 +2207,9 @@ void TestGCTAOptimize::test_onoff_optimizer_wstat(void) @@ -2207,9 +2207,9 @@ void TestGCTAOptimize::test_onoff_optimizer_wstat(void)
2207 // Load On/Off CTA observation 2207 // Load On/Off CTA observation
2208 GObservations obs(cta_onoff_obs); 2208 GObservations obs(cta_onoff_obs);
2209 2209
2210 - // Set fit statistics 2210 + // Set fit statistic
2211 for (int i = 0; i < obs.size(); ++i){ 2211 for (int i = 0; i < obs.size(); ++i){
2212 - obs[i]->statistics("WSTAT"); 2212 + obs[i]->statistic("WSTAT");
2213 } 2213 }
2214 2214
2215 // Load models from XML file 2215 // Load models from XML file
inst/lat/src/GLATObservation.cpp
1 /*************************************************************************** 1 /***************************************************************************
2 * GLATObservation.cpp - Fermi LAT observation class * 2 * GLATObservation.cpp - Fermi LAT observation class *
3 * ----------------------------------------------------------------------- * 3 * ----------------------------------------------------------------------- *
4 - * copyright (C) 2008-2016 by Juergen Knoedlseder * 4 + * copyright (C) 2008-2017 by Juergen Knoedlseder *
5 * ----------------------------------------------------------------------- * 5 * ----------------------------------------------------------------------- *
6 * * 6 * *
7 * This program is free software: you can redistribute it and/or modify * 7 * This program is free software: you can redistribute it and/or modify *
@@ -502,7 +502,7 @@ void GLATObservation::write(GXmlElement&amp; xml) const @@ -502,7 +502,7 @@ void GLATObservation::write(GXmlElement&amp; xml) const
502 /***********************************************************************//** 502 /***********************************************************************//**
503 * @brief Print LAT observation information 503 * @brief Print LAT observation information
504 * 504 *
505 - * @param[in] chatter Chattiness (defaults to NORMAL). 505 + * @param[in] chatter Chattiness.
506 * @return String containing LAT observation information. 506 * @return String containing LAT observation information.
507 ***************************************************************************/ 507 ***************************************************************************/
508 std::string GLATObservation::print(const GChatter& chatter) const 508 std::string GLATObservation::print(const GChatter& chatter) const
@@ -520,7 +520,7 @@ std::string GLATObservation::print(const GChatter&amp; chatter) const @@ -520,7 +520,7 @@ std::string GLATObservation::print(const GChatter&amp; chatter) const
520 result.append("\n"+gammalib::parformat("Name")+name()); 520 result.append("\n"+gammalib::parformat("Name")+name());
521 result.append("\n"+gammalib::parformat("Identifier")+id()); 521 result.append("\n"+gammalib::parformat("Identifier")+id());
522 result.append("\n"+gammalib::parformat("Instrument")+instrument()); 522 result.append("\n"+gammalib::parformat("Instrument")+instrument());
523 - result.append("\n"+gammalib::parformat("Statistics")+statistics()); 523 + result.append("\n"+gammalib::parformat("Statistic")+statistic());
524 result.append("\n"+gammalib::parformat("Ontime")); 524 result.append("\n"+gammalib::parformat("Ontime"));
525 result.append(gammalib::str(ontime())+" s"); 525 result.append(gammalib::str(ontime())+" s");
526 result.append("\n"+gammalib::parformat("Livetime")); 526 result.append("\n"+gammalib::parformat("Livetime"));
inst/mwl/src/GMWLObservation.cpp
1 /*************************************************************************** 1 /***************************************************************************
2 * GMWLObservation.cpp - Multi-wavelength observation class * 2 * GMWLObservation.cpp - Multi-wavelength observation class *
3 * ----------------------------------------------------------------------- * 3 * ----------------------------------------------------------------------- *
4 - * copyright (C) 2010-2016 by Juergen Knoedlseder * 4 + * copyright (C) 2010-2017 by Juergen Knoedlseder *
5 * ----------------------------------------------------------------------- * 5 * ----------------------------------------------------------------------- *
6 * * 6 * *
7 * This program is free software: you can redistribute it and/or modify * 7 * This program is free software: you can redistribute it and/or modify *
@@ -350,7 +350,7 @@ std::string GMWLObservation::print(const GChatter&amp; chatter) const @@ -350,7 +350,7 @@ std::string GMWLObservation::print(const GChatter&amp; chatter) const
350 result.append("\n"+gammalib::parformat("Name")+name()); 350 result.append("\n"+gammalib::parformat("Name")+name());
351 result.append("\n"+gammalib::parformat("Identifier")+id()); 351 result.append("\n"+gammalib::parformat("Identifier")+id());
352 result.append("\n"+gammalib::parformat("Instrument")+instrument()); 352 result.append("\n"+gammalib::parformat("Instrument")+instrument());
353 - result.append("\n"+gammalib::parformat("Statistics")+statistics()); 353 + result.append("\n"+gammalib::parformat("Statistic")+statistic());
354 354
355 // EXPLICIT: Append events 355 // EXPLICIT: Append events
356 if (chatter >= EXPLICIT) { 356 if (chatter >= EXPLICIT) {
@@ -386,8 +386,8 @@ void GMWLObservation::init_members(void) @@ -386,8 +386,8 @@ void GMWLObservation::init_members(void)
386 m_filename.clear(); 386 m_filename.clear();
387 m_response.clear(); 387 m_response.clear();
388 388
389 - // Overwrite base class statistics  
390 - m_statistics = "Gaussian"; 389 + // Overwrite base class statistic
  390 + m_statistic = "Gaussian";
391 391
392 // Return 392 // Return
393 return; 393 return;
pyext/GObservation.i
1 /*************************************************************************** 1 /***************************************************************************
2 * GObservation.i - Abstract observation base class * 2 * GObservation.i - Abstract observation base class *
3 * ----------------------------------------------------------------------- * 3 * ----------------------------------------------------------------------- *
4 - * copyright (C) 2008-2014 by Juergen Knoedlseder * 4 + * copyright (C) 2008-2017 by Juergen Knoedlseder *
5 * ----------------------------------------------------------------------- * 5 * ----------------------------------------------------------------------- *
6 * * 6 * *
7 * This program is free software: you can redistribute it and/or modify * 7 * This program is free software: you can redistribute it and/or modify *
@@ -94,10 +94,10 @@ public: @@ -94,10 +94,10 @@ public:
94 // Implemented methods 94 // Implemented methods
95 void name(const std::string& name); 95 void name(const std::string& name);
96 void id(const std::string& id); 96 void id(const std::string& id);
97 - void statistics(const std::string& statistics); 97 + void statistic(const std::string& statistic);
98 const std::string& name(void) const; 98 const std::string& name(void) const;
99 const std::string& id(void) const; 99 const std::string& id(void) const;
100 - const std::string& statistics(void) const; 100 + const std::string& statistic(void) const;
101 }; 101 };
102 102
103 103
src/obs/GObservation.cpp
1 /*************************************************************************** 1 /***************************************************************************
2 * GObservation.cpp - Abstract observation base class * 2 * GObservation.cpp - Abstract observation base class *
3 * ----------------------------------------------------------------------- * 3 * ----------------------------------------------------------------------- *
4 - * copyright (C) 2008-2016 by Juergen Knoedlseder * 4 + * copyright (C) 2008-2017 by Juergen Knoedlseder *
5 * ----------------------------------------------------------------------- * 5 * ----------------------------------------------------------------------- *
6 * * 6 * *
7 * This program is free software: you can redistribute it and/or modify * 7 * This program is free software: you can redistribute it and/or modify *
@@ -181,14 +181,14 @@ double GObservation::likelihood(const GModels&amp; models, @@ -181,14 +181,14 @@ double GObservation::likelihood(const GModels&amp; models,
181 // Initialise likelihood value 181 // Initialise likelihood value
182 double value = 0.0; 182 double value = 0.0;
183 183
184 - // Extract statistics for this observation  
185 - std::string statistics = gammalib::toupper(this->statistics()); 184 + // Extract statistic for this observation
  185 + std::string statistic = gammalib::toupper(this->statistic());
186 186
187 // Unbinned analysis 187 // Unbinned analysis
188 if (dynamic_cast<const GEventList*>(events()) != NULL) { 188 if (dynamic_cast<const GEventList*>(events()) != NULL) {
189 189
190 - // Poisson statistics  
191 - if (statistics == "POISSON") { 190 + // Poisson statistic
  191 + if (statistic == "POISSON") {
192 192
193 // Update the log-likelihood 193 // Update the log-likelihood
194 value = likelihood_poisson_unbinned(models, 194 value = likelihood_poisson_unbinned(models,
@@ -196,12 +196,13 @@ double GObservation::likelihood(const GModels&amp; models, @@ -196,12 +196,13 @@ double GObservation::likelihood(const GModels&amp; models,
196 curvature, 196 curvature,
197 npred); 197 npred);
198 198
199 - } // endif: Poisson statistics 199 + } // endif: Poisson statistic
200 200
201 // ... otherwise throw an exception 201 // ... otherwise throw an exception
202 else { 202 else {
203 - throw GException::invalid_statistics(G_LIKELIHOOD, statistics,  
204 - "Unbinned optimization requires Poisson statistics."); 203 + std::string msg = "Invalid statistic \""+statistic+"\". Unbinned "
  204 + "optimization requires \"POISSON\" statistic.";
  205 + throw GException::invalid_value(G_LIKELIHOOD, msg);
205 } 206 }
206 207
207 } // endif: unbinned analysis 208 } // endif: unbinned analysis
@@ -209,27 +210,28 @@ double GObservation::likelihood(const GModels&amp; models, @@ -209,27 +210,28 @@ double GObservation::likelihood(const GModels&amp; models,
209 // ... or binned analysis 210 // ... or binned analysis
210 else { 211 else {
211 212
212 - // Poisson statistics  
213 - if (statistics == "POISSON") { 213 + // Poisson statistic
  214 + if (statistic == "POISSON") {
214 value = likelihood_poisson_binned(models, 215 value = likelihood_poisson_binned(models,
215 gradient, 216 gradient,
216 curvature, 217 curvature,
217 npred); 218 npred);
218 } 219 }
219 220
220 - // ... or Gaussian statistics  
221 - else if (statistics == "GAUSSIAN") { 221 + // ... or Gaussian statistic
  222 + else if (statistic == "GAUSSIAN") {
222 value = likelihood_gaussian_binned(models, 223 value = likelihood_gaussian_binned(models,
223 - gradient,  
224 - curvature,  
225 - npred); 224 + gradient,
  225 + curvature,
  226 + npred);
226 } 227 }
227 228
228 // ... or unsupported 229 // ... or unsupported
229 else { 230 else {
230 - throw GException::invalid_statistics(G_LIKELIHOOD, statistics,  
231 - "Binned optimization requires Poisson or Gaussian"  
232 - " statistics."); 231 + std::string msg = "Invalid statistic \""+statistic+"\". Unbinned "
  232 + "optimization requires \"POISSON\" or "
  233 + "\"GAUSSIAN\" statistic.";
  234 + throw GException::invalid_value(G_LIKELIHOOD, msg);
233 } 235 }
234 236
235 } // endelse: binned analysis 237 } // endelse: binned analysis
@@ -833,8 +835,8 @@ void GObservation::init_members(void) @@ -833,8 +835,8 @@ void GObservation::init_members(void)
833 // Initialise members 835 // Initialise members
834 m_name.clear(); 836 m_name.clear();
835 m_id.clear(); 837 m_id.clear();
836 - m_statistics = "Poisson";  
837 - m_events = NULL; 838 + m_statistic = "Poisson";
  839 + m_events = NULL;
838 840
839 // Return 841 // Return
840 return; 842 return;
@@ -851,9 +853,9 @@ void GObservation::init_members(void) @@ -851,9 +853,9 @@ void GObservation::init_members(void)
851 void GObservation::copy_members(const GObservation& obs) 853 void GObservation::copy_members(const GObservation& obs)
852 { 854 {
853 // Copy members 855 // Copy members
854 - m_name = obs.m_name;  
855 - m_id = obs.m_id;  
856 - m_statistics = obs.m_statistics; 856 + m_name = obs.m_name;
  857 + m_id = obs.m_id;
  858 + m_statistic = obs.m_statistic;
857 859
858 // Clone members 860 // Clone members
859 m_events = (obs.m_events != NULL) ? obs.m_events->clone() : NULL; 861 m_events = (obs.m_events != NULL) ? obs.m_events->clone() : NULL;
@@ -886,7 +888,7 @@ void GObservation::free_members(void) @@ -886,7 +888,7 @@ void GObservation::free_members(void)
886 ==========================================================================*/ 888 ==========================================================================*/
887 889
888 /***********************************************************************//** 890 /***********************************************************************//**
889 - * @brief Evaluate log-likelihood function for Poisson statistics and 891 + * @brief Evaluate log-likelihood function for Poisson statistic and
890 * unbinned analysis (version with working arrays) 892 * unbinned analysis (version with working arrays)
891 * 893 *
892 * @param[in] models Models. 894 * @param[in] models Models.
@@ -896,7 +898,7 @@ void GObservation::free_members(void) @@ -896,7 +898,7 @@ void GObservation::free_members(void)
896 * @return Likelihood value. 898 * @return Likelihood value.
897 * 899 *
898 * This method evaluates the -(log-likelihood) function for parameter 900 * This method evaluates the -(log-likelihood) function for parameter
899 - * optimisation using unbinned analysis and Poisson statistics. 901 + * optimisation using unbinned analysis and Poisson statistic.
900 * The -(log-likelihood) function is given by 902 * The -(log-likelihood) function is given by
901 * 903 *
902 * \f[ 904 * \f[
@@ -960,7 +962,7 @@ double GObservation::likelihood_poisson_unbinned(const GModels&amp; models, @@ -960,7 +962,7 @@ double GObservation::likelihood_poisson_unbinned(const GModels&amp; models,
960 } 962 }
961 } 963 }
962 964
963 - // Update Poissonian statistics (excluding factorial term for faster 965 + // Update Poissonian statistic (excluding factorial term for faster
964 // computation) 966 // computation)
965 value -= log(model); 967 value -= log(model);
966 968
@@ -1006,7 +1008,7 @@ double GObservation::likelihood_poisson_unbinned(const GModels&amp; models, @@ -1006,7 +1008,7 @@ double GObservation::likelihood_poisson_unbinned(const GModels&amp; models,
1006 1008
1007 1009
1008 /***********************************************************************//** 1010 /***********************************************************************//**
1009 - * @brief Evaluate log-likelihood function for Poisson statistics and 1011 + * @brief Evaluate log-likelihood function for Poisson statistic and
1010 * binned analysis (version with working arrays) 1012 * binned analysis (version with working arrays)
1011 * 1013 *
1012 * @param[in] models Models. 1014 * @param[in] models Models.
@@ -1016,7 +1018,7 @@ double GObservation::likelihood_poisson_unbinned(const GModels&amp; models, @@ -1016,7 +1018,7 @@ double GObservation::likelihood_poisson_unbinned(const GModels&amp; models,
1016 * @return Likelihood value. 1018 * @return Likelihood value.
1017 * 1019 *
1018 * This method evaluates the -(log-likelihood) function for parameter 1020 * This method evaluates the -(log-likelihood) function for parameter
1019 - * optimisation using binned analysis and Poisson statistics. 1021 + * optimisation using binned analysis and Poisson statistic.
1020 * The -(log-likelihood) function is given by 1022 * The -(log-likelihood) function is given by
1021 * 1023 *
1022 * \f[ 1024 * \f[
@@ -1039,7 +1041,7 @@ double GObservation::likelihood_poisson_binned(const GModels&amp; models, @@ -1039,7 +1041,7 @@ double GObservation::likelihood_poisson_binned(const GModels&amp; models,
1039 // Initialise likelihood value 1041 // Initialise likelihood value
1040 double value = 0.0; 1042 double value = 0.0;
1041 1043
1042 - // Initialise statistics 1044 + // Initialise statistic
1043 #if defined(G_OPT_DEBUG) 1045 #if defined(G_OPT_DEBUG)
1044 int n_bins = 0; 1046 int n_bins = 0;
1045 int n_used = 0; 1047 int n_used = 0;
@@ -1096,7 +1098,7 @@ double GObservation::likelihood_poisson_binned(const GModels&amp; models, @@ -1096,7 +1098,7 @@ double GObservation::likelihood_poisson_binned(const GModels&amp; models,
1096 continue; 1098 continue;
1097 } 1099 }
1098 1100
1099 - // Update statistics 1101 + // Update statistic
1100 #if defined(G_OPT_DEBUG) 1102 #if defined(G_OPT_DEBUG)
1101 n_used++; 1103 n_used++;
1102 sum_data += data; 1104 sum_data += data;
@@ -1127,7 +1129,7 @@ double GObservation::likelihood_poisson_binned(const GModels&amp; models, @@ -1127,7 +1129,7 @@ double GObservation::likelihood_poisson_binned(const GModels&amp; models,
1127 // matrix ... 1129 // matrix ...
1128 if (data > 0.0) { 1130 if (data > 0.0) {
1129 1131
1130 - // Update Poissonian statistics (excluding factorial term for 1132 + // Update Poissonian statistic (excluding factorial term for
1131 // faster computation) 1133 // faster computation)
1132 value -= data * log(model) - model; 1134 value -= data * log(model) - model;
1133 1135
@@ -1168,12 +1170,12 @@ double GObservation::likelihood_poisson_binned(const GModels&amp; models, @@ -1168,12 +1170,12 @@ double GObservation::likelihood_poisson_binned(const GModels&amp; models,
1168 // ... handle now data=0 1170 // ... handle now data=0
1169 else { 1171 else {
1170 1172
1171 - // Update statistics 1173 + // Update statistic
1172 #if defined(G_OPT_DEBUG) 1174 #if defined(G_OPT_DEBUG)
1173 n_zero_data++; 1175 n_zero_data++;
1174 #endif 1176 #endif
1175 1177
1176 - // Update Poissonian statistics (excluding factorial term for 1178 + // Update Poissonian statistic (excluding factorial term for
1177 // faster computation) 1179 // faster computation)
1178 value += model; 1180 value += model;
1179 1181
@@ -1196,7 +1198,7 @@ double GObservation::likelihood_poisson_binned(const GModels&amp; models, @@ -1196,7 +1198,7 @@ double GObservation::likelihood_poisson_binned(const GModels&amp; models,
1196 if (values != NULL) delete [] values; 1198 if (values != NULL) delete [] values;
1197 if (inx != NULL) delete [] inx; 1199 if (inx != NULL) delete [] inx;
1198 1200
1199 - // Dump statistics 1201 + // Dump statistic
1200 #if defined(G_OPT_DEBUG) 1202 #if defined(G_OPT_DEBUG)
1201 std::cout << "Number of bins: " << n_bins << std::endl; 1203 std::cout << "Number of bins: " << n_bins << std::endl;
1202 std::cout << "Number of bins used for computation: " << n_used << std::endl; 1204 std::cout << "Number of bins used for computation: " << n_used << std::endl;
@@ -1205,8 +1207,8 @@ double GObservation::likelihood_poisson_binned(const GModels&amp; models, @@ -1205,8 +1207,8 @@ double GObservation::likelihood_poisson_binned(const GModels&amp; models,
1205 std::cout << "Number of bins with zero data: " << n_zero_data << std::endl; 1207 std::cout << "Number of bins with zero data: " << n_zero_data << std::endl;
1206 std::cout << "Sum of data: " << sum_data << std::endl; 1208 std::cout << "Sum of data: " << sum_data << std::endl;
1207 std::cout << "Sum of model: " << sum_model << std::endl; 1209 std::cout << "Sum of model: " << sum_model << std::endl;
1208 - std::cout << "Initial statistics: " << init_value << std::endl;  
1209 - std::cout << "Statistics: " << m_value-init_value << std::endl; 1210 + std::cout << "Initial statistic: " << init_value << std::endl;
  1211 + std::cout << "Statistic: " << m_value-init_value << std::endl;
1210 #endif 1212 #endif
1211 1213
1212 // Return 1214 // Return
@@ -1215,7 +1217,7 @@ double GObservation::likelihood_poisson_binned(const GModels&amp; models, @@ -1215,7 +1217,7 @@ double GObservation::likelihood_poisson_binned(const GModels&amp; models,
1215 1217
1216 1218
1217 /***********************************************************************//** 1219 /***********************************************************************//**
1218 - * @brief Evaluate log-likelihood function for Gaussian statistics and 1220 + * @brief Evaluate log-likelihood function for Gaussian statistic and
1219 * binned analysis (version with working arrays) 1221 * binned analysis (version with working arrays)
1220 * 1222 *
1221 * @param[in] models Models. 1223 * @param[in] models Models.
@@ -1225,7 +1227,7 @@ double GObservation::likelihood_poisson_binned(const GModels&amp; models, @@ -1225,7 +1227,7 @@ double GObservation::likelihood_poisson_binned(const GModels&amp; models,
1225 * @return Likelihood value. 1227 * @return Likelihood value.
1226 * 1228 *
1227 * This method evaluates the -(log-likelihood) function for parameter 1229 * This method evaluates the -(log-likelihood) function for parameter
1228 - * optimisation using binned analysis and Poisson statistics. 1230 + * optimisation using binned analysis and Poisson statistic.
1229 * The -(log-likelihood) function is given by 1231 * The -(log-likelihood) function is given by
1230 * 1232 *
1231 * \f[ 1233 * \f[
@@ -1311,7 +1313,7 @@ double GObservation::likelihood_gaussian_binned(const GModels&amp; models, @@ -1311,7 +1313,7 @@ double GObservation::likelihood_gaussian_binned(const GModels&amp; models,
1311 // Set weight 1313 // Set weight
1312 double weight = 1.0 / (sigma * sigma); 1314 double weight = 1.0 / (sigma * sigma);
1313 1315
1314 - // Update Gaussian statistics 1316 + // Update Gaussian statistic
1315 double fa = data - model; 1317 double fa = data - model;
1316 value += 0.5 * (fa * fa * weight); 1318 value += 0.5 * (fa * fa * weight);
1317 1319
src/template/GXXXObservation.cpp
@@ -304,7 +304,7 @@ std::string GXXXObservation::print(const GChatter&amp; chatter) const @@ -304,7 +304,7 @@ std::string GXXXObservation::print(const GChatter&amp; chatter) const
304 result.append("\n"+gammalib::parformat("Name")+name()); 304 result.append("\n"+gammalib::parformat("Name")+name());
305 result.append("\n"+gammalib::parformat("Identifier")+id()); 305 result.append("\n"+gammalib::parformat("Identifier")+id());
306 result.append("\n"+gammalib::parformat("Instrument")+instrument()); 306 result.append("\n"+gammalib::parformat("Instrument")+instrument());
307 - result.append("\n"+gammalib::parformat("Statistics")+statistics()); 307 + result.append("\n"+gammalib::parformat("Statistic")+statistic());
308 result.append("\n"+gammalib::parformat("Ontime")); 308 result.append("\n"+gammalib::parformat("Ontime"));
309 result.append(gammalib::str(ontime())+" sec"); 309 result.append(gammalib::str(ontime())+" sec");
310 result.append("\n"+gammalib::parformat("Livetime")); 310 result.append("\n"+gammalib::parformat("Livetime"));