Commit 21710d59df351e515f0a45eb5f40e1aaf8fdee81
1 parent
2de25f8e
Enhance logging experience.
Showing
2 changed files
with
52 additions
and
43 deletions
src/ctmodel/ctmodel.cpp
| @@ -254,57 +254,56 @@ void ctmodel::run(void) | @@ -254,57 +254,56 @@ void ctmodel::run(void) | ||
| 254 | // Loop over all observations in the container | 254 | // Loop over all observations in the container |
| 255 | for (int i = 0; i < m_obs.size(); ++i) { | 255 | for (int i = 0; i < m_obs.size(); ++i) { |
| 256 | 256 | ||
| 257 | - // Get CTA observation | ||
| 258 | - GCTAObservation* obs = dynamic_cast<GCTAObservation*>(m_obs[i]); | ||
| 259 | - | ||
| 260 | - // Continue only if observation is a CTA observation | ||
| 261 | - if (obs != NULL) { | ||
| 262 | - | ||
| 263 | - // Write header for observation | ||
| 264 | - if (logTerse()) { | ||
| 265 | - if (obs->name().length() > 1) { | ||
| 266 | - log.header3("Observation "+obs->name()); | ||
| 267 | - } | ||
| 268 | - else { | ||
| 269 | - log.header3("Observation"); | ||
| 270 | - } | 257 | + // Write header for observation |
| 258 | + if (logTerse()) { | ||
| 259 | + std::string header = m_obs[i]->instrument() + " observation"; | ||
| 260 | + if (m_obs[i]->name().length() > 1) { | ||
| 261 | + header += " \"" + m_obs[i]->name() + "\""; | ||
| 271 | } | 262 | } |
| 272 | - | ||
| 273 | - // Fill cube and leave loop if we are binned mode (meaning we only have | ||
| 274 | - // one binned observation) | ||
| 275 | - if (m_binned && m_obs.size() == 1) { | ||
| 276 | - fill_cube(obs); | ||
| 277 | - break; | 263 | + if (m_obs[i]->id().length() > 1) { |
| 264 | + header += " (id=" + m_obs[i]->id() +")"; | ||
| 278 | } | 265 | } |
| 266 | + log.header3(header); | ||
| 267 | + } | ||
| 279 | 268 | ||
| 280 | - // Skip observation if we don't have an unbinned observation | ||
| 281 | - if (obs->eventtype() != "EventList") { | 269 | + // Get CTA observation |
| 270 | + GCTAObservation* obs = dynamic_cast<GCTAObservation*>(m_obs[i]); | ||
| 282 | 271 | ||
| 283 | - // Log that we skip the this observation | ||
| 284 | - if (logTerse()) { | ||
| 285 | - log << "Warning: Skipping binned observation \""+obs->name()+"\""; | ||
| 286 | - log << std::endl; | ||
| 287 | - } | ||
| 288 | - continue; | 272 | + // Skip observation if it's not CTA |
| 273 | + if (obs == NULL) { | ||
| 274 | + if (logTerse()) { | ||
| 275 | + log << " Skipping "; | ||
| 276 | + log << m_obs[i]->instrument(); | ||
| 277 | + log << " observation" << std::endl; | ||
| 289 | } | 278 | } |
| 279 | + continue; | ||
| 280 | + } | ||
| 290 | 281 | ||
| 291 | - | ||
| 292 | - // Fill the cube | 282 | + // Fill cube and leave loop if we are binned mode (meaning we |
| 283 | + // only have one binned observation) | ||
| 284 | + if (m_binned && m_obs.size() == 1) { | ||
| 293 | fill_cube(obs); | 285 | fill_cube(obs); |
| 286 | + break; | ||
| 287 | + } | ||
| 294 | 288 | ||
| 295 | - // Leave loop if we are binned mode (meaning we only have | ||
| 296 | - // one binned observation | ||
| 297 | - if (m_binned && m_obs.size() == 1) { | ||
| 298 | - break; | 289 | + // Skip observation if we have a binned observation |
| 290 | + if (obs->eventtype() == "CountsCube") { | ||
| 291 | + if (logTerse()) { | ||
| 292 | + log << " Skipping binned "; | ||
| 293 | + log << obs->instrument(); | ||
| 294 | + log << " observation" << std::endl; | ||
| 299 | } | 295 | } |
| 296 | + continue; | ||
| 297 | + } | ||
| 300 | 298 | ||
| 301 | - // Dispose events to free memory if event file exists on disk | ||
| 302 | - if (obs->eventfile().length() > 0 && | ||
| 303 | - gammalib::file_exists(obs->eventfile())) { | ||
| 304 | - obs->dispose_events(); | ||
| 305 | - } | 299 | + // Fill the cube |
| 300 | + fill_cube(obs); | ||
| 306 | 301 | ||
| 307 | - } // endif: CTA observation found | 302 | + // Dispose events to free memory if event file exists on disk |
| 303 | + if (obs->eventfile().length() > 0 && | ||
| 304 | + gammalib::file_exists(obs->eventfile())) { | ||
| 305 | + obs->dispose_events(); | ||
| 306 | + } | ||
| 308 | 307 | ||
| 309 | } // endfor: looped over observations | 308 | } // endfor: looped over observations |
| 310 | 309 | ||
| @@ -345,8 +344,18 @@ void ctmodel::save(void) | @@ -345,8 +344,18 @@ void ctmodel::save(void) | ||
| 345 | // Make sure we have the FITS filename | 344 | // Make sure we have the FITS filename |
| 346 | m_outcube = (*this)["outcube"].filename(); | 345 | m_outcube = (*this)["outcube"].filename(); |
| 347 | 346 | ||
| 348 | - // Save model cube into FITS file | ||
| 349 | - m_cube.save(m_outcube, clobber()); | 347 | + // Save only if filename is non-empty |
| 348 | + if (m_outcube.length() > 0) { | ||
| 349 | + | ||
| 350 | + // Dump filename | ||
| 351 | + if (logTerse()) { | ||
| 352 | + log << "Save \""+m_outcube+"\"" << std::endl; | ||
| 353 | + } | ||
| 354 | + | ||
| 355 | + // Save model cube into FITS file | ||
| 356 | + m_cube.save(m_outcube, clobber()); | ||
| 357 | + | ||
| 358 | + } | ||
| 350 | 359 | ||
| 351 | // Return | 360 | // Return |
| 352 | return; | 361 | return; |
src/ctmodel/ctmodel.hpp
| @@ -92,7 +92,7 @@ protected: | @@ -92,7 +92,7 @@ protected: | ||
| 92 | GGti m_gti; //!< Model cube GTIs | 92 | GGti m_gti; //!< Model cube GTIs |
| 93 | bool m_has_cube; //!< Signal if cube has been set or loaded | 93 | bool m_has_cube; //!< Signal if cube has been set or loaded |
| 94 | bool m_append_cube; //!< Signal that cube should be appended | 94 | bool m_append_cube; //!< Signal that cube should be appended |
| 95 | - bool m_binned; //!< Signals that we are in binned mode | 95 | + bool m_binned; //!< Signals that we are in binned mode |
| 96 | }; | 96 | }; |
| 97 | 97 | ||
| 98 | 98 |