Commit bbd08db3a6caafdd031dce7744ded754946cb97c
1 parent
0847394c
Add ctool::get_obs_header() method.
Showing
3 changed files
with
41 additions
and
5 deletions
pyext/ctool.i
| ... | ... | @@ -99,6 +99,7 @@ public: |
| 99 | 99 | %rename(_set_obs_bounds) set_obs_bounds(GObservations& obs); |
| 100 | 100 | %rename(_get_mean_pointing) get_mean_pointing(const GObservations& obs); |
| 101 | 101 | %rename(_get_current_rss) get_current_rss(); |
| 102 | + %rename(_get_obs_header) get_obs_header(); | |
| 102 | 103 | |
| 103 | 104 | // Protected methods |
| 104 | 105 | const bool& read_ahead(void) const; |
| ... | ... | @@ -122,6 +123,7 @@ public: |
| 122 | 123 | void set_obs_bounds(GObservations& obs); |
| 123 | 124 | GSkyDir get_mean_pointing(const GObservations& obs); |
| 124 | 125 | size_t get_current_rss(void); |
| 126 | + std::string get_obs_header(const GObservation* obs); | |
| 125 | 127 | }; |
| 126 | 128 | |
| 127 | 129 | ... | ... |
src/support/ctool.cpp
| ... | ... | @@ -1108,6 +1108,39 @@ size_t ctool::get_current_rss(void) |
| 1108 | 1108 | |
| 1109 | 1109 | |
| 1110 | 1110 | /***********************************************************************//** |
| 1111 | + * @brief Return observation header string | |
| 1112 | + * | |
| 1113 | + * @param[in] obs Pointer to observation. | |
| 1114 | + * @return String containing observation information. | |
| 1115 | + * | |
| 1116 | + * Returns a string that contains observation information, including the | |
| 1117 | + * instrument name, the observation name, and the observation ID. The format | |
| 1118 | + * of the string is | |
| 1119 | + * | |
| 1120 | + * XXX observation "name" (id=YYYYY) | |
| 1121 | + * | |
| 1122 | + ***************************************************************************/ | |
| 1123 | +std::string ctool::get_obs_header(const GObservation* obs) | |
| 1124 | +{ | |
| 1125 | + // Initialise header string | |
| 1126 | + std::string header = obs->instrument() + " observation"; | |
| 1127 | + | |
| 1128 | + // If observation name is not empty then add name | |
| 1129 | + if (!obs->name().empty()) { | |
| 1130 | + header += " \"" + obs->name() + "\""; | |
| 1131 | + } | |
| 1132 | + | |
| 1133 | + // If observation ID is not empty then add ID | |
| 1134 | + if (!obs->id().empty()) { | |
| 1135 | + header += " (id=" + obs->id() +")"; | |
| 1136 | + } | |
| 1137 | + | |
| 1138 | + // Return header | |
| 1139 | + return header; | |
| 1140 | +} | |
| 1141 | + | |
| 1142 | + | |
| 1143 | +/***********************************************************************//** | |
| 1111 | 1144 | * @brief Dumps help text in the console |
| 1112 | 1145 | ***************************************************************************/ |
| 1113 | 1146 | void ctool::provide_help(void) const | ... | ... |
src/support/ctool.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * ctool - ctool base class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2014-2015 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2014-2016 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -90,17 +90,18 @@ protected: |
| 90 | 90 | void set_obs_bounds(GObservations& obs); |
| 91 | 91 | GSkyDir get_mean_pointing(const GObservations& obs); |
| 92 | 92 | size_t get_current_rss(void); |
| 93 | + std::string get_obs_header(const GObservation* obs); | |
| 93 | 94 | |
| 94 | 95 | // Protected members |
| 95 | - bool m_read_ahead; //!< Read ahead parameters | |
| 96 | + bool m_read_ahead; //!< Read ahead output parameters | |
| 96 | 97 | |
| 97 | 98 | protected: |
| 98 | 99 | // Protected methods |
| 99 | - void provide_help(void) const; | |
| 100 | + void provide_help(void) const; | |
| 100 | 101 | |
| 101 | 102 | // Protected members |
| 102 | - bool m_use_xml; //!< Use XML file instead of FITS file for observations | |
| 103 | - GTimeReference m_cta_ref; //!< CTA time reference | |
| 103 | + bool m_use_xml; //!< Use XML file instead of FITS file for observations | |
| 104 | + GTimeReference m_cta_ref; //!< CTA time reference | |
| 104 | 105 | }; |
| 105 | 106 | |
| 106 | 107 | ... | ... |