Commit bac09f5e5d118e282f1ce1f1b0eedaa7224b6685
1 parent
2299f91b
Add publish methods and parameters to tools/scripts that produce FITS tables
Showing
7 changed files
with
70 additions
and
13 deletions
doc/source/users/reference_manual/ctobssim.rst
| ... | ... | @@ -106,6 +106,9 @@ General parameters |
| 106 | 106 | Standard parameters |
| 107 | 107 | ------------------- |
| 108 | 108 | |
| 109 | +``(publish = no) [boolean]`` | |
| 110 | + Specifies whether the event list should be published on VO Hub. | |
| 111 | + | |
| 109 | 112 | ``(chatter = 2) [integer]`` |
| 110 | 113 | Verbosity of the executable: |
| 111 | 114 | chatter = 0: no information will be logged | ... | ... |
pyext/ctobssim.i
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * ctobssim - Observation simulator tool * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2011-2015 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2011-2016 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -47,6 +47,7 @@ public: |
| 47 | 47 | void clear(void); |
| 48 | 48 | void run(void); |
| 49 | 49 | void save(void); |
| 50 | + void publish(const std::string& name = ""); | |
| 50 | 51 | const double& max_rate(void) const; |
| 51 | 52 | void max_rate(const double& max_rate); |
| 52 | 53 | }; | ... | ... |
src/ctobssim/ctobssim.cpp
| ... | ... | @@ -32,6 +32,8 @@ |
| 32 | 32 | #include <typeinfo> |
| 33 | 33 | #include "ctobssim.hpp" |
| 34 | 34 | #include "GTools.hpp" |
| 35 | +#include "GFits.hpp" | |
| 36 | + | |
| 35 | 37 | |
| 36 | 38 | /* __ Method name definitions ____________________________________________ */ |
| 37 | 39 | #define G_GET_PARAMETERS "ctobssim::get_parameters()" |
| ... | ... | @@ -415,6 +417,11 @@ void ctobssim::run(void) |
| 415 | 417 | // Restore energy dispersion flags of all CTA observations |
| 416 | 418 | restore_edisp(m_obs, save_edisp); |
| 417 | 419 | |
| 420 | + // Optionally publish event list(s) | |
| 421 | + if ((*this)["publish"].boolean()) { | |
| 422 | + publish(); | |
| 423 | + } | |
| 424 | + | |
| 418 | 425 | // Return |
| 419 | 426 | return; |
| 420 | 427 | } |
| ... | ... | @@ -459,6 +466,60 @@ void ctobssim::save(void) |
| 459 | 466 | } |
| 460 | 467 | |
| 461 | 468 | |
| 469 | +/***********************************************************************//** | |
| 470 | + * @brief Publish event lists | |
| 471 | + * | |
| 472 | + * @param[in] name Event list name. | |
| 473 | + ***************************************************************************/ | |
| 474 | +void ctobssim::publish(const std::string& name) | |
| 475 | +{ | |
| 476 | + // Write header into logger | |
| 477 | + log_header1(TERSE, gammalib::number("Publish event list", m_obs.size())); | |
| 478 | + | |
| 479 | + // Loop over all observation in the container | |
| 480 | + for (int i = 0; i < m_obs.size(); ++i) { | |
| 481 | + | |
| 482 | + // Get CTA observation | |
| 483 | + GCTAObservation* obs = dynamic_cast<GCTAObservation*>(m_obs[i]); | |
| 484 | + | |
| 485 | + // Handle only CTA observations | |
| 486 | + if (obs != NULL) { | |
| 487 | + | |
| 488 | + // Continue only if there is an event list | |
| 489 | + if (obs->events()->size() != 0) { | |
| 490 | + | |
| 491 | + // Set default name if user name is empty | |
| 492 | + std::string user_name(name); | |
| 493 | + if (user_name.empty()) { | |
| 494 | + user_name = CTOBSSIM_NAME; | |
| 495 | + } | |
| 496 | + | |
| 497 | + // If there are several event lists then add an index | |
| 498 | + if (m_use_xml) { | |
| 499 | + user_name += gammalib::str(i); | |
| 500 | + } | |
| 501 | + | |
| 502 | + // Write event list name into logger | |
| 503 | + log_value(NORMAL, "Event list name", user_name); | |
| 504 | + | |
| 505 | + // Write events into in-memory FITS file | |
| 506 | + GFits fits; | |
| 507 | + obs->write(fits); | |
| 508 | + | |
| 509 | + // Publish | |
| 510 | + fits.publish("EVENTS", user_name); | |
| 511 | + | |
| 512 | + } // endif: there were events | |
| 513 | + | |
| 514 | + } // endif: observation was a CTA observation | |
| 515 | + | |
| 516 | + } // endfor: looped over observations | |
| 517 | + | |
| 518 | + // Return | |
| 519 | + return; | |
| 520 | +} | |
| 521 | + | |
| 522 | + | |
| 462 | 523 | /*========================================================================== |
| 463 | 524 | = = |
| 464 | 525 | = Private methods = | ... | ... |
src/ctobssim/ctobssim.hpp
src/ctobssim/ctobssim.par
| ... | ... | @@ -2,17 +2,6 @@ |
| 2 | 2 | # # |
| 3 | 3 | # CTA Science Analysis Tools # |
| 4 | 4 | # # |
| 5 | -# ------------------------------------------------------------------------- # | |
| 6 | -# # | |
| 7 | -# File: ctobssim.par # | |
| 8 | -# Version: 1.1.0 # | |
| 9 | -# # | |
| 10 | -# Author: Juergen Knoedlseder # | |
| 11 | -# Jurgen.Knodlseder@irap.omp.eu # | |
| 12 | -# IRAP # | |
| 13 | -# # | |
| 14 | -# Purpose: Parameter file for the ctobssim application # | |
| 15 | -# # | |
| 16 | 5 | ############################################################################# |
| 17 | 6 | # |
| 18 | 7 | # General parameters |
| ... | ... | @@ -43,6 +32,7 @@ eslices, i, h, 10,1,100, "Number of energy slices" |
| 43 | 32 | # |
| 44 | 33 | # Standard parameters |
| 45 | 34 | #==================== |
| 35 | +publish, b, h, no,,, "Publish event list on VO Hub?" | |
| 46 | 36 | chatter, i, h, 2,0,4, "Chattiness of output" |
| 47 | 37 | clobber, b, h, yes,,, "Overwrite existing output files with new output files?" |
| 48 | 38 | debug, b, h, no,,, "Debugging mode activated" | ... | ... |
src/ctskymap/ctskymap.cpp
| ... | ... | @@ -294,7 +294,7 @@ void ctskymap::publish(const std::string& name) |
| 294 | 294 | // Write header into logger |
| 295 | 295 | log_header1(TERSE, "Publish sky map"); |
| 296 | 296 | |
| 297 | - // Set default name is user name is empty | |
| 297 | + // Set default name if user name is empty | |
| 298 | 298 | std::string user_name(name); |
| 299 | 299 | if (user_name.empty()) { |
| 300 | 300 | user_name = CTSKYMAP_NAME; | ... | ... |
test/test_ctobssim.py
| ... | ... | @@ -228,6 +228,7 @@ class Test(test): |
| 228 | 228 | cpy_sim['outevents'] = 'ctobssim_py3.xml' |
| 229 | 229 | cpy_sim['logfile'] = 'ctobssim_py3.log' |
| 230 | 230 | cpy_sim['chatter'] = 4 |
| 231 | + cpy_sim['publish'] = True | |
| 231 | 232 | cpy_sim.logFileOpen() # Needed to get a new log file |
| 232 | 233 | cpy_sim.execute() |
| 233 | 234 | ... | ... |