Commit 155cf0c2bbb3f37e3152bce020289dd2d864d2f7
Committed by
Jürgen Knödlseder
1 parent
f418ba9a
creation of the new time variability tool
Showing
8 changed files
with
797 additions
and
0 deletions
doc/source/users/reference_manual/ctfindvar.rst
0 → 100644
| 1 | +.. _ctfindvar: | |
| 2 | + | |
| 3 | +ctfindvar | |
| 4 | +============================== | |
| 5 | + | |
| 6 | +ToDo: Describe in a one liner what the tool is doing. | |
| 7 | + | |
| 8 | + | |
| 9 | +Synopsis | |
| 10 | +-------- | |
| 11 | + | |
| 12 | +ToDo: Desribe in detail what the tool is doing, what it takes on input and | |
| 13 | +what it produces on output. Please do not write more than 80 characters per | |
| 14 | +line since this file is also used to produce a help text for the terminal. | |
| 15 | + | |
| 16 | + | |
| 17 | +General parameters | |
| 18 | +------------------ | |
| 19 | + | |
| 20 | +ToDo: Add here your parameters. | |
| 21 | + | |
| 22 | + | |
| 23 | +Standard parameters | |
| 24 | +------------------- | |
| 25 | + | |
| 26 | +``(chatter = 2) [integer]`` | |
| 27 | + Verbosity of the executable: | |
| 28 | + ``chatter = 0``: no information will be logged | |
| 29 | + | |
| 30 | + ``chatter = 1``: only errors will be logged | |
| 31 | + | |
| 32 | + ``chatter = 2``: errors and actions will be logged | |
| 33 | + | |
| 34 | + ``chatter = 3``: report about the task execution | |
| 35 | + | |
| 36 | + ``chatter = 4``: detailed report about the task execution | |
| 37 | + | |
| 38 | +``(clobber = yes) [boolean]`` | |
| 39 | + Specifies whether an existing output file should be overwritten. | |
| 40 | + | |
| 41 | +``(debug = no) [boolean]`` | |
| 42 | + Enables debug mode. In debug mode the executable will dump any log file output to the console. | |
| 43 | + | |
| 44 | +``(mode = ql) [string]`` | |
| 45 | + Mode of automatic parameters (default is ``ql``, i.e. "query and learn"). | |
| 46 | + | |
| 47 | +``(logfile = ctfindvar.log) [string]`` | |
| 48 | + Name of log file. | |
| 49 | + | |
| 50 | + | |
| 51 | +Related tools or scripts | |
| 52 | +------------------------ | |
| 53 | + | |
| 54 | +None | ... | ... |
pyext/ctfindvar.i
0 → 100644
| 1 | +/*************************************************************************** | |
| 2 | + * ctfindvar - search time variability tool * | |
| 3 | + * ----------------------------------------------------------------------- * | |
| 4 | + * copyright (C) 2018 by Simon Bonnefoy * | |
| 5 | + * ----------------------------------------------------------------------- * | |
| 6 | + * * | |
| 7 | + * This program is free software: you can redistribute it and/or modify * | |
| 8 | + * it under the terms of the GNU General Public License as published by * | |
| 9 | + * the Free Software Foundation, either version 3 of the License, or * | |
| 10 | + * (at your option) any later version. * | |
| 11 | + * * | |
| 12 | + * This program is distributed in the hope that it will be useful, * | |
| 13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of * | |
| 14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | |
| 15 | + * GNU General Public License for more details. * | |
| 16 | + * * | |
| 17 | + * You should have received a copy of the GNU General Public License * | |
| 18 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. * | |
| 19 | + * * | |
| 20 | + ***************************************************************************/ | |
| 21 | +/** | |
| 22 | + * @file ctfindvar.i | |
| 23 | + * @brief search time variability tool definition | |
| 24 | + * @author Simon Bonnefoy | |
| 25 | + */ | |
| 26 | +%{ | |
| 27 | +/* Put headers and other declarations here that are needed for compilation */ | |
| 28 | +#include "ctfindvar.hpp" | |
| 29 | +%} | |
| 30 | + | |
| 31 | + | |
| 32 | +/***********************************************************************//** | |
| 33 | + * @class ctfindvar | |
| 34 | + * | |
| 35 | + * @brief search time variability tool | |
| 36 | + ***************************************************************************/ | |
| 37 | +class ctfindvar : public ctobservation { | |
| 38 | +public: | |
| 39 | + // Constructors and destructors | |
| 40 | + ctfindvar(void); | |
| 41 | + explicit ctfindvar(const GObservations& obs); | |
| 42 | + ctfindvar(int argc, char *argv[]); | |
| 43 | + ctfindvar(const ctfindvar& app); | |
| 44 | + virtual ~ctfindvar(void); | |
| 45 | + | |
| 46 | + // Methods | |
| 47 | + void clear(void); | |
| 48 | + void run(void); | |
| 49 | + void save(void); | |
| 50 | +}; | |
| 51 | + | |
| 52 | + | |
| 53 | +/***********************************************************************//** | |
| 54 | + * @brief search time variability tool Python extension | |
| 55 | + ***************************************************************************/ | |
| 56 | +%extend ctfindvar { | |
| 57 | + ctfindvar copy() { | |
| 58 | + return (*self); | |
| 59 | + } | |
| 60 | +} | ... | ... |
src/ctfindvar/Makefile.am
0 → 100644
| 1 | +############################################################################# | |
| 2 | +# Makefile.am for ctfindvar tool # | |
| 3 | +# ------------------------------------------------------------------------- # | |
| 4 | +# Copyright (C) 2018 by Simon Bonnefoy # | |
| 5 | +# ------------------------------------------------------------------------- # | |
| 6 | +# # | |
| 7 | +# This program is free software: you can redistribute it and/or modify # | |
| 8 | +# it under the terms of the GNU General Public License as published by # | |
| 9 | +# the Free Software Foundation, either version 3 of the License, or # | |
| 10 | +# (at your option) any later version. # | |
| 11 | +# # | |
| 12 | +# This program is distributed in the hope that it will be useful, # | |
| 13 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of # | |
| 14 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # | |
| 15 | +# GNU General Public License for more details. # | |
| 16 | +# # | |
| 17 | +# You should have received a copy of the GNU General Public License # | |
| 18 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. # | |
| 19 | +# # | |
| 20 | +############################################################################# | |
| 21 | + | |
| 22 | +# Set include directories | |
| 23 | +INCLUDES = -I$(top_srcdir)/src/support | |
| 24 | + | |
| 25 | +# Program name | |
| 26 | +bin_PROGRAMS = ctfindvar | |
| 27 | + | |
| 28 | +# Sources | |
| 29 | +sources = ctfindvar.cpp ctfindvar.hpp | |
| 30 | + | |
| 31 | +# Headers | |
| 32 | +pkginclude_HEADERS = ctfindvar.hpp | |
| 33 | + | |
| 34 | +# Libtool library | |
| 35 | +noinst_LTLIBRARIES = libctfindvar.la | |
| 36 | +libctfindvar_la_SOURCES = $(sources) | |
| 37 | +libctfindvar_la_LDFLAGS = @OPENMP_LIB_LDFLAGS@ | |
| 38 | + | |
| 39 | +# Program definition | |
| 40 | +ctfindvar_SOURCES = main.cpp | |
| 41 | +ctfindvar_LDFLAGS = $(LIB_LINK_OPTION) @LDFLAGS@ | |
| 42 | +ctfindvar_CPPFLAGS = @CPPFLAGS@ | |
| 43 | +ctfindvar_LDADD = libctfindvar.la $(top_builddir)/src/support/libsupport.la | |
| 44 | + | |
| 45 | +# Parameter files | |
| 46 | +pfilesdir = $(prefix)/syspfiles | |
| 47 | +pfiles_DATA = $(srcdir)/ctfindvar.par | |
| 48 | + | |
| 49 | +# Extra files to be distributed in the tar file | |
| 50 | +EXTRA_DIST = $(pfiles_DATA) | ... | ... |
src/ctfindvar/ctfindvar.cpp
0 → 100644
| 1 | +/*************************************************************************** | |
| 2 | + * ctfindvar - search time variability tool * | |
| 3 | + * ----------------------------------------------------------------------- * | |
| 4 | + * copyright (C) 2018 by Simon Bonnefoy * | |
| 5 | + * ----------------------------------------------------------------------- * | |
| 6 | + * * | |
| 7 | + * This program is free software: you can redistribute it and/or modify * | |
| 8 | + * it under the terms of the GNU General Public License as published by * | |
| 9 | + * the Free Software Foundation, either version 3 of the License, or * | |
| 10 | + * (at your option) any later version. * | |
| 11 | + * * | |
| 12 | + * This program is distributed in the hope that it will be useful, * | |
| 13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of * | |
| 14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | |
| 15 | + * GNU General Public License for more details. * | |
| 16 | + * * | |
| 17 | + * You should have received a copy of the GNU General Public License * | |
| 18 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. * | |
| 19 | + * * | |
| 20 | + ***************************************************************************/ | |
| 21 | +/** | |
| 22 | + * @file ctfindvar.cpp | |
| 23 | + * @brief search time variability tool implementation | |
| 24 | + * @author Simon Bonnefoy | |
| 25 | + */ | |
| 26 | + | |
| 27 | +/* __ Includes ___________________________________________________________ */ | |
| 28 | +#ifdef HAVE_CONFIG_H | |
| 29 | +#include <config.h> | |
| 30 | +#endif | |
| 31 | +#include "ctfindvar.hpp" | |
| 32 | +#include "GammaLib.hpp" | |
| 33 | +#include "GCTALib.hpp" | |
| 34 | + | |
| 35 | +/* __ OpenMP section _____________________________________________________ */ | |
| 36 | +//#ifdef _OPENMP | |
| 37 | +//#include <omp.h> | |
| 38 | +//#endif | |
| 39 | + | |
| 40 | +/* __ Method name definitions ____________________________________________ */ | |
| 41 | + | |
| 42 | +/* __ Debug definitions __________________________________________________ */ | |
| 43 | + | |
| 44 | +/* __ Coding definitions _________________________________________________ */ | |
| 45 | + | |
| 46 | +/* __ Constants __________________________________________________________ */ | |
| 47 | + | |
| 48 | + | |
| 49 | +/*========================================================================== | |
| 50 | + = = | |
| 51 | + = Constructors/destructors = | |
| 52 | + = = | |
| 53 | + ==========================================================================*/ | |
| 54 | + | |
| 55 | +/***********************************************************************//** | |
| 56 | + * @brief Void constructor | |
| 57 | + * | |
| 58 | + * Constructs empty search time variability tool. | |
| 59 | + ***************************************************************************/ | |
| 60 | +ctfindvar::ctfindvar(void) : ctobservation(CTFINDVAR_NAME, VERSION) | |
| 61 | +{ | |
| 62 | + // Initialise members | |
| 63 | + init_members(); | |
| 64 | + | |
| 65 | + // Return | |
| 66 | + return; | |
| 67 | +} | |
| 68 | + | |
| 69 | + | |
| 70 | +/***********************************************************************//** | |
| 71 | + * @brief Observations constructor | |
| 72 | + * | |
| 73 | + * param[in] obs Observation container. | |
| 74 | + * | |
| 75 | + * Constructs search time variability tool from an observation container. | |
| 76 | + ***************************************************************************/ | |
| 77 | +ctfindvar::ctfindvar(const GObservations& obs) : ctobservation(CTFINDVAR_NAME, VERSION, obs) | |
| 78 | +{ | |
| 79 | + // Initialise members | |
| 80 | + init_members(); | |
| 81 | + | |
| 82 | + // Return | |
| 83 | + return; | |
| 84 | +} | |
| 85 | + | |
| 86 | + | |
| 87 | +/***********************************************************************//** | |
| 88 | + * @brief Command line constructor | |
| 89 | + * | |
| 90 | + * @param[in] argc Number of arguments in command line. | |
| 91 | + * @param[in] argv Array of command line arguments. | |
| 92 | + * | |
| 93 | + * Constructs search time variability tool using command line arguments for user | |
| 94 | + * parameter setting. | |
| 95 | + ***************************************************************************/ | |
| 96 | +ctfindvar::ctfindvar(int argc, char *argv[]) : ctobservation(CTFINDVAR_NAME, VERSION, argc, argv) | |
| 97 | +{ | |
| 98 | + // Initialise members | |
| 99 | + init_members(); | |
| 100 | + | |
| 101 | + // Return | |
| 102 | + return; | |
| 103 | +} | |
| 104 | + | |
| 105 | + | |
| 106 | +/***********************************************************************//** | |
| 107 | + * @brief Copy constructor | |
| 108 | + * | |
| 109 | + * @param[in] app search time variability tool. | |
| 110 | + * | |
| 111 | + * Constructs search time variability tool from another search time variability tool. | |
| 112 | + ***************************************************************************/ | |
| 113 | +ctfindvar::ctfindvar(const ctfindvar& app) : ctobservation(app) | |
| 114 | +{ | |
| 115 | + // Initialise members | |
| 116 | + init_members(); | |
| 117 | + | |
| 118 | + // Copy members | |
| 119 | + copy_members(app); | |
| 120 | + | |
| 121 | + // Return | |
| 122 | + return; | |
| 123 | +} | |
| 124 | + | |
| 125 | + | |
| 126 | +/***********************************************************************//** | |
| 127 | + * @brief Destructor | |
| 128 | + * | |
| 129 | + * Destructs search time variability tool. | |
| 130 | + ***************************************************************************/ | |
| 131 | +ctfindvar::~ctfindvar(void) | |
| 132 | +{ | |
| 133 | + // Free members | |
| 134 | + free_members(); | |
| 135 | + | |
| 136 | + // Return | |
| 137 | + return; | |
| 138 | +} | |
| 139 | + | |
| 140 | + | |
| 141 | +/*========================================================================== | |
| 142 | + = = | |
| 143 | + = Operators = | |
| 144 | + = = | |
| 145 | + ==========================================================================*/ | |
| 146 | + | |
| 147 | +/***********************************************************************//** | |
| 148 | + * @brief Assignment operator | |
| 149 | + * | |
| 150 | + * @param[in] app search time variability tool. | |
| 151 | + * @return search time variability tool. | |
| 152 | + * | |
| 153 | + * Assigns search time variability tool. | |
| 154 | + ***************************************************************************/ | |
| 155 | +ctfindvar& ctfindvar::operator=(const ctfindvar& app) | |
| 156 | +{ | |
| 157 | + // Execute only if object is not identical | |
| 158 | + if (this != &app) { | |
| 159 | + | |
| 160 | + // Copy base class members | |
| 161 | + this->ctobservation::operator=(app); | |
| 162 | + | |
| 163 | + // Free members | |
| 164 | + free_members(); | |
| 165 | + | |
| 166 | + // Initialise members | |
| 167 | + init_members(); | |
| 168 | + | |
| 169 | + // Copy members | |
| 170 | + copy_members(app); | |
| 171 | + | |
| 172 | + } // endif: object was not identical | |
| 173 | + | |
| 174 | + // Return this object | |
| 175 | + return *this; | |
| 176 | +} | |
| 177 | + | |
| 178 | + | |
| 179 | +/*========================================================================== | |
| 180 | + = = | |
| 181 | + = Public methods = | |
| 182 | + = = | |
| 183 | + ==========================================================================*/ | |
| 184 | + | |
| 185 | +/***********************************************************************//** | |
| 186 | + * @brief Clear search time variability tool | |
| 187 | + * | |
| 188 | + * Clears search time variability tool. | |
| 189 | + ***************************************************************************/ | |
| 190 | +void ctfindvar::clear(void) | |
| 191 | +{ | |
| 192 | + // Free members | |
| 193 | + free_members(); | |
| 194 | + this->ctobservation::free_members(); | |
| 195 | + this->ctool::free_members(); | |
| 196 | + | |
| 197 | + // Clear base class (needed to conserve tool name and version) | |
| 198 | + this->GApplication::clear(); | |
| 199 | + | |
| 200 | + // Initialise members | |
| 201 | + this->ctool::init_members(); | |
| 202 | + this->ctobservation::init_members(); | |
| 203 | + init_members(); | |
| 204 | + | |
| 205 | + // Write header into logger | |
| 206 | + log_header(); | |
| 207 | + | |
| 208 | + // Return | |
| 209 | + return; | |
| 210 | +} | |
| 211 | + | |
| 212 | + | |
| 213 | +/***********************************************************************//** | |
| 214 | + * @brief Run search time variability tool | |
| 215 | + ***************************************************************************/ | |
| 216 | +void ctfindvar::run(void) | |
| 217 | +{ | |
| 218 | + // If we're in debug mode then all output is also dumped on the screen | |
| 219 | + if (logDebug()) { | |
| 220 | + log.cout(true); | |
| 221 | + } | |
| 222 | + | |
| 223 | + // Get task parameters | |
| 224 | + get_parameters(); | |
| 225 | + | |
| 226 | + // Write input observation container into logger | |
| 227 | + log_observations(NORMAL, m_obs, "Input observation"); | |
| 228 | + | |
| 229 | + // TODO: Your code goes here | |
| 230 | + | |
| 231 | + // Return | |
| 232 | + return; | |
| 233 | +} | |
| 234 | + | |
| 235 | + | |
| 236 | +/***********************************************************************//** | |
| 237 | + * @brief Save something | |
| 238 | + * | |
| 239 | + * Saves something. | |
| 240 | + ***************************************************************************/ | |
| 241 | +void ctfindvar::save(void) | |
| 242 | +{ | |
| 243 | + // Write header | |
| 244 | + log_header1(TERSE, "Save something"); | |
| 245 | + | |
| 246 | + // TODO: Your code goes here | |
| 247 | + | |
| 248 | + // Return | |
| 249 | + return; | |
| 250 | +} | |
| 251 | + | |
| 252 | + | |
| 253 | +/*========================================================================== | |
| 254 | + = = | |
| 255 | + = Private methods = | |
| 256 | + = = | |
| 257 | + ==========================================================================*/ | |
| 258 | + | |
| 259 | +/***********************************************************************//** | |
| 260 | + * @brief Initialise class members | |
| 261 | + ***************************************************************************/ | |
| 262 | +void ctfindvar::init_members(void) | |
| 263 | +{ | |
| 264 | + // Initialise members | |
| 265 | + // TODO: Your code goes here | |
| 266 | + | |
| 267 | + // Return | |
| 268 | + return; | |
| 269 | +} | |
| 270 | + | |
| 271 | + | |
| 272 | +/***********************************************************************//** | |
| 273 | + * @brief Copy class members | |
| 274 | + * | |
| 275 | + * @param[in] app search time variability tool. | |
| 276 | + ***************************************************************************/ | |
| 277 | +void ctfindvar::copy_members(const ctfindvar& app) | |
| 278 | +{ | |
| 279 | + // Copy attributes | |
| 280 | + // TODO: Your code goes here | |
| 281 | + | |
| 282 | + // Return | |
| 283 | + return; | |
| 284 | +} | |
| 285 | + | |
| 286 | + | |
| 287 | +/***********************************************************************//** | |
| 288 | + * @brief Delete class members | |
| 289 | + ***************************************************************************/ | |
| 290 | +void ctfindvar::free_members(void) | |
| 291 | +{ | |
| 292 | + // Return | |
| 293 | + return; | |
| 294 | +} | |
| 295 | + | |
| 296 | + | |
| 297 | +/***********************************************************************//** | |
| 298 | + * @brief Get application parameters | |
| 299 | + * | |
| 300 | + * @todo Implement method | |
| 301 | + ***************************************************************************/ | |
| 302 | +void ctfindvar::get_parameters(void) | |
| 303 | +{ | |
| 304 | + // TODO: Your code goes here | |
| 305 | + | |
| 306 | + // Write parameters into logger | |
| 307 | + log_parameters(TERSE); | |
| 308 | + | |
| 309 | + // Return | |
| 310 | + return; | |
| 311 | +} | ... | ... |
src/ctfindvar/ctfindvar.hpp
0 → 100644
| 1 | +/*************************************************************************** | |
| 2 | + * ctfindvar - search time variability tool * | |
| 3 | + * ----------------------------------------------------------------------- * | |
| 4 | + * copyright (C) 2018 by Simon Bonnefoy * | |
| 5 | + * ----------------------------------------------------------------------- * | |
| 6 | + * * | |
| 7 | + * This program is free software: you can redistribute it and/or modify * | |
| 8 | + * it under the terms of the GNU General Public License as published by * | |
| 9 | + * the Free Software Foundation, either version 3 of the License, or * | |
| 10 | + * (at your option) any later version. * | |
| 11 | + * * | |
| 12 | + * This program is distributed in the hope that it will be useful, * | |
| 13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of * | |
| 14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | |
| 15 | + * GNU General Public License for more details. * | |
| 16 | + * * | |
| 17 | + * You should have received a copy of the GNU General Public License * | |
| 18 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. * | |
| 19 | + * * | |
| 20 | + ***************************************************************************/ | |
| 21 | +/** | |
| 22 | + * @file ctfindvar.hpp | |
| 23 | + * @brief search time variability tool definition | |
| 24 | + * @author Simon Bonnefoy | |
| 25 | + */ | |
| 26 | + | |
| 27 | +#ifndef CTFINDVAR_HPP | |
| 28 | +#define CTFINDVAR_HPP | |
| 29 | + | |
| 30 | +/* __ Includes ___________________________________________________________ */ | |
| 31 | +#include "ctobservation.hpp" | |
| 32 | + | |
| 33 | +/* __Definitions _________________________________________________________ */ | |
| 34 | +#define CTFINDVAR_NAME "ctfindvar" | |
| 35 | + | |
| 36 | + | |
| 37 | +/***********************************************************************//** | |
| 38 | + * @class ctfindvar | |
| 39 | + * | |
| 40 | + * @brief search time variability tool | |
| 41 | + * | |
| 42 | + * @todo Add tool description. | |
| 43 | + ***************************************************************************/ | |
| 44 | +class ctfindvar : public ctobservation { | |
| 45 | +public: | |
| 46 | + // Constructors and destructors | |
| 47 | + ctfindvar(void); | |
| 48 | + explicit ctfindvar(const GObservations& obs); | |
| 49 | + ctfindvar(int argc, char *argv[]); | |
| 50 | + ctfindvar(const ctfindvar& app); | |
| 51 | + virtual ~ctfindvar(void); | |
| 52 | + | |
| 53 | + // Operators | |
| 54 | + ctfindvar& operator=(const ctfindvar& app); | |
| 55 | + | |
| 56 | + // Methods | |
| 57 | + void clear(void); | |
| 58 | + void run(void); | |
| 59 | + void save(void); | |
| 60 | + | |
| 61 | +protected: | |
| 62 | + // Protected methods | |
| 63 | + void init_members(void); | |
| 64 | + void copy_members(const ctfindvar& app); | |
| 65 | + void free_members(void); | |
| 66 | + void get_parameters(void); | |
| 67 | + | |
| 68 | + // Protected members | |
| 69 | + // TODO: Add any data members that are necessary | |
| 70 | +}; | |
| 71 | + | |
| 72 | +#endif /* CTFINDVAR_HPP */ | ... | ... |
src/ctfindvar/ctfindvar.par
0 → 100644
| 1 | +############################################################################# | |
| 2 | +# # | |
| 3 | +# CTA Science Analysis Tools # | |
| 4 | +# # | |
| 5 | +# ------------------------------------------------------------------------- # | |
| 6 | +# # | |
| 7 | +# File: ctfindvar.par # | |
| 8 | +# # | |
| 9 | +# Author: Simon Bonnefoy # | |
| 10 | +# simon.bonnefoy@desy.de # | |
| 11 | +# DESY # | |
| 12 | +# # | |
| 13 | +# Purpose: Parameter file for the ctfindvar tool # | |
| 14 | +# # | |
| 15 | +############################################################################# | |
| 16 | +# | |
| 17 | +# General parameters | |
| 18 | +#=================== | |
| 19 | +# Your parameters go here | |
| 20 | + | |
| 21 | +# | |
| 22 | +# Standard parameters | |
| 23 | +#==================== | |
| 24 | +chatter, i, h, 2,0,4, "Chattiness of output" | |
| 25 | +clobber, b, h, yes,,, "Overwrite existing output files with new output files?" | |
| 26 | +debug, b, h, no,,, "Activate debugging mode?" | |
| 27 | +mode, s, h, ql,,, "Mode of automatic parameters" | |
| 28 | +logfile, f, h, ctfindvar.log,,, "Log filename" | ... | ... |
src/ctfindvar/main.cpp
0 → 100644
| 1 | +/*************************************************************************** | |
| 2 | + *ctfindvar - search time variability tool main code * | |
| 3 | + * ----------------------------------------------------------------------- * | |
| 4 | + * copyright (C) 2018 by Simon Bonnefoy * | |
| 5 | + * ----------------------------------------------------------------------- * | |
| 6 | + * * | |
| 7 | + * This program is free software: you can redistribute it and/or modify * | |
| 8 | + * it under the terms of the GNU General Public License as published by * | |
| 9 | + * the Free Software Foundation, either version 3 of the License, or * | |
| 10 | + * (at your option) any later version. * | |
| 11 | + * * | |
| 12 | + * This program is distributed in the hope that it will be useful, * | |
| 13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of * | |
| 14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | |
| 15 | + * GNU General Public License for more details. * | |
| 16 | + * * | |
| 17 | + * You should have received a copy of the GNU General Public License * | |
| 18 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. * | |
| 19 | + * * | |
| 20 | + ***************************************************************************/ | |
| 21 | +/** | |
| 22 | + * @file ctfindvar/main.cpp | |
| 23 | + * @brief search time variability tool main code | |
| 24 | + * @author Simon Bonnefoy | |
| 25 | + */ | |
| 26 | + | |
| 27 | +/* __ Includes ___________________________________________________________ */ | |
| 28 | +#ifdef HAVE_CONFIG_H | |
| 29 | +#include <config.h> | |
| 30 | +#endif | |
| 31 | +#include "support.hpp" | |
| 32 | +#include "ctfindvar.hpp" | |
| 33 | + | |
| 34 | + | |
| 35 | +/***********************************************************************//** | |
| 36 | + * @brief Main entry point of application | |
| 37 | + * | |
| 38 | + * @param[in] argc Number of command line arguments. | |
| 39 | + * @param[in] argv Command line arguments. | |
| 40 | + * | |
| 41 | + * This is the main entry point of the ctfindvar application. It allocates a | |
| 42 | + * ctfindvar object and executes the application. Any exceptions that occur | |
| 43 | + * will be catched and corresponding error messages written in the | |
| 44 | + * application logger and into the standard output. | |
| 45 | + ***************************************************************************/ | |
| 46 | +int main (int argc, char *argv[]) | |
| 47 | +{ | |
| 48 | + // Initialise return code | |
| 49 | + int rc = 1; | |
| 50 | + | |
| 51 | + // Initialise pointer on application | |
| 52 | + ctfindvar* application = NULL; | |
| 53 | + | |
| 54 | + // Try creating an instance of the application and executing the instance | |
| 55 | + try { | |
| 56 | + | |
| 57 | + // Create instance of application | |
| 58 | + application = new ctfindvar(argc, argv); | |
| 59 | + | |
| 60 | + // Execute ctool | |
| 61 | + rc = execute_ctool(application); | |
| 62 | + | |
| 63 | + } | |
| 64 | + | |
| 65 | + catch (std::exception &e) { | |
| 66 | + | |
| 67 | + // Report exception | |
| 68 | + report_ctool_failure("ctfindvar", e.what()); | |
| 69 | + | |
| 70 | + } | |
| 71 | + | |
| 72 | + // Delete application | |
| 73 | + delete application; | |
| 74 | + | |
| 75 | + // Return | |
| 76 | + return rc; | |
| 77 | +} | ... | ... |
test/test_ctfindvar.py
0 → 100644
| 1 | +#! /usr/bin/env python | |
| 2 | +# ========================================================================== | |
| 3 | +# This scripts performs unit tests for the ctfindvar tool. | |
| 4 | +# | |
| 5 | +# Copyright (C) 2018 Simon Bonnefoy | |
| 6 | +# | |
| 7 | +# This program is free software: you can redistribute it and/or modify | |
| 8 | +# it under the terms of the GNU General Public License as published by | |
| 9 | +# the Free Software Foundation, either version 3 of the License, or | |
| 10 | +# (at your option) any later version. | |
| 11 | +# | |
| 12 | +# This program is distributed in the hope that it will be useful, | |
| 13 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 14 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 15 | +# GNU General Public License for more details. | |
| 16 | +# | |
| 17 | +# You should have received a copy of the GNU General Public License | |
| 18 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| 19 | +# | |
| 20 | +# ========================================================================== | |
| 21 | +import os | |
| 22 | +import gammalib | |
| 23 | +import ctools | |
| 24 | +from testing import test | |
| 25 | + | |
| 26 | + | |
| 27 | +# ======================= # | |
| 28 | +# Test class for ctfindvar tool # | |
| 29 | +# ======================= # | |
| 30 | +class Test(test): | |
| 31 | + """ | |
| 32 | + Test class for ctfindvar tool | |
| 33 | + | |
| 34 | + This test class makes unit tests for the ctfindvar tool by using it from | |
| 35 | + the command line and from Python. | |
| 36 | + """ | |
| 37 | + | |
| 38 | + # Constructor | |
| 39 | + def __init__(self): | |
| 40 | + """ | |
| 41 | + Constructor | |
| 42 | + """ | |
| 43 | + # Call base class constructor | |
| 44 | + test.__init__(self) | |
| 45 | + | |
| 46 | + # Return | |
| 47 | + return | |
| 48 | + | |
| 49 | + # Set test functions | |
| 50 | + def set(self): | |
| 51 | + """ | |
| 52 | + Set all test functions | |
| 53 | + """ | |
| 54 | + # Set test name | |
| 55 | + self.name('ctfindvar') | |
| 56 | + | |
| 57 | + # Append tests | |
| 58 | + self.append(self._test_cmd, 'Test ctfindvar on command line') | |
| 59 | + self.append(self._test_python, 'Test ctfindvar from Python') | |
| 60 | + | |
| 61 | + # Return | |
| 62 | + return | |
| 63 | + | |
| 64 | + # Test ctfindvar on command line | |
| 65 | + def _test_cmd(self): | |
| 66 | + """ | |
| 67 | + Test ctfindvar on the command line | |
| 68 | + """ | |
| 69 | + # Set tool name | |
| 70 | + ctfindvar = self._tool('ctfindvar') | |
| 71 | + | |
| 72 | + # Setup ctfindvar command | |
| 73 | + cmd = ctfindvar+' logfile="ctfindvar_cmd1.log" chatter=1' | |
| 74 | + | |
| 75 | + # Check if execution was successful | |
| 76 | + self.test_value(self._execute(cmd), 0, | |
| 77 | + 'Check successful execution from command line') | |
| 78 | + | |
| 79 | + # Check ctfindvar --help | |
| 80 | + self._check_help(ctfindvar) | |
| 81 | + | |
| 82 | + # Return | |
| 83 | + return | |
| 84 | + | |
| 85 | + # Test ctfindvar from Python | |
| 86 | + def _test_python(self): | |
| 87 | + """ | |
| 88 | + Test ctfindvar from Python | |
| 89 | + """ | |
| 90 | + # Allocate ctfindvar | |
| 91 | + tool = ctools.ctfindvar() | |
| 92 | + | |
| 93 | + # Check that saving does not nothing | |
| 94 | + tool['logfile'] = 'ctfindvar_py0.log' | |
| 95 | + tool.logFileOpen() | |
| 96 | + tool.save() | |
| 97 | + self.test_assert(not os.path.isfile('ctfindvar_py0.fits'), | |
| 98 | + 'Check that no FITS file has been created') | |
| 99 | + | |
| 100 | + # Check that clearing does not lead to an exception or segfault | |
| 101 | + tool.clear() | |
| 102 | + | |
| 103 | + # Now set ctfindvar parameters | |
| 104 | + tool['logfile'] = 'ctfindvar_py1.log' | |
| 105 | + tool['chatter'] = 2 | |
| 106 | + | |
| 107 | + # Run ctfindvar tool | |
| 108 | + tool.logFileOpen() | |
| 109 | + tool.run() | |
| 110 | + | |
| 111 | + # Check result | |
| 112 | + self._check_result(tool) | |
| 113 | + | |
| 114 | + # Copy ctfindvar tool | |
| 115 | + cpy_tool = tool.copy() | |
| 116 | + | |
| 117 | + # Check result | |
| 118 | + self._check_result(cpy_tool) | |
| 119 | + | |
| 120 | + # Run copy of ctfindvar tool again | |
| 121 | + cpy_tool['logfile'] = 'ctfindvar_py2.log' | |
| 122 | + cpy_tool['chatter'] = 3 | |
| 123 | + cpy_tool.logFileOpen() | |
| 124 | + cpy_tool.run() | |
| 125 | + | |
| 126 | + # Check result | |
| 127 | + self._check_result(cpy_tool) | |
| 128 | + | |
| 129 | + # Return | |
| 130 | + return | |
| 131 | + | |
| 132 | + # Check ctfindvar result | |
| 133 | + def _check_result(self, tool): | |
| 134 | + """ | |
| 135 | + Check content of tool | |
| 136 | + | |
| 137 | + Parameters | |
| 138 | + ---------- | |
| 139 | + tool : `~ctools.ctfindvar` | |
| 140 | + ctfindvar instance | |
| 141 | + """ | |
| 142 | + # TODO: Implement test on tool result | |
| 143 | + | |
| 144 | + # Return | |
| 145 | + return | ... | ... |