Commit e0d12cc9cc766def232f55438bea411600fbe192

Authored by Jürgen Knödlseder
1 parent 86548a09

Also enhance logging for ctskymap.

src/ctbin/ctbin.cpp
@@ -325,13 +325,26 @@ void ctbin::save(void) @@ -325,13 +325,26 @@ void ctbin::save(void)
325 // Get output filename 325 // Get output filename
326 m_outcube = (*this)["outcube"].filename(); 326 m_outcube = (*this)["outcube"].filename();
327 327
328 - // Get CTA observation from observation container  
329 - GCTAObservation* obs = dynamic_cast<GCTAObservation*>(m_obs[0]); 328 + // Save only if filename is non-empty
  329 + if (m_outcube.length() > 0) {
330 330
331 - // Save only if observation is valid  
332 - if (obs != NULL) {  
333 - obs->save(m_outcube, clobber());  
334 - } 331 + // Get CTA observation from observation container
  332 + GCTAObservation* obs = dynamic_cast<GCTAObservation*>(m_obs[0]);
  333 +
  334 + // Save only if observation is valid
  335 + if (obs != NULL) {
  336 +
  337 + // Dump filename
  338 + if (logTerse()) {
  339 + log << "Save \""+m_outcube+"\"" << std::endl;
  340 + }
  341 +
  342 + // Save cube
  343 + obs->save(m_outcube, clobber());
  344 +
  345 + } // endif: observation was valid
  346 +
  347 + } // endif: outcube file was valid
335 348
336 // Return 349 // Return
337 return; 350 return;
src/ctskymap/ctskymap.cpp
@@ -247,15 +247,27 @@ void ctskymap::run(void) @@ -247,15 +247,27 @@ void ctskymap::run(void)
247 // Loop over all observation in the container 247 // Loop over all observation in the container
248 for (int i = 0; i < m_obs.size(); ++i) { 248 for (int i = 0; i < m_obs.size(); ++i) {
249 249
  250 + // Write header for observation
  251 + if (logTerse()) {
  252 + std::string header = m_obs[i]->instrument() + " observation";
  253 + if (m_obs[i]->name().length() > 1) {
  254 + header += " \"" + m_obs[i]->name() + "\"";
  255 + }
  256 + if (m_obs[i]->id().length() > 1) {
  257 + header += " (id=" + m_obs[i]->id() +")";
  258 + }
  259 + log.header3(header);
  260 + }
  261 +
250 // Get CTA observation 262 // Get CTA observation
251 GCTAObservation* obs = dynamic_cast<GCTAObservation*>(m_obs[i]); 263 GCTAObservation* obs = dynamic_cast<GCTAObservation*>(m_obs[i]);
252 264
253 // Skip observation if it's not CTA 265 // Skip observation if it's not CTA
254 if (obs == NULL) { 266 if (obs == NULL) {
255 if (logTerse()) { 267 if (logTerse()) {
256 - log << "Warning: Skipping "+m_obs[i]->instrument();  
257 - log << " observation \"";  
258 - log << m_obs[i]->name() << "\"" << std::endl; 268 + log << " Skipping ";
  269 + log << m_obs[i]->instrument();
  270 + log << " observation" << std::endl;
259 } 271 }
260 continue; 272 continue;
261 } 273 }
@@ -263,22 +275,13 @@ void ctskymap::run(void) @@ -263,22 +275,13 @@ void ctskymap::run(void)
263 // Skip observation if we have a binned observation 275 // Skip observation if we have a binned observation
264 if (obs->eventtype() == "CountsCube") { 276 if (obs->eventtype() == "CountsCube") {
265 if (logTerse()) { 277 if (logTerse()) {
266 - log << "Warning: Skipping binned observation \"";  
267 - log << obs->name()+"\"" << std::endl; 278 + log << " Skipping binned ";
  279 + log << obs->instrument();
  280 + log << " observation" << std::endl;
268 } 281 }
269 continue; 282 continue;
270 } 283 }
271 284
272 - // Write header for current observation  
273 - if (logTerse()) {  
274 - if (obs->name().length() > 1) {  
275 - log.header3("Observation "+obs->name());  
276 - }  
277 - else {  
278 - log.header3("Observation");  
279 - }  
280 - }  
281 -  
282 // Map events into sky map 285 // Map events into sky map
283 map_events(obs); 286 map_events(obs);
284 287
@@ -308,8 +311,18 @@ void ctskymap::save(void) @@ -308,8 +311,18 @@ void ctskymap::save(void)
308 // Get output filename 311 // Get output filename
309 m_outmap = (*this)["outmap"].filename(); 312 m_outmap = (*this)["outmap"].filename();
310 313
311 - // Save sky map  
312 - m_skymap.save(m_outmap, clobber()); 314 + // Save only if filename is non-empty
  315 + if (m_outmap.length() > 0) {
  316 +
  317 + // Dump filename
  318 + if (logTerse()) {
  319 + log << "Save \""+m_outmap+"\"" << std::endl;
  320 + }
  321 +
  322 + // Save sky map
  323 + m_skymap.save(m_outmap, clobber());
  324 +
  325 + }
313 326
314 // Return 327 // Return
315 return; 328 return;
@@ -424,23 +437,21 @@ void ctskymap::map_events(GCTAObservation* obs) @@ -424,23 +437,21 @@ void ctskymap::map_events(GCTAObservation* obs)
424 437
425 // Log binning results 438 // Log binning results
426 if (logTerse()) { 439 if (logTerse()) {
427 - log << std::endl;  
428 - log.header1("Mapping");  
429 log << gammalib::parformat("Events in list"); 440 log << gammalib::parformat("Events in list");
430 log << obs->events()->size() << std::endl; 441 log << obs->events()->size() << std::endl;
431 log << gammalib::parformat("Events in map"); 442 log << gammalib::parformat("Events in map");
432 log << num_in_map << std::endl; 443 log << num_in_map << std::endl;
433 log << gammalib::parformat("Events outside map area"); 444 log << gammalib::parformat("Events outside map area");
434 log << num_outside_map << std::endl; 445 log << num_outside_map << std::endl;
435 - log << gammalib::parformat("Events outside energy range"); 446 + log << gammalib::parformat("Events outside energies");
436 log << num_outside_erange << std::endl; 447 log << num_outside_erange << std::endl;
437 } 448 }
438 449
439 // Log map 450 // Log map
440 - if (logTerse()) {  
441 - log << std::endl;  
442 - log.header1("Sky map"); 451 + if (logVerbose()) {
  452 + log.indent(1);
443 log << m_skymap << std::endl; 453 log << m_skymap << std::endl;
  454 + log.indent(0);
444 } 455 }
445 456
446 } // endif: observation was valid 457 } // endif: observation was valid