Commit e0d12cc9cc766def232f55438bea411600fbe192
1 parent
86548a09
Also enhance logging for ctskymap.
Showing
2 changed files
with
53 additions
and
29 deletions
src/ctbin/ctbin.cpp
| ... | ... | @@ -325,13 +325,26 @@ void ctbin::save(void) |
| 325 | 325 | // Get output filename |
| 326 | 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 | 349 | // Return |
| 337 | 350 | return; | ... | ... |
src/ctskymap/ctskymap.cpp
| ... | ... | @@ -247,15 +247,27 @@ void ctskymap::run(void) |
| 247 | 247 | // Loop over all observation in the container |
| 248 | 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 | 262 | // Get CTA observation |
| 251 | 263 | GCTAObservation* obs = dynamic_cast<GCTAObservation*>(m_obs[i]); |
| 252 | 264 | |
| 253 | 265 | // Skip observation if it's not CTA |
| 254 | 266 | if (obs == NULL) { |
| 255 | 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 | 272 | continue; |
| 261 | 273 | } |
| ... | ... | @@ -263,22 +275,13 @@ void ctskymap::run(void) |
| 263 | 275 | // Skip observation if we have a binned observation |
| 264 | 276 | if (obs->eventtype() == "CountsCube") { |
| 265 | 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 | 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 | 285 | // Map events into sky map |
| 283 | 286 | map_events(obs); |
| 284 | 287 | |
| ... | ... | @@ -308,8 +311,18 @@ void ctskymap::save(void) |
| 308 | 311 | // Get output filename |
| 309 | 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 | 327 | // Return |
| 315 | 328 | return; |
| ... | ... | @@ -424,23 +437,21 @@ void ctskymap::map_events(GCTAObservation* obs) |
| 424 | 437 | |
| 425 | 438 | // Log binning results |
| 426 | 439 | if (logTerse()) { |
| 427 | - log << std::endl; | |
| 428 | - log.header1("Mapping"); | |
| 429 | 440 | log << gammalib::parformat("Events in list"); |
| 430 | 441 | log << obs->events()->size() << std::endl; |
| 431 | 442 | log << gammalib::parformat("Events in map"); |
| 432 | 443 | log << num_in_map << std::endl; |
| 433 | 444 | log << gammalib::parformat("Events outside map area"); |
| 434 | 445 | log << num_outside_map << std::endl; |
| 435 | - log << gammalib::parformat("Events outside energy range"); | |
| 446 | + log << gammalib::parformat("Events outside energies"); | |
| 436 | 447 | log << num_outside_erange << std::endl; |
| 437 | 448 | } |
| 438 | 449 | |
| 439 | 450 | // Log map |
| 440 | - if (logTerse()) { | |
| 441 | - log << std::endl; | |
| 442 | - log.header1("Sky map"); | |
| 451 | + if (logVerbose()) { | |
| 452 | + log.indent(1); | |
| 443 | 453 | log << m_skymap << std::endl; |
| 454 | + log.indent(0); | |
| 444 | 455 | } |
| 445 | 456 | |
| 446 | 457 | } // endif: observation was valid | ... | ... |