Commit 583fdb7308d38a8630b64ef2f81ed98616dcfbcb

Authored by jean perrot
1 parent d1ef7990

publish global in ctool

cscripts/csviscube.py
... ... @@ -494,20 +494,6 @@ class csviscube(ctools.cscript):
494 494 name : str, optional
495 495 Name of visibility cube
496 496 """
497   - # Write header
498   - # self._log_header1(gammalib.TERSE, 'Publish visibility cube')
499   -
500   - # Set default name is user name is empty
501   - # if not name:
502   - # user_name = self._name
503   - # else:
504   - # user_name = name
505   -
506   - # Log cube name
507   - # self._log_value(gammalib.TERSE, 'Visibility cube name', user_name)
508   -
509   - # Publish cube
510   - # self._cube.publish(user_name)
511 497  
512 498 self._publish_map(name, "", "Publish visibility cube", self._cube)
513 499  
... ...
pyext/ctool.i
... ... @@ -112,11 +112,13 @@ public:
112 112 %rename(_warn_too_few_energies) warn_too_few_energies;
113 113 %rename(_warn_xml_suffix) warn_xml_suffix;
114 114 %rename(_publish_map) publish_map;
  115 + %rename(_publish_events_list) publish_events_list;
115 116  
116 117 // Protected methods
117 118 const bool& read_ahead(void) const;
118 119 const GTimeReference& time_reference(void) const;
119 120 void publish_map(const std::string& name, std::string defautName, std::string typePub, const GSkyMap& pub);
  121 + void publish_events_list(const std::string& name, std::string defautName);
120 122  
121 123 // Protected high-level setup methods
122 124 void setup_observations(GObservations& obs, const bool& response = true,
... ...
src/support/ctobservation.cpp
... ... @@ -452,7 +452,7 @@ void ctobservation::save_events_xml(void)
452 452 *
453 453 * @param[in] name Event list name, default name
454 454 ***************************************************************************/
455   -void ctobservation::publish_events_list(const std::string& name, std::string DefaultName)
  455 +/*void ctobservation::publish_events_list(const std::string& name, std::string DefaultName)
456 456 {
457 457 // Write header into logger
458 458 log_header1(TERSE, gammalib::number("Publish event list", m_obs.size()));
... ... @@ -498,4 +498,4 @@ void ctobservation::publish_events_list(const std::string& name, std::string Def
498 498  
499 499 // Return
500 500 return;
501   -}
  501 +}*/
... ...
src/support/ctobservation.hpp
... ... @@ -80,7 +80,7 @@ protected:
80 80 void free_members(void);
81 81 void save_events_fits(void);
82 82 void save_events_xml(void);
83   - void publish_events_list(const std::string& name, std::string defautName);
  83 + // void publish_events_list(const std::string& name, std::string defautName);
84 84  
85 85 // Protected members
86 86  
... ...
src/support/ctool.cpp
... ... @@ -2079,3 +2079,56 @@ void ctool::publish_map(const std::string& name, std::string defautName, std::st
2079 2079 // Return
2080 2080 return;
2081 2081 }
  2082 +
  2083 +/***********************************************************************//**
  2084 + * @brief Publish event lists
  2085 + *
  2086 + * @param[in] name Event list name, default name
  2087 + ***************************************************************************/
  2088 +void ctool::publish_events_list(const std::string& name, std::string DefaultName)
  2089 +{
  2090 + // Write header into logger
  2091 + log_header1(TERSE, gammalib::number("Publish event list", m_obs.size()));
  2092 +
  2093 + // Loop over all observation in the container
  2094 + for (int i = 0; i < m_obs.size(); ++i) {
  2095 +
  2096 + // Get CTA observation
  2097 + GCTAObservation* obs = dynamic_cast<GCTAObservation*>(m_obs[i]);
  2098 +
  2099 + // Handle only CTA observations
  2100 + if (obs != NULL) {
  2101 +
  2102 + // Continue only if there is an event list
  2103 + if (obs->events()->size() != 0) {
  2104 +
  2105 + // Set default name if user name is empty
  2106 + std::string user_name(name);
  2107 + if (user_name.empty()) {
  2108 + user_name = DefaultName;
  2109 + }
  2110 +
  2111 + // If there are several event lists then add an index
  2112 + if (m_use_xml) {
  2113 + user_name += gammalib::str(i);
  2114 + }
  2115 +
  2116 + // Write event list name into logger
  2117 + log_value(NORMAL, "Event list name", user_name);
  2118 +
  2119 + // Write events into in-memory FITS file
  2120 + GFits fits;
  2121 + obs->write(fits);
  2122 +
  2123 + // Publish
  2124 + fits.publish(gammalib::extname_cta_events, user_name);
  2125 +
  2126 + } // endif: there were events
  2127 +
  2128 + } // endif: observation was a CTA observation
  2129 +
  2130 + } // endfor: looped over observations
  2131 +
  2132 + // Return
  2133 + return;
  2134 +}
... ...
src/support/ctool.hpp
... ... @@ -80,6 +80,7 @@ protected:
80 80 const bool& read_ahead(void) const;
81 81 const GTimeReference& time_reference(void) const;
82 82 void publish_map(const std::string& name, std::string defautName, std::string typePub, const GSkyMap& pub);
  83 + void publish_events_list(const std::string& name, std::string defautName);
83 84  
84 85 // Protected high-level setup methods
85 86 void setup_observations(GObservations& obs, const bool& response = true,
... ...