Commit b3540bee1f2c2b071203cf4b8c8ae1fbc96104ea
1 parent
34468df1
Use log_parameters() with GClobber argument (#1828)
Showing
39 changed files
with
208 additions
and
288 deletions
cscripts/cscaldb.py
cscripts/csfindobs.py
| ... | ... | @@ -154,10 +154,8 @@ class csfindobs(ctools.cscript): |
| 154 | 154 | (self._obs_index, self._prodname)) |
| 155 | 155 | raise RuntimeError(msg) |
| 156 | 156 | |
| 157 | - # Write input parameters into logger | |
| 158 | - if self._logTerse(): | |
| 159 | - self._log_parameters() | |
| 160 | - self._log('\n') | |
| 157 | + # Write input parameters into logger | |
| 158 | + self._log_parameters(gammalib.TERSE) | |
| 161 | 159 | |
| 162 | 160 | # Return |
| 163 | 161 | return | ... | ... |
cscripts/csiactcopy.py
| ... | ... | @@ -80,11 +80,9 @@ class csiactcopy(ctools.cscript): |
| 80 | 80 | self._outpath = gammalib.expand_env(self['outpath'].string()) |
| 81 | 81 | self._runlist = self['runlist'].filename() |
| 82 | 82 | |
| 83 | - # Write input parameters into logger | |
| 84 | - if self._logTerse(): | |
| 85 | - self._log_parameters() | |
| 86 | - self._log('\n') | |
| 87 | - | |
| 83 | + # Write input parameters into logger | |
| 84 | + self._log_parameters(gammalib.TERSE) | |
| 85 | + | |
| 88 | 86 | # Return |
| 89 | 87 | return |
| 90 | 88 | ... | ... |
cscripts/csiactdata.py
| ... | ... | @@ -83,10 +83,8 @@ class csiactdata(ctools.cscript): |
| 83 | 83 | '"master_indx" to specifiy a different '+ |
| 84 | 84 | 'filename.') |
| 85 | 85 | |
| 86 | - # Write input parameters into logger | |
| 87 | - if self._logTerse(): | |
| 88 | - self._log_parameters() | |
| 89 | - self._log('\n') | |
| 86 | + # Write input parameters into logger | |
| 87 | + self._log_parameters(gammalib.TERSE) | |
| 90 | 88 | |
| 91 | 89 | # Return |
| 92 | 90 | return | ... | ... |
cscripts/csiactobs.py
| ... | ... | @@ -214,10 +214,8 @@ class csiactobs(ctools.cscript): |
| 214 | 214 | self._subdir = os.path.dirname(self._hdu_index) |
| 215 | 215 | self._debug = False # Debugging in client tools |
| 216 | 216 | |
| 217 | - # Write input parameters into logger | |
| 218 | - if self._logTerse(): | |
| 219 | - self._log_parameters() | |
| 220 | - self._log('\n') | |
| 217 | + # Write input parameters into logger | |
| 218 | + self._log_parameters(gammalib.TERSE) | |
| 221 | 219 | |
| 222 | 220 | # Return |
| 223 | 221 | return | ... | ... |
cscripts/cslightcrv.py
| ... | ... | @@ -140,9 +140,7 @@ class cslightcrv(ctools.cscript): |
| 140 | 140 | self['outfile'].filename() |
| 141 | 141 | |
| 142 | 142 | # Write input parameters into logger |
| 143 | - if self._logTerse(): | |
| 144 | - self._log_parameters() | |
| 145 | - self._log('\n') | |
| 143 | + self._log_parameters(gammalib.TERSE) | |
| 146 | 144 | |
| 147 | 145 | # Return |
| 148 | 146 | return | ... | ... |
cscripts/csmodelinfo.py
| ... | ... | @@ -80,10 +80,8 @@ class csmodelinfo(ctools.cscript): |
| 80 | 80 | if self._read_ahead(): |
| 81 | 81 | self["ds9file"].filename() |
| 82 | 82 | |
| 83 | - # Write input parameters into logger | |
| 84 | - if self._logTerse(): | |
| 85 | - self._log_parameters() | |
| 86 | - self._log('\n') | |
| 83 | + # Write input parameters into logger | |
| 84 | + self._log_parameters(gammalib.TERSE) | |
| 87 | 85 | |
| 88 | 86 | # Return |
| 89 | 87 | return | ... | ... |
cscripts/csmodelmerge.py
| ... | ... | @@ -107,10 +107,8 @@ class csmodelmerge(ctools.cscript): |
| 107 | 107 | # Get clobber parameter |
| 108 | 108 | self._clobber = self['clobber'].boolean() |
| 109 | 109 | |
| 110 | - # Write input parameters into logger | |
| 111 | - if self._logTerse(): | |
| 112 | - self._log_parameters() | |
| 113 | - self._log('\n') | |
| 110 | + # Write input parameters into logger | |
| 111 | + self._log_parameters(gammalib.TERSE) | |
| 114 | 112 | |
| 115 | 113 | # Return |
| 116 | 114 | return | ... | ... |
cscripts/csobs2caldb.py
| ... | ... | @@ -128,10 +128,8 @@ class csobs2caldb(ctools.cscript): |
| 128 | 128 | self['irf'].string() |
| 129 | 129 | self['rootdir'].string() |
| 130 | 130 | |
| 131 | - # Write input parameters and header into logger | |
| 132 | - if self._logTerse(): | |
| 133 | - self._log_parameters() | |
| 134 | - self._log('\n') | |
| 131 | + # Write input parameters into logger | |
| 132 | + self._log_parameters(gammalib.TERSE) | |
| 135 | 133 | |
| 136 | 134 | # Return |
| 137 | 135 | return | ... | ... |
cscripts/csobsdef.py
| ... | ... | @@ -112,10 +112,8 @@ class csobsdef(ctools.cscript): |
| 112 | 112 | if self._read_ahead(): |
| 113 | 113 | self['outobs'].filename() |
| 114 | 114 | |
| 115 | - # Write input parameters into logger | |
| 116 | - if self._logTerse(): | |
| 117 | - self._log_parameters() | |
| 118 | - self._log('\n') | |
| 115 | + # Write input parameters into logger | |
| 116 | + self._log_parameters(gammalib.TERSE) | |
| 119 | 117 | |
| 120 | 118 | # Return |
| 121 | 119 | return | ... | ... |
cscripts/csobsinfo.py
| ... | ... | @@ -86,10 +86,8 @@ class csobsinfo(ctools.cscript): |
| 86 | 86 | if self._read_ahead(): |
| 87 | 87 | self['ds9file'].filename() |
| 88 | 88 | |
| 89 | - # Write input parameters into logger | |
| 90 | - if self._logTerse(): | |
| 91 | - self._log_parameters() | |
| 92 | - self._log('\n') | |
| 89 | + # Write input parameters into logger | |
| 90 | + self._log_parameters(gammalib.TERSE) | |
| 93 | 91 | |
| 94 | 92 | # Return |
| 95 | 93 | return | ... | ... |
cscripts/cspull.py
| ... | ... | @@ -123,9 +123,7 @@ class cspull(ctools.cscript): |
| 123 | 123 | self['profile'].boolean() |
| 124 | 124 | |
| 125 | 125 | # Write input parameters into logger |
| 126 | - if self._logTerse(): | |
| 127 | - self._log_parameters() | |
| 128 | - self._log('\n') | |
| 126 | + self._log_parameters(gammalib.TERSE) | |
| 129 | 127 | |
| 130 | 128 | # Return |
| 131 | 129 | return | ... | ... |
cscripts/csresmap.py
| ... | ... | @@ -129,10 +129,8 @@ class csresmap(ctools.cscript): |
| 129 | 129 | if (self._read_ahead()): |
| 130 | 130 | self['outmap'].filename() |
| 131 | 131 | |
| 132 | - # Write input parameters into logger | |
| 133 | - if self._logTerse(): | |
| 134 | - self._log_parameters() | |
| 135 | - self._log('\n') | |
| 132 | + # Write input parameters into logger | |
| 133 | + self._log_parameters(gammalib.TERSE) | |
| 136 | 134 | |
| 137 | 135 | # Return |
| 138 | 136 | return | ... | ... |
cscripts/csroot2caldb.py
| ... | ... | @@ -79,10 +79,8 @@ class csroot2caldb(ctools.cscript): |
| 79 | 79 | self['bgdoversample'].integer() |
| 80 | 80 | self['bgdinfill'].boolean() |
| 81 | 81 | |
| 82 | - # Write input parameters into logger | |
| 83 | - if self._logTerse(): | |
| 84 | - self._log_parameters() | |
| 85 | - self._log('\n') | |
| 82 | + # Write input parameters into logger | |
| 83 | + self._log_parameters(gammalib.TERSE) | |
| 86 | 84 | |
| 87 | 85 | # Return |
| 88 | 86 | return | ... | ... |
cscripts/cssens.py
| ... | ... | @@ -124,10 +124,8 @@ class cssens(ctools.cscript): |
| 124 | 124 | gammalib.GEnergy(self._emin, 'TeV'), |
| 125 | 125 | gammalib.GEnergy(self._emax, 'TeV')) |
| 126 | 126 | |
| 127 | - # Write input parameters into logger | |
| 128 | - if self._logTerse(): | |
| 129 | - self._log_parameters() | |
| 130 | - self._log('\n') | |
| 127 | + # Write input parameters into logger | |
| 128 | + self._log_parameters(gammalib.TERSE) | |
| 131 | 129 | |
| 132 | 130 | # Return |
| 133 | 131 | return | ... | ... |
cscripts/csspec.py
| ... | ... | @@ -122,10 +122,8 @@ class csspec(ctools.cscript): |
| 122 | 122 | if self._read_ahead(): |
| 123 | 123 | self["outfile"].filename() |
| 124 | 124 | |
| 125 | - # Write input parameters into logger | |
| 126 | - if self._logTerse(): | |
| 127 | - self._log_parameters() | |
| 128 | - self._log("\n") | |
| 125 | + # Write input parameters into logger | |
| 126 | + self._log_parameters(gammalib.TERSE) | |
| 129 | 127 | |
| 130 | 128 | # Return |
| 131 | 129 | return | ... | ... |
cscripts/cstsdist.py
| ... | ... | @@ -102,10 +102,8 @@ class cstsdist(ctools.cscript): |
| 102 | 102 | self['outfile'].filename() |
| 103 | 103 | self['debug'].boolean() |
| 104 | 104 | |
| 105 | - # Write input parameters into logger | |
| 106 | - if self._logTerse(): | |
| 107 | - self._log_parameters() | |
| 108 | - self._log('\n') | |
| 105 | + # Write input parameters into logger | |
| 106 | + self._log_parameters(gammalib.TERSE) | |
| 109 | 107 | |
| 110 | 108 | # Return |
| 111 | 109 | return | ... | ... |
cscripts/cstsmapmerge.py
| ... | ... | @@ -118,10 +118,8 @@ class cstsmapmerge(ctools.cscript): |
| 118 | 118 | if self._read_ahead(): |
| 119 | 119 | self['outmap'].filename() |
| 120 | 120 | |
| 121 | - # Write input parameters into logger | |
| 122 | - if self._logTerse(): | |
| 123 | - self._log_parameters() | |
| 124 | - self._log('\n') | |
| 121 | + # Write input parameters into logger | |
| 122 | + self._log_parameters(gammalib.TERSE) | |
| 125 | 123 | |
| 126 | 124 | # Return |
| 127 | 125 | return | ... | ... |
cscripts/cstsmapsplit.py
| ... | ... | @@ -92,10 +92,8 @@ class cstsmapsplit(ctools.cscript): |
| 92 | 92 | self._compute_null = self['compute_null'].boolean() |
| 93 | 93 | self._outfile = self['outfile'].filename() |
| 94 | 94 | |
| 95 | - # Write input parameters into logger | |
| 96 | - if self._logTerse(): | |
| 97 | - self._log_parameters() | |
| 98 | - self._log('\n') | |
| 95 | + # Write input parameters into logger | |
| 96 | + self._log_parameters(gammalib.TERSE) | |
| 99 | 97 | |
| 100 | 98 | # Return |
| 101 | 99 | return | ... | ... |
cscripts/csworkflow.py
| ... | ... | @@ -76,9 +76,7 @@ class csworkflow(ctools.cscript): |
| 76 | 76 | self._workflow = gammalib.GXml(xmlfile.url()) |
| 77 | 77 | |
| 78 | 78 | # Write input parameters into logger |
| 79 | - if self._logTerse(): | |
| 80 | - self._log_parameters() | |
| 81 | - self._log('\n') | |
| 79 | + self._log_parameters(gammalib.TERSE) | |
| 82 | 80 | |
| 83 | 81 | # Return |
| 84 | 82 | return | ... | ... |
src/ctbin/ctbin.cpp
| ... | ... | @@ -226,47 +226,34 @@ void ctbin::run(void) |
| 226 | 226 | // Get task parameters |
| 227 | 227 | get_parameters(); |
| 228 | 228 | |
| 229 | - // Write observation(s) into logger | |
| 230 | - if (logTerse()) { | |
| 231 | - log << std::endl; | |
| 232 | - log.header1(gammalib::number("Observation", m_obs.size())); | |
| 233 | - log << m_obs.print(m_chatter) << std::endl; | |
| 234 | - } | |
| 229 | + // Write input observation container into logger | |
| 230 | + log_observations(NORMAL, m_obs); | |
| 235 | 231 | |
| 236 | 232 | // Write header |
| 237 | - if (logTerse()) { | |
| 238 | - log << std::endl; | |
| 239 | - log.header1(gammalib::number("Bin observation", m_obs.size())); | |
| 240 | - } | |
| 233 | + log_header1(TERSE, gammalib::number("Bin observation", m_obs.size())); | |
| 241 | 234 | |
| 242 | 235 | // Loop over all observations in the container |
| 243 | 236 | for (int i = 0; i < m_obs.size(); ++i) { |
| 244 | 237 | |
| 245 | 238 | // Write header for observation |
| 246 | - if (logTerse()) { | |
| 247 | - log.header3(get_obs_header(m_obs[i])); | |
| 248 | - } | |
| 239 | + log_header3(NORMAL, get_obs_header(m_obs[i])); | |
| 249 | 240 | |
| 250 | 241 | // Get CTA observation |
| 251 | 242 | GCTAObservation* obs = dynamic_cast<GCTAObservation*>(m_obs[i]); |
| 252 | 243 | |
| 253 | 244 | // Skip observation if it's not CTA |
| 254 | 245 | if (obs == NULL) { |
| 255 | - if (logTerse()) { | |
| 256 | - log << " Skipping "; | |
| 257 | - log << m_obs[i]->instrument(); | |
| 258 | - log << " observation" << std::endl; | |
| 259 | - } | |
| 246 | + std::string msg = " Skipping "+m_obs[i]->instrument()+ | |
| 247 | + " observation\n"; | |
| 248 | + log_string(NORMAL, msg); | |
| 260 | 249 | continue; |
| 261 | 250 | } |
| 262 | 251 | |
| 263 | 252 | // Skip observation if we have a binned observation |
| 264 | 253 | if (obs->eventtype() == "CountsCube") { |
| 265 | - if (logTerse()) { | |
| 266 | - log << " Skipping binned "; | |
| 267 | - log << obs->instrument(); | |
| 268 | - log << " observation" << std::endl; | |
| 269 | - } | |
| 254 | + std::string msg = " Skipping binned "+m_obs[i]->instrument()+ | |
| 255 | + " observation\n"; | |
| 256 | + log_string(NORMAL, msg); | |
| 270 | 257 | continue; |
| 271 | 258 | } |
| 272 | 259 | |
| ... | ... | @@ -288,12 +275,8 @@ void ctbin::run(void) |
| 288 | 275 | // Set a single cube in the observation container |
| 289 | 276 | obs_cube(); |
| 290 | 277 | |
| 291 | - // Write observation(s) into logger | |
| 292 | - if (logTerse()) { | |
| 293 | - log << std::endl; | |
| 294 | - log.header1(gammalib::number("Binned observation", m_obs.size())); | |
| 295 | - log << m_obs.print(m_chatter) << std::endl; | |
| 296 | - } | |
| 278 | + // Write resulting observation container into logger | |
| 279 | + log_observations(NORMAL, m_obs, "Binned observation"); | |
| 297 | 280 | |
| 298 | 281 | // Optionally publish counts cube |
| 299 | 282 | if (m_publish) { |
| ... | ... | @@ -313,10 +296,7 @@ void ctbin::run(void) |
| 313 | 296 | void ctbin::save(void) |
| 314 | 297 | { |
| 315 | 298 | // Write header |
| 316 | - if (logTerse()) { | |
| 317 | - log << std::endl; | |
| 318 | - log.header1("Save counts cube"); | |
| 319 | - } | |
| 299 | + log_header1(TERSE, "Save counts cube"); | |
| 320 | 300 | |
| 321 | 301 | // Get counts cube filename |
| 322 | 302 | m_outcube = (*this)["outcube"].filename(); |
| ... | ... | @@ -330,11 +310,8 @@ void ctbin::save(void) |
| 330 | 310 | // Save only if observation is valid |
| 331 | 311 | if (obs != NULL) { |
| 332 | 312 | |
| 333 | - // Log filename | |
| 334 | - if (logTerse()) { | |
| 335 | - log << gammalib::parformat("Counts cube file"); | |
| 336 | - log << m_outcube.url() << std::endl; | |
| 337 | - } | |
| 313 | + // Log counts cube file name | |
| 314 | + log_value(NORMAL, "Counts cube file", m_outcube.url()); | |
| 338 | 315 | |
| 339 | 316 | // Save cube |
| 340 | 317 | obs->save(m_outcube, clobber()); |
| ... | ... | @@ -356,10 +333,7 @@ void ctbin::save(void) |
| 356 | 333 | void ctbin::publish(const std::string& name) |
| 357 | 334 | { |
| 358 | 335 | // Write header |
| 359 | - if (logTerse()) { | |
| 360 | - log << std::endl; | |
| 361 | - log.header1("Publish counts cube"); | |
| 362 | - } | |
| 336 | + log_header1(TERSE, "Publish counts cube"); | |
| 363 | 337 | |
| 364 | 338 | // Set default name is user name is empty |
| 365 | 339 | std::string user_name(name); |
| ... | ... | @@ -367,11 +341,8 @@ void ctbin::publish(const std::string& name) |
| 367 | 341 | user_name = CTBIN_NAME; |
| 368 | 342 | } |
| 369 | 343 | |
| 370 | - // Log filename | |
| 371 | - if (logTerse()) { | |
| 372 | - log << gammalib::parformat("Counts cube name"); | |
| 373 | - log << user_name << std::endl; | |
| 374 | - } | |
| 344 | + // Log counts cube name | |
| 345 | + log_value(NORMAL, "Counts cube name", user_name); | |
| 375 | 346 | |
| 376 | 347 | // Publish counts cube |
| 377 | 348 | m_counts.publish(user_name); |
| ... | ... | @@ -500,10 +471,7 @@ void ctbin::get_parameters(void) |
| 500 | 471 | } |
| 501 | 472 | |
| 502 | 473 | // Write parameters into logger |
| 503 | - if (logTerse()) { | |
| 504 | - log_parameters(); | |
| 505 | - log << std::endl; | |
| 506 | - } | |
| 474 | + log_parameters(TERSE); | |
| 507 | 475 | |
| 508 | 476 | // Return |
| 509 | 477 | return; |
| ... | ... | @@ -610,23 +578,14 @@ void ctbin::fill_cube(GCTAObservation* obs) |
| 610 | 578 | m_livetime += obs->livetime(); |
| 611 | 579 | |
| 612 | 580 | // Log filling results |
| 613 | - if (logTerse()) { | |
| 614 | - log << gammalib::parformat("Events in list"); | |
| 615 | - log << obs->events()->size() << std::endl; | |
| 616 | - log << gammalib::parformat("Events in cube"); | |
| 617 | - log << num_in_map << std::endl; | |
| 618 | - log << gammalib::parformat("Event bins outside RoI"); | |
| 619 | - log << num_outside_roi << std::endl; | |
| 620 | - log << gammalib::parformat("Events outside cube area"); | |
| 621 | - log << num_outside_map << std::endl; | |
| 622 | - log << gammalib::parformat("Events outside energy bins"); | |
| 623 | - log << num_outside_ebds << std::endl; | |
| 624 | - } | |
| 581 | + log_value(TERSE, "Events in list", obs->events()->size()); | |
| 582 | + log_value(TERSE, "Events in cube", num_in_map); | |
| 583 | + log_value(TERSE, "Event bins outside RoI", num_outside_roi); | |
| 584 | + log_value(TERSE, "Events outside cube area", num_outside_map); | |
| 585 | + log_value(TERSE, "Events outside energy bins", num_outside_ebds); | |
| 625 | 586 | |
| 626 | 587 | // Log cube |
| 627 | - if (logExplicit()) { | |
| 628 | - log << m_counts << std::endl; | |
| 629 | - } | |
| 588 | + log_string(EXPLICIT, m_counts.print()); | |
| 630 | 589 | |
| 631 | 590 | } // endif: observation was valid |
| 632 | 591 | ... | ... |
src/ctbkgcube/ctbkgcube.cpp
| ... | ... | @@ -211,12 +211,6 @@ void ctbkgcube::run(void) |
| 211 | 211 | // Get task parameters |
| 212 | 212 | get_parameters(); |
| 213 | 213 | |
| 214 | - // Write parameters into logger | |
| 215 | - if (logTerse()) { | |
| 216 | - log_parameters(); | |
| 217 | - log << std::endl; | |
| 218 | - } | |
| 219 | - | |
| 220 | 214 | // Warn if there are not enough energy bins |
| 221 | 215 | int n = m_background.energies().size(); |
| 222 | 216 | double logEmin = std::log10(m_background.energies()[0].TeV()); |
| ... | ... | @@ -605,6 +599,9 @@ void ctbkgcube::get_parameters(void) |
| 605 | 599 | m_outmodel = (*this)["outmodel"].filename(); |
| 606 | 600 | } |
| 607 | 601 | |
| 602 | + // Write parameters into logger | |
| 603 | + log_parameters(TERSE); | |
| 604 | + | |
| 608 | 605 | // Return |
| 609 | 606 | return; |
| 610 | 607 | } | ... | ... |
src/ctbutterfly/ctbutterfly.cpp
| ... | ... | @@ -211,12 +211,6 @@ void ctbutterfly::run(void) |
| 211 | 211 | // Get task parameters |
| 212 | 212 | get_parameters(); |
| 213 | 213 | |
| 214 | - // Write parameters into logger | |
| 215 | - if (logTerse()) { | |
| 216 | - log_parameters(); | |
| 217 | - log << std::endl; | |
| 218 | - } | |
| 219 | - | |
| 220 | 214 | // Set energy dispersion flag for all CTA observations and save old |
| 221 | 215 | // values in save_edisp vector |
| 222 | 216 | std::vector<bool> save_edisp; |
| ... | ... | @@ -687,6 +681,9 @@ void ctbutterfly::get_parameters(void) |
| 687 | 681 | m_outfile = (*this)["outfile"].filename(); |
| 688 | 682 | } |
| 689 | 683 | |
| 684 | + // Write parameters into logger | |
| 685 | + log_parameters(TERSE); | |
| 686 | + | |
| 690 | 687 | // Return |
| 691 | 688 | return; |
| 692 | 689 | } | ... | ... |
src/ctcubemask/ctcubemask.cpp
| ... | ... | @@ -212,12 +212,6 @@ void ctcubemask::run(void) |
| 212 | 212 | // Get parameters |
| 213 | 213 | get_parameters(); |
| 214 | 214 | |
| 215 | - // Write parameters into logger | |
| 216 | - if (logTerse()) { | |
| 217 | - log_parameters(); | |
| 218 | - log << std::endl; | |
| 219 | - } | |
| 220 | - | |
| 221 | 215 | // Write observation(s) into logger |
| 222 | 216 | if (logTerse()) { |
| 223 | 217 | log << std::endl; |
| ... | ... | @@ -471,6 +465,9 @@ void ctcubemask::get_parameters(void) |
| 471 | 465 | m_prefix = (*this)["prefix"].string(); |
| 472 | 466 | } |
| 473 | 467 | |
| 468 | + // Write parameters into logger | |
| 469 | + log_parameters(TERSE); | |
| 470 | + | |
| 474 | 471 | // Return |
| 475 | 472 | return; |
| 476 | 473 | } | ... | ... |
src/ctedispcube/ctedispcube.cpp
| ... | ... | @@ -223,12 +223,6 @@ void ctedispcube::run(void) |
| 223 | 223 | // Get task parameters |
| 224 | 224 | get_parameters(); |
| 225 | 225 | |
| 226 | - // Write parameters into logger | |
| 227 | - if (logTerse()) { | |
| 228 | - log_parameters(); | |
| 229 | - log << std::endl; | |
| 230 | - } | |
| 231 | - | |
| 232 | 226 | // Write header |
| 233 | 227 | if (logTerse()) { |
| 234 | 228 | log << std::endl; |
| ... | ... | @@ -417,6 +411,9 @@ void ctedispcube::get_parameters(void) |
| 417 | 411 | m_outcube = (*this)["outcube"].filename(); |
| 418 | 412 | } |
| 419 | 413 | |
| 414 | + // Write parameters into logger | |
| 415 | + log_parameters(TERSE); | |
| 416 | + | |
| 420 | 417 | // Return |
| 421 | 418 | return; |
| 422 | 419 | } | ... | ... |
src/cterror/cterror.cpp
| ... | ... | @@ -224,12 +224,6 @@ void cterror::run(void) |
| 224 | 224 | // Get task parameters |
| 225 | 225 | get_parameters(); |
| 226 | 226 | |
| 227 | - // Write parameters into logger | |
| 228 | - if (logTerse()) { | |
| 229 | - log_parameters(); | |
| 230 | - log << std::endl; | |
| 231 | - } | |
| 232 | - | |
| 233 | 227 | // Set energy dispersion flag for all CTA observations and save old |
| 234 | 228 | // values in save_edisp vector |
| 235 | 229 | std::vector<bool> save_edisp; |
| ... | ... | @@ -568,6 +562,9 @@ void cterror::get_parameters(void) |
| 568 | 562 | m_outmodel = (*this)["outmodel"].filename(); |
| 569 | 563 | } |
| 570 | 564 | |
| 565 | + // Write parameters into logger | |
| 566 | + log_parameters(TERSE); | |
| 567 | + | |
| 571 | 568 | // Return |
| 572 | 569 | return; |
| 573 | 570 | } | ... | ... |
src/ctexpcube/ctexpcube.cpp
| ... | ... | @@ -211,12 +211,6 @@ void ctexpcube::run(void) |
| 211 | 211 | // Get task parameters |
| 212 | 212 | get_parameters(); |
| 213 | 213 | |
| 214 | - // Write parameters into logger | |
| 215 | - if (logTerse()) { | |
| 216 | - log_parameters(); | |
| 217 | - log << std::endl; | |
| 218 | - } | |
| 219 | - | |
| 220 | 214 | // Warn if there are not enough energy bins |
| 221 | 215 | int n = m_expcube.energies().size(); |
| 222 | 216 | double logEmin = std::log10(m_expcube.energies()[0].TeV()); |
| ... | ... | @@ -460,6 +454,9 @@ void ctexpcube::get_parameters(void) |
| 460 | 454 | m_outcube = (*this)["outcube"].filename(); |
| 461 | 455 | } |
| 462 | 456 | |
| 457 | + // Write parameters into logger | |
| 458 | + log_parameters(TERSE); | |
| 459 | + | |
| 463 | 460 | // Return |
| 464 | 461 | return; |
| 465 | 462 | } | ... | ... |
src/ctlike/ctlike.cpp
| ... | ... | @@ -209,12 +209,6 @@ void ctlike::run(void) |
| 209 | 209 | // Get parameters |
| 210 | 210 | get_parameters(); |
| 211 | 211 | |
| 212 | - // Write parameters into logger | |
| 213 | - if (logTerse()) { | |
| 214 | - log_parameters(); | |
| 215 | - log << std::endl; | |
| 216 | - } | |
| 217 | - | |
| 218 | 212 | // Set energy dispersion flag for all CTA observations and save old |
| 219 | 213 | // values in save_edisp vector |
| 220 | 214 | std::vector<bool> save_edisp; |
| ... | ... | @@ -441,6 +435,9 @@ void ctlike::get_parameters(void) |
| 441 | 435 | static_cast<GOptimizerLM*>(m_opt)->logger(NULL); |
| 442 | 436 | } |
| 443 | 437 | |
| 438 | + // Write parameters into logger | |
| 439 | + log_parameters(TERSE); | |
| 440 | + | |
| 444 | 441 | // Return |
| 445 | 442 | return; |
| 446 | 443 | } | ... | ... |
src/ctmapcube/ctmapcube.cpp
| ... | ... | @@ -380,10 +380,7 @@ void ctmapcube::get_parameters(void) |
| 380 | 380 | m_cube = GModelSpatialDiffuseCube(cube, energies); |
| 381 | 381 | |
| 382 | 382 | // Write parameters into logger |
| 383 | - if (logTerse()) { | |
| 384 | - log_parameters(); | |
| 385 | - log << std::endl; | |
| 386 | - } | |
| 383 | + log_parameters(TERSE); | |
| 387 | 384 | |
| 388 | 385 | // Return |
| 389 | 386 | return; | ... | ... |
src/ctmodel/ctmodel.cpp
| ... | ... | @@ -211,12 +211,6 @@ void ctmodel::run(void) |
| 211 | 211 | // Get task parameters |
| 212 | 212 | get_parameters(); |
| 213 | 213 | |
| 214 | - // Write parameters into logger | |
| 215 | - if (logTerse()) { | |
| 216 | - log_parameters(); | |
| 217 | - log << std::endl; | |
| 218 | - } | |
| 219 | - | |
| 220 | 214 | // Set energy dispersion flag for all CTA observations and save old |
| 221 | 215 | // values in save_edisp vector |
| 222 | 216 | std::vector<bool> save_edisp; |
| ... | ... | @@ -618,6 +612,9 @@ void ctmodel::get_parameters(void) |
| 618 | 612 | |
| 619 | 613 | } // endif: cube was scheduled for appending |
| 620 | 614 | |
| 615 | + // Write parameters into logger | |
| 616 | + log_parameters(TERSE); | |
| 617 | + | |
| 621 | 618 | // Return |
| 622 | 619 | return; |
| 623 | 620 | } | ... | ... |
src/ctobssim/ctobssim.cpp
| ... | ... | @@ -231,12 +231,6 @@ void ctobssim::run(void) |
| 231 | 231 | // Get parameters |
| 232 | 232 | get_parameters(); |
| 233 | 233 | |
| 234 | - // Write input parameters into logger | |
| 235 | - if (logTerse()) { | |
| 236 | - log_parameters(); | |
| 237 | - log << std::endl; | |
| 238 | - } | |
| 239 | - | |
| 240 | 234 | // Special mode: if read ahead is specified we know that we called |
| 241 | 235 | // the execute() method, hence files are saved immediately and event |
| 242 | 236 | // lists are disposed afterwards. |
| ... | ... | @@ -665,6 +659,9 @@ void ctobssim::get_parameters(void) |
| 665 | 659 | |
| 666 | 660 | } // endfor: looped over observations |
| 667 | 661 | |
| 662 | + // Write parameters into logger | |
| 663 | + log_parameters(TERSE); | |
| 664 | + | |
| 668 | 665 | // Return |
| 669 | 666 | return; |
| 670 | 667 | } | ... | ... |
src/ctpsfcube/ctpsfcube.cpp
| ... | ... | @@ -210,12 +210,6 @@ void ctpsfcube::run(void) |
| 210 | 210 | // Get task parameters |
| 211 | 211 | get_parameters(); |
| 212 | 212 | |
| 213 | - // Write parameters into logger | |
| 214 | - if (logTerse()) { | |
| 215 | - log_parameters(); | |
| 216 | - log << std::endl; | |
| 217 | - } | |
| 218 | - | |
| 219 | 213 | // Write header |
| 220 | 214 | if (logTerse()) { |
| 221 | 215 | log << std::endl; |
| ... | ... | @@ -401,6 +395,9 @@ void ctpsfcube::get_parameters(void) |
| 401 | 395 | m_outcube = (*this)["outcube"].filename(); |
| 402 | 396 | } |
| 403 | 397 | |
| 398 | + // Write parameters into logger | |
| 399 | + log_parameters(TERSE); | |
| 400 | + | |
| 404 | 401 | // Return |
| 405 | 402 | return; |
| 406 | 403 | } | ... | ... |
src/ctselect/ctselect.cpp
| ... | ... | @@ -218,12 +218,6 @@ void ctselect::run(void) |
| 218 | 218 | // Get parameters |
| 219 | 219 | get_parameters(); |
| 220 | 220 | |
| 221 | - // Write parameters into logger | |
| 222 | - if (logTerse()) { | |
| 223 | - log_parameters(); | |
| 224 | - log << std::endl; | |
| 225 | - } | |
| 226 | - | |
| 227 | 221 | // Write observation(s) into logger |
| 228 | 222 | if (logTerse()) { |
| 229 | 223 | log << std::endl; |
| ... | ... | @@ -623,6 +617,9 @@ void ctselect::get_parameters(void) |
| 623 | 617 | m_timemin.set(m_tmin, m_cta_ref); |
| 624 | 618 | m_timemax.set(m_tmax, m_cta_ref); |
| 625 | 619 | |
| 620 | + // Write parameters into logger | |
| 621 | + log_parameters(TERSE); | |
| 622 | + | |
| 626 | 623 | // Return |
| 627 | 624 | return; |
| 628 | 625 | } | ... | ... |
src/ctskymap/ctskymap.cpp
| ... | ... | @@ -215,12 +215,6 @@ void ctskymap::run(void) |
| 215 | 215 | // Get parameters |
| 216 | 216 | get_parameters(); |
| 217 | 217 | |
| 218 | - // Write parameters into logger | |
| 219 | - if (logTerse()) { | |
| 220 | - log_parameters(); | |
| 221 | - log << std::endl; | |
| 222 | - } | |
| 223 | - | |
| 224 | 218 | // Write observation(s) into logger |
| 225 | 219 | if (logTerse()) { |
| 226 | 220 | log << std::endl; |
| ... | ... | @@ -414,6 +408,9 @@ void ctskymap::get_parameters(void) |
| 414 | 408 | m_outmap = (*this)["outmap"].filename(); |
| 415 | 409 | } |
| 416 | 410 | |
| 411 | + // Write parameters into logger | |
| 412 | + log_parameters(TERSE); | |
| 413 | + | |
| 417 | 414 | // Return |
| 418 | 415 | return; |
| 419 | 416 | } | ... | ... |
src/cttsmap/cttsmap.cpp
| ... | ... | @@ -209,12 +209,6 @@ void cttsmap::run(void) |
| 209 | 209 | // Get task parameters |
| 210 | 210 | get_parameters(); |
| 211 | 211 | |
| 212 | - // Write parameters into logger | |
| 213 | - if (logTerse()) { | |
| 214 | - log_parameters(); | |
| 215 | - log << std::endl; | |
| 216 | - } | |
| 217 | - | |
| 218 | 212 | // Set energy dispersion flag for all CTA observations and save old |
| 219 | 213 | // values in save_edisp vector |
| 220 | 214 | std::vector<bool> save_edisp; |
| ... | ... | @@ -630,6 +624,9 @@ void cttsmap::get_parameters(void) |
| 630 | 624 | m_outmap = (*this)["outmap"].filename(); |
| 631 | 625 | } |
| 632 | 626 | |
| 627 | + // Write parameters into logger | |
| 628 | + log_parameters(TERSE); | |
| 629 | + | |
| 633 | 630 | // Return |
| 634 | 631 | return; |
| 635 | 632 | } | ... | ... |
src/ctulimit/ctulimit.cpp
| ... | ... | @@ -225,12 +225,6 @@ void ctulimit::run(void) |
| 225 | 225 | // Get task parameters |
| 226 | 226 | get_parameters(); |
| 227 | 227 | |
| 228 | - // Write parameters into logger | |
| 229 | - if (logTerse()) { | |
| 230 | - log_parameters(); | |
| 231 | - log << std::endl; | |
| 232 | - } | |
| 233 | - | |
| 234 | 228 | // Set energy dispersion flag for all CTA observations and save old |
| 235 | 229 | // values in save_edisp vector |
| 236 | 230 | std::vector<bool> save_edisp; |
| ... | ... | @@ -582,6 +576,9 @@ void ctulimit::get_parameters(void) |
| 582 | 576 | m_tol = (*this)["tol"].real(); |
| 583 | 577 | m_max_iter = (*this)["max_iter"].integer(); |
| 584 | 578 | |
| 579 | + // Write parameters into logger | |
| 580 | + log_parameters(TERSE); | |
| 581 | + | |
| 585 | 582 | // Return |
| 586 | 583 | return; |
| 587 | 584 | } | ... | ... |
src/support/ctool.cpp
| ... | ... | @@ -894,6 +894,40 @@ void ctool::require_inobs_nocube(const std::string& method) |
| 894 | 894 | |
| 895 | 895 | |
| 896 | 896 | /***********************************************************************//** |
| 897 | + * @brief Log observation container | |
| 898 | + * | |
| 899 | + * @param[in] chatter Minimum required chattiness | |
| 900 | + * @param[in] obs Observation container | |
| 901 | + * @param[in] what String specifying the container content | |
| 902 | + * | |
| 903 | + * Log observations if chattiness is at least @p chatter. | |
| 904 | + ***************************************************************************/ | |
| 905 | +void ctool::log_observations(const GChatter& chatter, | |
| 906 | + const GObservations& obs, | |
| 907 | + const std::string& what) | |
| 908 | +{ | |
| 909 | + // Get chattiness of ctool | |
| 910 | + GChatter chattiness = static_cast<GChatter>((*this)["chatter"].integer()); | |
| 911 | + | |
| 912 | + // Only write message if chattiness is at least equal to the minimum | |
| 913 | + // required chattiness | |
| 914 | + if (chattiness >= chatter) { | |
| 915 | + | |
| 916 | + // Log observation header | |
| 917 | + log << std::endl; | |
| 918 | + log.header1(gammalib::number(what, obs.size())); | |
| 919 | + | |
| 920 | + // Log observation content dependent on chattiness | |
| 921 | + log << obs.print(chattiness) << std::endl; | |
| 922 | + | |
| 923 | + } // endif: Chattiness satisfied minimum required level | |
| 924 | + | |
| 925 | + // Return | |
| 926 | + return; | |
| 927 | +} | |
| 928 | + | |
| 929 | + | |
| 930 | +/***********************************************************************//** | |
| 897 | 931 | * @brief Set response for all CTA observations in container |
| 898 | 932 | * |
| 899 | 933 | * @param[in,out] obs Observation container | ... | ... |
src/support/ctool.hpp
| ... | ... | @@ -85,6 +85,11 @@ protected: |
| 85 | 85 | void require_inobs_nolist(const std::string& method); |
| 86 | 86 | void require_inobs_nocube(const std::string& method); |
| 87 | 87 | |
| 88 | + // Protected methods for logging | |
| 89 | + void log_observations(const GChatter& chatter, | |
| 90 | + const GObservations& obs, | |
| 91 | + const std::string& what = "Observation"); | |
| 92 | + | |
| 88 | 93 | // Protected support methods |
| 89 | 94 | void set_response(GObservations& obs); |
| 90 | 95 | void set_obs_response(GCTAObservation* obs); | ... | ... |
test/test_ctbin.py
| ... | ... | @@ -71,8 +71,8 @@ class Test(test): |
| 71 | 71 | # Setup ctbin command |
| 72 | 72 | cmd = ctbin+' inobs="'+self._events+'"'+ \ |
| 73 | 73 | ' outcube="cntmap_cmd1.fits"'+\ |
| 74 | - ' emin=0.1 emax=100.0 enumbins=20 ebinalg="LOG"'+ \ | |
| 75 | - ' nxpix=200 nypix=200 binsz=0.02 coordsys="CEL"'+ \ | |
| 74 | + ' emin=0.1 emax=100.0 enumbins=10 ebinalg="LOG"'+ \ | |
| 75 | + ' nxpix=40 nypix=40 binsz=0.1 coordsys="CEL"'+ \ | |
| 76 | 76 | ' xref=83.63 yref=22.01 proj="CAR"'+ \ |
| 77 | 77 | ' logfile="ctbin_cmd1.log" chatter=1' |
| 78 | 78 | |
| ... | ... | @@ -91,8 +91,8 @@ class Test(test): |
| 91 | 91 | # Setup ctbin command |
| 92 | 92 | cmd = ctbin+' inobs="events_that_do_not_exist.fits"'+ \ |
| 93 | 93 | ' outcube="cntmap_cmd2.fits"'+\ |
| 94 | - ' emin=0.1 emax=100.0 enumbins=20 ebinalg="LOG"'+ \ | |
| 95 | - ' nxpix=200 nypix=200 binsz=0.02 coordsys="CEL"'+ \ | |
| 94 | + ' emin=0.1 emax=100.0 enumbins=10 ebinalg="LOG"'+ \ | |
| 95 | + ' nxpix=40 nypix=40 binsz=0.1 coordsys="CEL"'+ \ | |
| 96 | 96 | ' xref=83.63 yref=22.01 proj="CAR"'+ \ |
| 97 | 97 | ' logfile="ctbin_cmd1.log" chatter=1' |
| 98 | 98 | |
| ... | ... | @@ -108,17 +108,33 @@ class Test(test): |
| 108 | 108 | """ |
| 109 | 109 | Test ctbin from Python |
| 110 | 110 | """ |
| 111 | - # Set-up ctbin | |
| 111 | + # Allocate ctbin | |
| 112 | + bin = ctools.ctbin() | |
| 113 | + | |
| 114 | + # Check that empty ctbin has an empty observation container and counts | |
| 115 | + # cube | |
| 116 | + self.test_value(bin.obs().size(), 0, | |
| 117 | + 'Check that empty ctbin has an empty observation container') | |
| 118 | + self.test_value(bin.cube().size(), 0, | |
| 119 | + 'Check that empty ctbin has an empty counts cube') | |
| 120 | + | |
| 121 | + # Check that saving and publishing does nothing | |
| 122 | + bin['debug'] = True | |
| 123 | + bin['outcube'] = 'ctbin_py0.fits' | |
| 124 | + #bin.save() # Segfaults, see issue #1835 | |
| 125 | + #bin.publish() # Segfaults, see issue #1835 | |
| 126 | + | |
| 127 | + # Set ctbin parameters | |
| 112 | 128 | bin = ctools.ctbin() |
| 113 | 129 | bin['inobs'] = self._events |
| 114 | - bin['outcube'] = 'cntmap.fits' | |
| 130 | + bin['outcube'] = 'ctbin_py1.fits' | |
| 115 | 131 | bin['ebinalg'] = 'LOG' |
| 116 | 132 | bin['emin'] = 0.1 |
| 117 | 133 | bin['emax'] = 100.0 |
| 118 | - bin['enumbins'] = 20 | |
| 119 | - bin['nxpix'] = 200 | |
| 120 | - bin['nypix'] = 200 | |
| 121 | - bin['binsz'] = 0.02 | |
| 134 | + bin['enumbins'] = 10 | |
| 135 | + bin['nxpix'] = 40 | |
| 136 | + bin['nypix'] = 40 | |
| 137 | + bin['binsz'] = 0.1 | |
| 122 | 138 | bin['coordsys'] = 'CEL' |
| 123 | 139 | bin['proj'] = 'CAR' |
| 124 | 140 | bin['xref'] = 83.63 |
| ... | ... | @@ -132,14 +148,14 @@ class Test(test): |
| 132 | 148 | # see issue #1823 (need to fix that) |
| 133 | 149 | bin.run() |
| 134 | 150 | |
| 135 | - # Check content of observation and cube | |
| 151 | + # Check content of observation container and counts cube | |
| 136 | 152 | self._check_observation(bin, 5542) |
| 137 | 153 | self._check_cube(bin.cube(), 5542) |
| 138 | 154 | |
| 139 | 155 | # Test copy constructor |
| 140 | 156 | cpy_bin = bin.copy() |
| 141 | 157 | |
| 142 | - # Check content of observation and cube | |
| 158 | + # Check content of observation container and counts cube | |
| 143 | 159 | self._check_observation(cpy_bin, 5542) |
| 144 | 160 | self._check_cube(cpy_bin.cube(), 5542) |
| 145 | 161 | |
| ... | ... | @@ -148,20 +164,29 @@ class Test(test): |
| 148 | 164 | cpy_bin['chatter'] = 3 |
| 149 | 165 | cpy_bin.run() |
| 150 | 166 | |
| 151 | - # Check content of observation and cube. We expect now an empty | |
| 152 | - # event cube as on input the observation is binned, and any binned | |
| 153 | - # observation will be skipped, hence the counts cube should be | |
| 154 | - # empty. | |
| 167 | + # Check content of observation container and counts cube. Now an empty | |
| 168 | + # event cube is expected since on input the observation is binned, and | |
| 169 | + # any binned observation will be skipped. | |
| 155 | 170 | self._check_observation(cpy_bin, 0) |
| 156 | 171 | self._check_cube(cpy_bin.cube(), 0) |
| 157 | 172 | |
| 158 | 173 | # Save counts cube |
| 159 | 174 | bin.save() |
| 160 | 175 | |
| 161 | - # Load counts cube and check content. | |
| 162 | - evt = gammalib.GCTAEventCube('cntmap.fits') | |
| 176 | + # Load counts cube and check content | |
| 177 | + evt = gammalib.GCTAEventCube('ctbin_py1.fits') | |
| 163 | 178 | self._check_cube(evt, 5542) |
| 164 | 179 | |
| 180 | + # Now clear ctbin tool | |
| 181 | + #bin.clear() # Segfaults, see issue #1835 | |
| 182 | + | |
| 183 | + # Check that cleared ctbin has an empty observation container and | |
| 184 | + # counts cube | |
| 185 | + #self.test_value(bin.obs().size(), 0, | |
| 186 | + # 'Check that empty ctbin has an empty observation container') | |
| 187 | + #self.test_value(bin.cube().size(), 0, | |
| 188 | + # 'Check that empty ctbin has an empty counts cube') | |
| 189 | + | |
| 165 | 190 | # Prepare observation container for stacked analysis |
| 166 | 191 | cta = gammalib.GCTAObservation(self._events) |
| 167 | 192 | obs = gammalib.GObservations() |
| ... | ... | @@ -174,52 +199,33 @@ class Test(test): |
| 174 | 199 | |
| 175 | 200 | # Set-up ctbin using an observation container |
| 176 | 201 | bin = ctools.ctbin(obs) |
| 177 | - bin['outcube'] = 'cntmap.fits' | |
| 202 | + bin['outcube'] = 'ctbin_py3.fits' | |
| 178 | 203 | bin['ebinalg'] = 'LOG' |
| 179 | 204 | bin['emin'] = 0.1 |
| 180 | 205 | bin['emax'] = 100.0 |
| 181 | - bin['enumbins'] = 20 | |
| 182 | - bin['nxpix'] = 200 | |
| 183 | - bin['nypix'] = 200 | |
| 184 | - bin['binsz'] = 0.02 | |
| 206 | + bin['enumbins'] = 10 | |
| 207 | + bin['nxpix'] = 40 | |
| 208 | + bin['nypix'] = 40 | |
| 209 | + bin['binsz'] = 0.1 | |
| 185 | 210 | bin['coordsys'] = 'CEL' |
| 186 | 211 | bin['proj'] = 'CAR' |
| 187 | 212 | bin['xref'] = 83.63 |
| 188 | 213 | bin['yref'] = 22.01 |
| 214 | + bin['publish'] = True | |
| 215 | + bin['debug'] = True | |
| 189 | 216 | bin['logfile'] = 'ctbin_py3.log' |
| 190 | 217 | bin['chatter'] = 4 |
| 191 | 218 | |
| 192 | - # Run ctbin tool | |
| 193 | - bin.logFileOpen() # Make sure we get a log file | |
| 194 | - bin.run() | |
| 219 | + # Execute ctbin tool | |
| 220 | + bin.execute() | |
| 195 | 221 | |
| 196 | 222 | # Check content of observation and cube (need multiplier=3 since |
| 197 | 223 | # three identical observations have been appended) |
| 198 | 224 | self._check_observation(bin, 5542, multiplier=3) |
| 199 | 225 | self._check_cube(bin.cube(), 5542, multiplier=3) |
| 200 | 226 | |
| 201 | - # Set-up ctbin using an observation container | |
| 202 | - bin = ctools.ctbin(obs) | |
| 203 | - bin['outcube'] = 'cntmap2.fits' | |
| 204 | - bin['ebinalg'] = 'LOG' | |
| 205 | - bin['emin'] = 0.1 | |
| 206 | - bin['emax'] = 100.0 | |
| 207 | - bin['enumbins'] = 20 | |
| 208 | - bin['nxpix'] = 200 | |
| 209 | - bin['nypix'] = 200 | |
| 210 | - bin['binsz'] = 0.02 | |
| 211 | - bin['coordsys'] = 'CEL' | |
| 212 | - bin['proj'] = 'CAR' | |
| 213 | - bin['xref'] = 83.63 | |
| 214 | - bin['yref'] = 22.01 | |
| 215 | - bin['logfile'] = 'ctbin_py4.log' | |
| 216 | - bin['chatter'] = 4 | |
| 217 | - | |
| 218 | - # Execute ctbin tool | |
| 219 | - bin.execute() | |
| 220 | - | |
| 221 | 227 | # Load counts cube and check content. |
| 222 | - evt = gammalib.GCTAEventCube('cntmap2.fits') | |
| 228 | + evt = gammalib.GCTAEventCube('ctbin_py3.fits') | |
| 223 | 229 | self._check_cube(evt, 5542, multiplier=3) |
| 224 | 230 | |
| 225 | 231 | # Return |
| ... | ... | @@ -237,23 +243,23 @@ class Test(test): |
| 237 | 243 | nevents : int |
| 238 | 244 | Expected number of events |
| 239 | 245 | multiplier : float, optional |
| 240 | - Observation multiplier | |
| 246 | + Ontime and livetime multiplier | |
| 241 | 247 | """ |
| 242 | 248 | # Test observation container |
| 243 | 249 | obs = gammalib.GCTAObservation(ctbin.obs()[0]) |
| 244 | 250 | pnt = obs.pointing() |
| 245 | 251 | self.test_value(ctbin.obs().size(), 1, |
| 246 | - 'There is one observation') | |
| 247 | - self.test_assert(obs.instrument() == 'CTA', | |
| 248 | - 'Observation is CTA observation') | |
| 252 | + 'Check that there is one observation on the observation container') | |
| 253 | + self.test_value(obs.instrument(), 'CTA', | |
| 254 | + 'Check that the one observation is a CTA observation') | |
| 249 | 255 | self.test_value(obs.ontime(), 1800.0*multiplier, 1.0e-6, |
| 250 | - 'Ontime is 1800 sec') | |
| 256 | + 'Check ontime of observation') | |
| 251 | 257 | self.test_value(obs.livetime(), 1710.0*multiplier, 1.0e-6, |
| 252 | - 'Livetime is 1710 sec') | |
| 258 | + 'Check livetime of observation') | |
| 253 | 259 | self.test_value(pnt.dir().ra_deg(), 83.63, 1.0e-6, |
| 254 | - 'Pointing Right Ascension is 83.63 deg') | |
| 260 | + 'Check pointing Right Ascension of observation') | |
| 255 | 261 | self.test_value(pnt.dir().dec_deg(), 22.01, 1.0e-6, |
| 256 | - 'Pointing Declination is 22.01 deg') | |
| 262 | + 'Check pointing Declination of observation') | |
| 257 | 263 | |
| 258 | 264 | # Test event cube |
| 259 | 265 | self._check_cube(obs.events(), nevents, multiplier=multiplier) |
| ... | ... | @@ -276,9 +282,10 @@ class Test(test): |
| 276 | 282 | Event number multiplier |
| 277 | 283 | """ |
| 278 | 284 | # Test event cube |
| 279 | - self.test_value(cube.size(), 800000, '800000 event bins') | |
| 285 | + self.test_value(cube.size(), 16000, | |
| 286 | + 'Check bin size of counts cube') | |
| 280 | 287 | self.test_value(cube.number(), nevents*multiplier, |
| 281 | - str(nevents*multiplier)+' events') | |
| 288 | + 'Check number of events in counts cube') | |
| 282 | 289 | |
| 283 | 290 | # Return |
| 284 | 291 | return | ... | ... |