Commit 96ec743cc9734f95d9865ee2ac111a5eb30ce7b6

Authored by Jürgen Knödlseder
2 parents 535bdb93 3992ea54

Merge branch 'ctbkgcube-2' into integration

.gitignore
... ... @@ -54,6 +54,7 @@ src/ctselect/ctselect
54 54 src/ctskymap/ctskymap
55 55 src/ctexpcube/ctexpcube
56 56 src/ctpsfcube/ctpsfcube
  57 +src/ctbkgcube/ctbkgcube
57 58 src/ctcubemask/ctcubemask
58 59 test/pfiles/
59 60 test/*.fits
... ...
ChangeLog
1   -2014-07-20 Juergen Knoedlseder <jurgen.knodlseder@irap.omp.eu>
  1 +2014-07-22 Juergen Knoedlseder <jurgen.knodlseder@irap.omp.eu>
2 2  
3 3 * Version 0.8.0 released
4 4 ========================
... ... @@ -6,7 +6,8 @@
6 6 Adapt to GammaLib 0.9.0 interface
7 7 ctbin now always merges event lists into a single counts cube
8 8 Add ctexpcube tool (generates exposure cube)
9   - Add ctpsfcube tool (generated PSF cube)
  9 + Add ctpsfcube tool (generates PSF cube)
  10 + Add ctbkgcube tool (generates background cube)
10 11 Add ctcubemask tool (masks event bins in event cube)
11 12 Support energy dispersion in ctobssim, ctlike and ctmodel
12 13 Correct ctobssim for thread safety
... ...
... ... @@ -2,7 +2,7 @@ New Features and Important Changes in ctools 00-08-00
2 2  
3 3 Author(s) : Juergen Knoedlseder
4 4  
5   -20 July 2014
  5 +22 July 2014
6 6  
7 7  
8 8 1. Introduction
... ... @@ -97,7 +97,15 @@ definition file. The cube definition may be taken from a counts cube
97 97 or may be specified by user parameters.
98 98  
99 99  
100   -12. ctcubemask - CTA cube filtering
  100 +12. ctbkgcube - CTA background cube generation
  101 +----------------------------------------------
  102 +The first version of the ctbkgcube tool is included in the release.
  103 +ctbkgcube computes the background cube for an observation definition
  104 +file. The cube definition may be taken from a counts cube or may be
  105 +specified by user parameters.
  106 +
  107 +
  108 +13. ctcubemask - CTA cube filtering
101 109 -----------------------------------
102 110 The first version of the ctcubemask tool is included in the release.
103 111 ctcubemask allows filtering of bins in a counts cube by setting the
... ... @@ -105,12 +113,12 @@ bin content to -1. Filtering can be done by energy, for a circular
105 113 Region of Interest (ROI) or using ds9 exclusion regions.
106 114  
107 115  
108   -13. Examples
  116 +14. Examples
109 117 ------------
110 118 None
111 119  
112 120  
113   -14. Scripts
  121 +15. Scripts
114 122 -----------
115 123 Add logL and event statistics to cspull output file.
116 124  
... ... @@ -119,11 +127,11 @@ Convert all tabs into spaces.
119 127 The obsutils script has now been moved into the ctools module namespace.
120 128  
121 129  
122   -15. caldb
  130 +16. caldb
123 131 ---------
124 132 None
125 133  
126 134  
127   -16. models
  135 +17. models
128 136 ----------
129 137 None
... ...
configure.ac
... ... @@ -884,6 +884,7 @@ AC_CONFIG_FILES([Makefile
884 884 src/ctselect/Makefile
885 885 src/ctexpcube/Makefile
886 886 src/ctpsfcube/Makefile
  887 + src/ctbkgcube/Makefile
887 888 src/ctcubemask/Makefile
888 889 src/ctools-setup
889 890 test/Makefile
... ...
pyext/ctbkgcube.i 0 → 100644
  1 +/***************************************************************************
  2 + * ctbkgcube - CTA background cube tool *
  3 + * ----------------------------------------------------------------------- *
  4 + * copyright (C) 2014 by Chia-Chun Lu *
  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 ctbkgcube.i
  23 + * @brief CTA background cube tool definition
  24 + * @author Chia-Chun Lu
  25 + */
  26 +
  27 +%{
  28 +/* Put headers and other declarations here that are needed for compilation */
  29 +#include "ctbkgcube.hpp"
  30 +#include "GTools.hpp"
  31 +%}
  32 +
  33 +/***********************************************************************//**
  34 + * @class ctbkgcube
  35 + *
  36 + * @brief CTA background cube tool
  37 + ***************************************************************************/
  38 +class ctbkgcube : public GApplication {
  39 +
  40 +public:
  41 + // Constructors and destructors
  42 + ctbkgcube(void);
  43 + explicit ctbkgcube(const GObservations& obs);
  44 + ctbkgcube(int argc, char *argv[]);
  45 + ctbkgcube(const ctbkgcube& app);
  46 + virtual ~ctbkgcube(void);
  47 +
  48 + // Methods
  49 + void clear(void);
  50 + void execute(void);
  51 + void run(void);
  52 + void save(void);
  53 + const GObservations& obs(void) const;
  54 + void get_parameters(void);
  55 + void get_obs(void);
  56 + void get_ebounds(void);
  57 + void set_from_cntmap(const std::string& filename);
  58 + void fill_cube(GCTAObservation* obs);
  59 +};
  60 +
  61 +/***********************************************************************//**
  62 + * @brief CTA background cube tool Python extension
  63 + ***************************************************************************/
  64 +%extend ctbkgcube {
  65 + ctbkgcube copy() {
  66 + return (*self);
  67 + }
  68 +}
... ...
pyext/ctools/ctools.i
... ... @@ -53,4 +53,5 @@
53 53 %include "ctskymap.i"
54 54 %include "ctexpcube.i"
55 55 %include "ctpsfcube.i"
  56 +%include "ctbkgcube.i"
56 57 %include "ctcubemask.i"
... ...
src/Makefile.am
... ... @@ -13,6 +13,7 @@ SUBDIRS = ctbin \
13 13 ctskymap \
14 14 ctexpcube \
15 15 ctpsfcube \
  16 + ctbkgcube \
16 17 ctcubemask
17 18  
18 19 # Scripts to be distributed
... ... @@ -33,6 +34,7 @@ libctools_la_LIBADD = ctbin/libctbin.la \
33 34 ctskymap/libctskymap.la \
34 35 ctexpcube/libctexpcube.la \
35 36 ctpsfcube/libctpsfcube.la \
  37 + ctbkgcube/libctbkgcube.la \
36 38 ctcubemask/libctcubemask.la
37 39  
38 40 # Distribute scripts
... ...
src/ctbin/ctbin.cpp
... ... @@ -777,7 +777,7 @@ void ctbin::fill_cube(GCTAObservation* obs)
777 777 // Make sure that the observation holds a CTA event list. If this
778 778 // is not the case then throw an exception.
779 779 if (dynamic_cast<const GCTAEventList*>(obs->events()) == NULL) {
780   - throw GException::no_list(G_BIN_EVENTS);
  780 + throw GException::no_list(G_FILL_CUBE);
781 781 }
782 782  
783 783 // Initialise binning statistics
... ...
src/ctbkgcube/Makefile.am 0 → 100644
  1 +## Process this file with automake to produce Makefile.in
  2 +
  3 +# Program name
  4 +bin_PROGRAMS = ctbkgcube
  5 +
  6 +# Sources
  7 +sources = ctbkgcube.cpp
  8 +
  9 +# Libtool library
  10 +noinst_LTLIBRARIES = libctbkgcube.la
  11 +libctbkgcube_la_SOURCES = $(sources)
  12 +
  13 +# Program definition
  14 +ctbkgcube_SOURCES = main.cpp
  15 +ctbkgcube_LDFLAGS = $(LIB_LINK_OPTION) @LDFLAGS@
  16 +ctbkgcube_CPPFLAGS = @CPPFLAGS@
  17 +ctbkgcube_LDADD = libctbkgcube.la
  18 +
  19 +# Parameter files
  20 +pfilesdir = $(prefix)/syspfiles
  21 +pfiles_DATA = ctbkgcube.par
... ...
src/ctbkgcube/ctbkgcube.cpp 0 → 100644
  1 +/***************************************************************************
  2 + * ctbkgcube - CTA background cube tool *
  3 + * ----------------------------------------------------------------------- *
  4 + * copyright (C) 2014 by Chia-Chun Lu *
  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 ctbkgcube.cpp
  23 + * @brief CTA background cube tool implementation
  24 + * @author Chia-Chun Lu
  25 + */
  26 +
  27 +/* __ Includes ___________________________________________________________ */
  28 +#ifdef HAVE_CONFIG_H
  29 +#include <config.h>
  30 +#endif
  31 +#include <cstdio>
  32 +#include "ctbkgcube.hpp"
  33 +#include "GTools.hpp"
  34 +
  35 +/* __ Method name definitions ____________________________________________ */
  36 +#define G_GET_PARAMETERS "ctbkgcube::get_parameters()"
  37 +#define G_GET_OBS "ctbkgcube::get_obs()"
  38 +#define G_GET_EBOUNDS "ctbkgcube::get_ebounds()"
  39 +#define G_SET_FROM_CNTMAP "ctbkgcube::set_from_cntmap(std::string&)"
  40 +
  41 +/* __ Debug definitions __________________________________________________ */
  42 +
  43 +/* __ Coding definitions _________________________________________________ */
  44 +
  45 +
  46 +/*==========================================================================
  47 + = =
  48 + = Constructors/destructors =
  49 + = =
  50 + ==========================================================================*/
  51 +
  52 +/***********************************************************************//**
  53 + * @brief Void constructor
  54 + ***************************************************************************/
  55 +ctbkgcube::ctbkgcube(void) : GApplication(CTBKGCUBE_NAME, CTBKGCUBE_VERSION)
  56 +{
  57 + // Initialise members
  58 + init_members();
  59 +
  60 + // Write header into logger
  61 + log_header();
  62 +
  63 + // Return
  64 + return;
  65 +}
  66 +
  67 +
  68 +/***********************************************************************//**
  69 + * @brief Observations constructor
  70 + *
  71 + * param[in] obs Observation container.
  72 + *
  73 + * This method creates an instance of the class by copying an existing
  74 + * observations container.
  75 + ***************************************************************************/
  76 +ctbkgcube::ctbkgcube(const GObservations& obs) :
  77 + GApplication(CTBKGCUBE_NAME, CTBKGCUBE_VERSION)
  78 +{
  79 + // Initialise members
  80 + init_members();
  81 +
  82 + // Set observations
  83 + m_obs = obs;
  84 +
  85 + // Write header into logger
  86 + log_header();
  87 +
  88 + // Return
  89 + return;
  90 +}
  91 +
  92 +
  93 +
  94 +/***********************************************************************//**
  95 + * @brief Command line constructor
  96 + *
  97 + * @param[in] argc Number of arguments in command line.
  98 + * @param[in] argv Array of command line arguments.
  99 + ***************************************************************************/
  100 +ctbkgcube::ctbkgcube(int argc, char *argv[]) :
  101 + GApplication(CTBKGCUBE_NAME, CTBKGCUBE_VERSION, argc, argv)
  102 +{
  103 + // Initialise members
  104 + init_members();
  105 +
  106 + // Write header into logger
  107 + log_header();
  108 +
  109 + // Return
  110 + return;
  111 +}
  112 +
  113 +
  114 +/***********************************************************************//**
  115 + * @brief Copy constructor
  116 + *
  117 + * @param[in] app ctbkgcube application.
  118 + ***************************************************************************/
  119 +ctbkgcube::ctbkgcube(const ctbkgcube& app) : GApplication(app)
  120 +{
  121 + // Initialise members
  122 + init_members();
  123 +
  124 + // Copy members
  125 + copy_members(app);
  126 +
  127 + // Return
  128 + return;
  129 +}
  130 +
  131 +
  132 +/***********************************************************************//**
  133 + * @brief Destructor
  134 + ***************************************************************************/
  135 +ctbkgcube::~ctbkgcube(void)
  136 +{
  137 + // Free members
  138 + free_members();
  139 +
  140 + // Return
  141 + return;
  142 +}
  143 +
  144 +
  145 +/*==========================================================================
  146 + = =
  147 + = Operators =
  148 + = =
  149 + ==========================================================================*/
  150 +
  151 +/***********************************************************************//**
  152 + * @brief Assignment operator
  153 + *
  154 + * @param[in] app ctbkgcube application.
  155 + * @return Returns ctbkgcube application.
  156 + ***************************************************************************/
  157 +ctbkgcube& ctbkgcube::operator=(const ctbkgcube& app)
  158 +{
  159 + // Execute only if object is not identical
  160 + if (this != &app) {
  161 +
  162 + // Copy base class members
  163 + this->GApplication::operator=(app);
  164 +
  165 + // Free members
  166 + free_members();
  167 +
  168 + // Initialise members
  169 + init_members();
  170 +
  171 + // Copy members
  172 + copy_members(app);
  173 +
  174 + } // endif: object was not identical
  175 +
  176 + // Return this object
  177 + return *this;
  178 +}
  179 +
  180 +
  181 +/*==========================================================================
  182 + = =
  183 + = Public methods =
  184 + = =
  185 + ==========================================================================*/
  186 +
  187 +/***********************************************************************//**
  188 + * @brief Clear instance
  189 + ***************************************************************************/
  190 +void ctbkgcube::clear(void)
  191 +{
  192 + // Free members
  193 + free_members();
  194 + this->GApplication::free_members();
  195 +
  196 + // Initialise members
  197 + this->GApplication::init_members();
  198 + init_members();
  199 +
  200 + // Return
  201 + return;
  202 +}
  203 +
  204 +
  205 +/***********************************************************************//**
  206 + * @brief Execute application
  207 + *
  208 + * This is the main execution method of the ctbkgcube class. It is invoked
  209 + * when the executable is called from command line. The method generates
  210 + * the background cube and saves the result.
  211 + ***************************************************************************/
  212 +void ctbkgcube::execute(void)
  213 +{
  214 + // Signal that some parameters should be read ahead
  215 + m_read_ahead = true;
  216 +
  217 + // Create the background cube
  218 + run();
  219 +
  220 + // Save the background cube into the output FITS file
  221 + save();
  222 +
  223 + // Return
  224 + return;
  225 +}
  226 +
  227 +
  228 +/***********************************************************************//**
  229 + * @brief Generate the background cube(s).
  230 + *
  231 + * This method reads the task parameters from the parfile, sets up the
  232 + * observation container, loops over all CTA observations in the container
  233 + * and generates a background cube from the CTA observations.
  234 + ***************************************************************************/
  235 +void ctbkgcube::run(void)
  236 +{
  237 + // If we're in debug mode then all output is also dumped on the screen
  238 + if (logDebug()) {
  239 + log.cout(true);
  240 + }
  241 +
  242 + // Get task parameters
  243 + get_parameters();
  244 +
  245 + // Write parameters into logger
  246 + if (logTerse()) {
  247 + log_parameters();
  248 + log << std::endl;
  249 + }
  250 +
  251 + // Write observation(s) into logger
  252 + if (logTerse()) {
  253 + log << std::endl;
  254 + if (m_obs.size() > 1) {
  255 + log.header1("Observations");
  256 + }
  257 + else {
  258 + log.header1("Observation");
  259 + }
  260 + log << m_obs << std::endl;
  261 + }
  262 +
  263 + // Write header
  264 + if (logTerse()) {
  265 + log << std::endl;
  266 + log.header1("Prepare model");
  267 + }
  268 +
  269 + // Copy models from observation container
  270 + m_bkgmdl = m_obs.models();
  271 +
  272 + // Remove all model that are not CTA background models from the
  273 + // container
  274 + int num = m_bkgmdl.size();
  275 + for (int i = num-1; i >= 0; --i) {
  276 +
  277 + // Flag removal
  278 + bool remove = true;
  279 +
  280 + // Do we have a CTA, HESS or VERITAS specific model?
  281 + if (m_bkgmdl[i]->is_valid("CTA", "") ||
  282 + m_bkgmdl[i]->is_valid("HESS", "") ||
  283 + m_bkgmdl[i]->is_valid("VERITAS", "")) {
  284 +
  285 + // Do we have a background model?
  286 + if (dynamic_cast<GModelData*>(m_bkgmdl[i]) != NULL) {
  287 +
  288 + // ... then keep model
  289 + remove = false;
  290 +
  291 + } // endif: had a background model
  292 + } // endif: had a CTA, HESS or VERITAS model
  293 +
  294 + // Log results
  295 + if (logTerse()) {
  296 + if (remove) {
  297 + log << gammalib::parformat("Remove model");
  298 + }
  299 + else {
  300 + log << gammalib::parformat("Keep model");
  301 + }
  302 + log << m_bkgmdl[i]->name();
  303 + log << " ";
  304 + log << m_bkgmdl[i]->type();
  305 + log << "(";
  306 + log << m_bkgmdl[i]->instruments();
  307 + log << ")";
  308 + log << std::endl;
  309 + }
  310 +
  311 + // Remove model if requested
  312 + if (remove) {
  313 + m_bkgmdl.remove(i);
  314 + }
  315 +
  316 + } // endfor: looped over all background models
  317 +
  318 + // Write header
  319 + if (logTerse()) {
  320 + log << std::endl;
  321 + log.header1("Generate background cube");
  322 + }
  323 +
  324 + // Initialise observation counter
  325 + int n_observations = 0;
  326 +
  327 + // Loop over all observations in the container
  328 + for (int i = 0; i < m_obs.size(); ++i) {
  329 +
  330 + // Get CTA observation
  331 + GCTAObservation* obs = dynamic_cast<GCTAObservation*>(m_obs[i]);
  332 +
  333 + // Continue only if observation is a CTA observation
  334 + if (obs != NULL) {
  335 +
  336 + // Write header for observation
  337 + if (logTerse()) {
  338 + if (obs->name().length() > 1) {
  339 + log.header3("Observation "+obs->name());
  340 + }
  341 + else {
  342 + log.header3("Observation "+gammalib::str(i));
  343 + }
  344 + }
  345 +
  346 + // Increment number of observations
  347 + n_observations++;
  348 +
  349 + // Fill the cube
  350 + fill_cube(obs);
  351 +
  352 + } // endif: CTA observation found
  353 +
  354 + } // endfor: looped over observations
  355 +
  356 + // Log results
  357 + if (logTerse()) {
  358 + log << gammalib::parformat("Number of observations");
  359 + log << n_observations << std::endl;
  360 + }
  361 +
  362 + // Return
  363 + return;
  364 +}
  365 +
  366 +
  367 +/***********************************************************************//**
  368 + * @brief Generate background cube
  369 + *
  370 + * @param[in] obs Pointer to CTA observation.
  371 + *
  372 + * Fills
  373 + ***************************************************************************/
  374 +void ctbkgcube::fill_cube(GCTAObservation* obs)
  375 +{
  376 + // Continue only if observation pointer is valid
  377 + if (obs != NULL) {
  378 +
  379 + // Initialise statistics
  380 + double sum = 0.0;
  381 +
  382 + // Set GTI of actual observations as the GTI of the event cube
  383 + m_bkgcube.gti(obs->events()->gti());
  384 +
  385 + // Loop over all bins in background cube
  386 + for (int i = 0; i < m_bkgcube.size(); ++i) {
  387 +
  388 + // Get event bin
  389 + GCTAEventBin* bin = m_bkgcube[i];
  390 +
  391 + // Compute model value for event bin
  392 + double model =
  393 + m_bkgmdl.eval(*(const_cast<const GCTAEventBin*>(bin)), *obs) *
  394 + bin->size();
  395 +
  396 + // Add existing number of counts
  397 + model += bin->counts();
  398 +
  399 + // Store cumulated value
  400 + bin->counts(model);
  401 +
  402 + // Sum all events
  403 + sum += model;
  404 + }
  405 +
  406 + // Log results
  407 + if (logTerse()) {
  408 + log << gammalib::parformat("Background events in cube");
  409 + log << sum << std::endl;
  410 + }
  411 +
  412 + } // endif: observation pointer was not valid
  413 +
  414 + // Return
  415 + return;
  416 +}
  417 +
  418 +
  419 +/***********************************************************************//**
  420 + * @brief Save background cube
  421 + *
  422 + * Save the background cube into the file specified by the outfile parameter.
  423 + ***************************************************************************/
  424 +void ctbkgcube::save(void)
  425 +{
  426 + // Write header
  427 + if (logTerse()) {
  428 + log << std::endl;
  429 + log.header1("Save background cube");
  430 + }
  431 +
  432 + // Create energies container from energy boundaries
  433 + GEnergies energies;
  434 + for (int i = 0; i < m_ebounds.size(); ++i) {
  435 + energies.append(m_ebounds.elogmean(i));
  436 + }
  437 +
  438 + // Get output filename
  439 + std::string filename = (*this)["outfile"].filename();
  440 +
  441 + // Create empty FITS file
  442 + GFits fits;
  443 +
  444 + // Write background cube
  445 + m_bkgcube.map().write(fits);
  446 +
  447 + // Write energies
  448 + energies.write(fits);
  449 +
  450 + // Save FITS file
  451 + fits.saveto(filename, clobber());
  452 +
  453 + // Return
  454 + return;
  455 +}
  456 +
  457 +
  458 +/***********************************************************************//**
  459 + * @brief Get application parameters
  460 + *
  461 + * @exception GException::invalid_value
  462 + * No background model definition XML file specified.
  463 + *
  464 + * Get all task parameters from parameter file or (if required) by querying
  465 + * the user. The parameters are read in the correct order.
  466 + ***************************************************************************/
  467 +void ctbkgcube::get_parameters(void)
  468 +{
  469 + // If we do not have any observations in the container then load them
  470 + // using the "infile" parameter
  471 + if (m_obs.size() == 0) {
  472 + get_obs();
  473 + }
  474 +
  475 + // If there are no models associated with the observations then load now
  476 + // the model definition from the XML file
  477 + if (m_obs.models().size() == 0) {
  478 + if ((*this)["bkgmdl"].is_undefined()) {
  479 + std::string msg = "No background model definition XML file "
  480 + "specified. Please set the \"bkgmdl\" parameter "
  481 + "to the background model definition XML "
  482 + "filename.";
  483 + throw GException::invalid_value(G_GET_PARAMETERS, msg);
  484 + }
  485 + std::string bkgmdl = (*this)["bkgmdl"].filename();
  486 + GModels models(bkgmdl);
  487 + m_obs.models(models);
  488 + }
  489 +
  490 + // If no counts map is specified then setup the background cube from
  491 + // the user parameters
  492 + std::string cntmap = (*this)["cntmap"].filename();
  493 + if ((gammalib::toupper(cntmap) == "NONE") ||
  494 + (gammalib::strip_whitespace(cntmap) == "")) {
  495 +
  496 + // Get user parameters for counts map definition
  497 + std::string proj = (*this)["proj"].string();
  498 + std::string coordsys = (*this)["coordsys"].string();
  499 + double xref = (*this)["xref"].real();
  500 + double yref = (*this)["yref"].real();
  501 + double binsz = (*this)["binsz"].real();
  502 + int nxpix = (*this)["nxpix"].integer();
  503 + int nypix = (*this)["nypix"].integer();
  504 +
  505 + // Get energy definition
  506 + get_ebounds();
  507 +
  508 + // Define skymap for background cube
  509 + GSkymap map(proj, coordsys, xref, yref,
  510 + -binsz, binsz, nxpix, nypix,
  511 + m_ebounds.size());
  512 +
  513 + // Allocate background cube using a dummy GTI
  514 + GGti gti;
  515 + gti.append(GTime(0.0), GTime(1.0)); // Dummy GTI
  516 + m_bkgcube = GCTAEventCube(map, m_ebounds, gti);
  517 +
  518 + }
  519 +
  520 + // ... otherwise setup the background cube from the counts map
  521 + else {
  522 +
  523 + // Set background cube from counts map
  524 + set_from_cntmap(cntmap);
  525 +
  526 + }
  527 +
  528 + // Read output filename (if needed)
  529 + if (m_read_ahead) {
  530 + std::string filename = (*this)["outfile"].filename();
  531 + }
  532 +
  533 + // Return
  534 + return;
  535 +}
  536 +
  537 +
  538 +/***********************************************************************//**
  539 + * @brief Get observation definition
  540 + *
  541 + * @exception GException::invalid_value
  542 + * No event list, counts cube or observation definition file
  543 + * specified.
  544 + *
  545 + * Get observation definition from the user parameters.
  546 + ***************************************************************************/
  547 +void ctbkgcube::get_obs(void)
  548 +{
  549 + // Get input filename
  550 + std::string filename = (*this)["infile"].filename();
  551 +
  552 + // Check whether infile parameter is undefined
  553 + if (gammalib::toupper(filename) == "NONE") {
  554 + std::string msg = "No event list, counts cube or observation definition "
  555 + "file specified. Please set the \"infile\" parameter "
  556 + "to either an event list filename, a counts cube "
  557 + "filename or an observation definition filename.";
  558 + throw GException::invalid_value(G_GET_OBS, msg);
  559 + }
  560 +
  561 + // Try first to open as FITS file
  562 + try {
  563 +
  564 + // Allocate CTA observation
  565 + GCTAObservation obs;
  566 +
  567 + // Load input file in CTA observation
  568 + obs.load(filename);
  569 +
  570 + // Append CTA observation to container
  571 + m_obs.append(obs);
  572 +
  573 + }
  574 +
  575 + // ... otherwise try to open as XML file
  576 + catch (GException::fits_open_error &e) {
  577 +
  578 + // Load observations from XML file
  579 + m_obs.load(filename);
  580 +
  581 + }
  582 +
  583 + // Return
  584 + return;
  585 +}
  586 +
  587 +
  588 +/***********************************************************************//**
  589 + * @brief Get energy boundaries from parameters
  590 + *
  591 + * @exception GException::invalid_value
  592 + * Energy bin definition file not defined or invalid extension
  593 + * name encountered.
  594 + *
  595 + * Get the energy boundaries from the user parameters.
  596 + ***************************************************************************/
  597 +void ctbkgcube::get_ebounds(void)
  598 +{
  599 + // Determine the energy binning alogrithm
  600 + std::string ebinalg = (*this)["ebinalg"].string();
  601 +
  602 + // If we have the binning given by a file then try to get the boundaries
  603 + // from that file
  604 + if (ebinalg == "FILE") {
  605 +
  606 + // Get filename
  607 + std::string filename = (*this)["ebinfile"].filename();
  608 +
  609 + // Check whether infile parameter is undefined
  610 + if (gammalib::toupper(filename) == "NONE") {
  611 + std::string msg = "No energy bin definition file specified. "
  612 + "Please set the \"ebinfile\" parameter to a "
  613 + "file containing the energy bin definition.";
  614 + throw GException::invalid_value(G_GET_EBOUNDS, msg);
  615 + }
  616 +
  617 + // Open fits file to check which extension is given
  618 + GFits file(filename);
  619 +
  620 + // Check first for EBOUNDS extension
  621 + if (file.contains("EBOUNDS")) {
  622 + file.close();
  623 + m_ebounds.load(filename, "EBOUNDS");
  624 + }
  625 +
  626 + // ... then check for ENERGYBINS extension
  627 + else if (file.contains("ENERGYBINS")) {
  628 + file.close();
  629 + m_ebounds.load(filename, "ENERGYBINS");
  630 + }
  631 +
  632 + // ... otherwise throw an exception
  633 + else {
  634 + file.close();
  635 + std::string msg = "No extension with name \"EBOUNDS\" or"
  636 + " \"ENERGYBINS\" found in FITS file"
  637 + " \""+filename+"\".\n"
  638 + "An \"EBOUNDS\" or \"ENERGYBINS\" extension"
  639 + " is required if the parameter \"ebinalg\""
  640 + " is set to \"FILE\".";
  641 + throw GException::invalid_value(G_GET_EBOUNDS, msg);
  642 + }
  643 + }
  644 +
  645 + // ... otherwise read emin, emax and nebins
  646 + else {
  647 +
  648 + // Get the relevant parameters
  649 + double emin = (*this)["emin"].real();
  650 + double emax = (*this)["emax"].real();
  651 + int enumbins = (*this)["enumbins"].integer();
  652 + bool log = ((*this)["ebinalg"].string() == "LIN") ? false : true;
  653 +
  654 + // Create energy boundaries
  655 + m_ebounds = GEbounds(enumbins,
  656 + GEnergy(emin, "TeV"),
  657 + GEnergy(emax, "TeV"),
  658 + log);
  659 +
  660 + }
  661 +
  662 + // Return
  663 + return;
  664 +}
  665 +
  666 +
  667 +/***********************************************************************//**
  668 + * @brief Set background cube definition from counts map
  669 + *
  670 + * @exception GException::invalid_value
  671 + * Invalid counts map projection or invalid events encountered.
  672 + *
  673 + * Set background cube definition from counts map.
  674 + ***************************************************************************/
  675 +void ctbkgcube::set_from_cntmap(const std::string& filename)
  676 +{
  677 + // Allocate CTA observation
  678 + GCTAObservation obs;
  679 +
  680 + // Load counts map in CTA observation
  681 + obs.load(filename);
  682 +
  683 + // Set background cube from counts map
  684 + const GCTAEventCube* cube = dynamic_cast<const GCTAEventCube*>(obs.events());
  685 +
  686 + // Continue only if cube is valid
  687 + if (cube != NULL) {
  688 +
  689 + // Get sky map projection
  690 + const GWcs* wcs = dynamic_cast<const GWcs*>(cube->map().projection());
  691 +
  692 + // Continue only if projection is valid
  693 + if (wcs != NULL) {
  694 +
  695 + // Get user parameters for counts map definition
  696 + std::string proj = wcs->code();
  697 + std::string coordsys = wcs->coordsys();
  698 + double xref = wcs->crval(0);
  699 + double yref = wcs->crval(1);
  700 + double dx = wcs->cdelt(0);
  701 + double dy = wcs->cdelt(1);
  702 + int nx = cube->map().nx();
  703 + int ny = cube->map().ny();
  704 +
  705 + // Get energy definition
  706 + m_ebounds = cube->ebounds();
  707 +
  708 + // Define skymap for background cube
  709 + GSkymap map(proj, coordsys, xref, yref,
  710 + dx, dy, nx, ny,
  711 + m_ebounds.size());
  712 +
  713 + // Allocate background cube
  714 + m_bkgcube = GCTAEventCube(map, m_ebounds, obs.events()->gti());
  715 +
  716 + } // endif: WCS projection was valid
  717 +
  718 + // ... projection is not of WCS type
  719 + else {
  720 + std::string msg = "Counts map project is not of WCS type.";
  721 + throw GException::invalid_value(G_SET_FROM_CNTMAP, msg);
  722 + }
  723 +
  724 + } // endif: observation contained an events cube
  725 +
  726 + // ... there is not events cube
  727 + else {
  728 + std::string msg = "No events cube found in file \""
  729 + ""+filename+"\".";
  730 + throw GException::invalid_value(G_SET_FROM_CNTMAP, msg);
  731 + }
  732 +
  733 + // Return
  734 + return;
  735 +}
  736 +
  737 +
  738 +/*==========================================================================
  739 + = =
  740 + = Private methods =
  741 + = =
  742 + ==========================================================================*/
  743 +
  744 +/***********************************************************************//**
  745 + * @brief Initialise class members
  746 + ***************************************************************************/
  747 +void ctbkgcube::init_members(void)
  748 +{
  749 + // Initialise members
  750 + m_read_ahead = false;
  751 + m_obs.clear();
  752 + m_bkgcube.clear();
  753 + m_bkgmdl.clear();
  754 + m_ebounds.clear();
  755 +
  756 + // Set logger properties
  757 + log.date(true);
  758 +
  759 + // Return
  760 + return;
  761 +}
  762 +
  763 +
  764 +/***********************************************************************//**
  765 + * @brief Copy class members
  766 + *
  767 + * @param[in] app Application.
  768 + ***************************************************************************/
  769 +void ctbkgcube::copy_members(const ctbkgcube& app)
  770 +{
  771 + // Copy members
  772 + m_read_ahead = app.m_read_ahead;
  773 + m_obs = app.m_obs;
  774 + m_bkgcube = app.m_bkgcube;
  775 + m_bkgmdl = app.m_bkgmdl;
  776 + m_ebounds = app.m_ebounds;
  777 +
  778 + // Return
  779 + return;
  780 +}
  781 +
  782 +
  783 +/***********************************************************************//**
  784 + * @brief Delete class members
  785 + ***************************************************************************/
  786 +void ctbkgcube::free_members(void)
  787 +{
  788 + // Write separator into logger
  789 + if (logTerse()) {
  790 + log << std::endl;
  791 + }
  792 +
  793 + // Return
  794 + return;
  795 +}
... ...
src/ctbkgcube/ctbkgcube.hpp 0 → 100644
  1 +/***************************************************************************
  2 + * ctbkgcube - CTA background cube tool *
  3 + * ----------------------------------------------------------------------- *
  4 + * copyright (C) 2014 by Chia-Chun Lu *
  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 ctbkgcube.hpp
  23 + * @brief CTA background cube tool definition
  24 + * @author Chia-Chun Lu
  25 + */
  26 +
  27 +#ifndef CTBKGCUBE_HPP
  28 +#define CTBKGCUBE_HPP
  29 +
  30 +/* __ Includes ___________________________________________________________ */
  31 +#include "GammaLib.hpp"
  32 +#include "GCTALib.hpp"
  33 +
  34 +/* __Definitions _________________________________________________________ */
  35 +#define CTBKGCUBE_NAME "ctbkgcube"
  36 +#define CTBKGCUBE_VERSION "00-01-00"
  37 +
  38 +
  39 +/***********************************************************************//**
  40 + * @class ctbkgcube
  41 + *
  42 + * @brief CTA background cube tool
  43 + ***************************************************************************/
  44 +class ctbkgcube : public GApplication {
  45 +
  46 +public:
  47 + // Constructors and destructors
  48 + ctbkgcube(void);
  49 + explicit ctbkgcube(const GObservations& obs);
  50 + ctbkgcube(int argc, char *argv[]);
  51 + ctbkgcube(const ctbkgcube& app);
  52 + virtual ~ctbkgcube(void);
  53 +
  54 + // Operators
  55 + ctbkgcube& operator=(const ctbkgcube& app);
  56 +
  57 + // Methods
  58 + void clear(void);
  59 + void execute(void);
  60 + void run(void);
  61 + void save(void);
  62 + const GObservations& obs(void) const;
  63 + void get_parameters(void);
  64 + void get_obs(void);
  65 + void get_ebounds(void);
  66 + void set_from_cntmap(const std::string& filename);
  67 + void fill_cube(GCTAObservation* obs);
  68 +
  69 +protected:
  70 + // Protected methods
  71 + void init_members(void);
  72 + void copy_members(const ctbkgcube& app);
  73 + void free_members(void);
  74 +
  75 + // Protected members
  76 + bool m_read_ahead; //!< Read ahead parameters
  77 + GObservations m_obs; //!< Observation container
  78 + GCTAEventCube m_bkgcube; //!< Background cube
  79 + GModels m_bkgmdl; //!< CTA background models
  80 + GEbounds m_ebounds; //!< Energy boundaries
  81 +};
  82 +
  83 +
  84 +/***********************************************************************//**
  85 + * @brief Return observation container
  86 + *
  87 + * @return Observation container.
  88 + ***************************************************************************/
  89 +inline
  90 +const GObservations& ctbkgcube::obs(void) const
  91 +{
  92 + // Return observation container
  93 + return m_obs;
  94 +}
  95 +
  96 +#endif /* CTBKGCUBE_HPP */
... ...
src/ctbkgcube/ctbkgcube.par 0 → 100644
  1 +#############################################################################
  2 +# #
  3 +# CTA Science Analysis Tools #
  4 +# #
  5 +# ------------------------------------------------------------------------- #
  6 +# #
  7 +# File: ctbkgcube.par #
  8 +# Version: 00-01-00 #
  9 +# #
  10 +# Author: Chia-Chun Lu #
  11 +# c.lu@mpi-hd.mpg.de #
  12 +# MPIK #
  13 +# #
  14 +# Purpose: Parameter file for the ctbkgcube application #
  15 +# #
  16 +#############################################################################
  17 +#
  18 +# General parameters
  19 +#===================
  20 +infile, f, a, "NONE",,, "Event list, counts cube or observation definition file"
  21 +bkgmdl, f, a, "NONE",,, "Background model XML file"
  22 +cntmap, f, a, "NONE",,, "Counts cube for background cube definition"
  23 +outfile, f, a, "bkgcube.fits",,, "Output background cube file"
  24 +#
  25 +# Energy binning parameters
  26 +#==========================
  27 +ebinalg, s, h, "LOG", FILE|LIN|LOG,,"Algorithm for defining energy bins"
  28 +emin, r, a, 0.1,,,"Start value for first energy bin in TeV"
  29 +emax, r, a, 100.0,,,"Stop value for last energy bin in TeV"
  30 +enumbins, i, a, 20,,,"Number of energy bins"
  31 +ebinfile, f, h, "NONE",,,"Name of the file containing the energy bin definition"
  32 +#
  33 +# Spatial binning parameters
  34 +#===========================
  35 +nxpix, i, a, 200,,, "Size of the X axis in pixels"
  36 +nypix, i, a, 200,,, "Size of the Y axis in pixels"
  37 +binsz, r, a, 0.02,,, "Image scale (in degrees/pixel)"
  38 +coordsys, s, a, "CEL", CEL|GAL,,"Coordinate system (CEL - celestial, GAL - galactic)"
  39 +xref, r, a, 83.63,,, "First coordinate of image center in degrees (RA or galactic l)"
  40 +yref, r, a, 22.01,,, "Second coordinate of image center in degrees (DEC or galactic b)"
  41 +axisrot, r, h, 0.0,,, "Rotation angle of image axis, in degrees"
  42 +proj, s, a, "CAR", AIT|AZP|CAR|MER|STG|TAN,, "Projection method e.g. AIT|AZP|CAR|MER|STG|TAN"
  43 +#
  44 +# Standard parameters
  45 +#====================
  46 +chatter, i, h, 2,0,4, "Chattiness of output"
  47 +clobber, b, h, yes,,, "Overwrite existing output files with new output files?"
  48 +debug, b, h, no,,, "Debugging mode activated"
  49 +mode, s, h, "ql",,, "Mode of automatic parameters"
  50 +logfile, f, h, "ctbkgcube.log",,, "Log filename"
... ...
src/ctbkgcube/main.cpp 0 → 100644
  1 +/***************************************************************************
  2 + * ctbkgcube - CTA background cube tool *
  3 + * ----------------------------------------------------------------------- *
  4 + * copyright (C) 2014 by Chia-Chun Lu *
  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 ctbkgcube/main.cpp
  23 + * @brief CTA background cube tool main code
  24 + * @author Chia-Chun Lu
  25 + */
  26 +
  27 +/* __ Includes ___________________________________________________________ */
  28 +#ifdef HAVE_CONFIG_H
  29 +#include <config.h>
  30 +#endif
  31 +#include <cstdio>
  32 +#include "ctbkgcube.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 ctbkgcube application. It allocates a
  42 + * ctbkgcube object and runs the application.
  43 + ***************************************************************************/
  44 +int main (int argc, char *argv[])
  45 +{
  46 + // Initialise return code
  47 + int rc = 1;
  48 +
  49 + // Create instance of application
  50 + ctbkgcube application(argc, argv);
  51 +
  52 + // Run application
  53 + try {
  54 + // Execute application
  55 + application.execute();
  56 +
  57 + // Signal success
  58 + rc = 0;
  59 + }
  60 + catch (std::exception &e) {
  61 +
  62 + // Extract error message
  63 + std::string message = e.what();
  64 + std::string signal = "*** ERROR encounterted in the execution of"
  65 + " ctbkgcube. Run aborted ...";
  66 +
  67 + // Write error in logger
  68 + application.log << signal << std::endl;
  69 + application.log << message << std::endl;
  70 +
  71 + // Write error on standard output
  72 + std::cout << signal << std::endl;
  73 + std::cout << message << std::endl;
  74 +
  75 + } // endcatch: catched any application error
  76 +
  77 + // Return
  78 + return rc;
  79 +}
... ...
src/ctexpcube/ctexpcube.par
... ... @@ -17,7 +17,7 @@
17 17 #
18 18 # General parameters
19 19 #===================
20   -infile, f, a, "NONE",,, "Observation definition file"
  20 +infile, f, a, "NONE",,, "Event list, counts cube or observation definition file"
21 21 cntmap, f, a, "NONE",,, "Counts map for exposure cube definition"
22 22 outfile, f, a, "expcube.fits",,, "Output exposure cube file"
23 23 caldb, s, a, "dummy",,, "Calibration database"
... ...
src/ctpsfcube/ctpsfcube.par
... ... @@ -17,7 +17,7 @@
17 17 #
18 18 # General parameters
19 19 #===================
20   -infile, f, a, "NONE",,, "Observation definition file"
  20 +infile, f, a, "NONE",,, "Event list, counts cube or observation definition file"
21 21 cntmap, f, a, "NONE",,, "Counts map for exposure cube definition"
22 22 outfile, f, a, "psfcube.fits",,, "Output exposure cube file"
23 23 caldb, s, a, "dummy",,, "Calibration database"
... ...
test/test_ctbin.py
... ... @@ -22,9 +22,9 @@ import gammalib
22 22 import ctools
23 23  
24 24  
25   -# ============================ #
26   -# Test class for ctobssim tool #
27   -# ============================ #
  25 +# ========================= #
  26 +# Test class for ctbin tool #
  27 +# ========================= #
28 28 class Test(gammalib.GPythonTestSuite):
29 29 """
30 30 Test class for ctbin tool.
... ...
test/test_ctbkgcube.py 0 → 100755
  1 +#! /usr/bin/env python
  2 +# ==========================================================================
  3 +# This scripts performs unit tests for the ctbkgcube tool.
  4 +#
  5 +# Copyright (C) 2014 Juergen Knoedlseder
  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 gammalib
  22 +import ctools
  23 +
  24 +
  25 +# ============================= #
  26 +# Test class for ctbkgcube tool #
  27 +# ============================= #
  28 +class Test(gammalib.GPythonTestSuite):
  29 + """
  30 + Test class for ctbkgcube tool.
  31 + """
  32 + # Constructor
  33 + def __init__(self):
  34 + """
  35 + Constructor.
  36 + """
  37 + # Call base class constructor
  38 + gammalib.GPythonTestSuite.__init__(self)
  39 +
  40 + # Set members
  41 + self.events_name = "data/crab_events.fits"
  42 + self.bkg_model = "data/crab.xml"
  43 +
  44 + # Return
  45 + return
  46 +
  47 + # Set test functions
  48 + def set(self):
  49 + """
  50 + Set all test functions.
  51 + """
  52 + # Set test name
  53 + self.name("ctbkgcube")
  54 +
  55 + # Append tests
  56 + self.append(self.test_functional, "Test ctbkgcube functionality")
  57 +
  58 + # Return
  59 + return
  60 +
  61 + # Test ctbkgcube functionnality
  62 + def test_functional(self):
  63 + """
  64 + Test ctbkgcube functionnality.
  65 + """
  66 + # Set-up ctbkgcube
  67 + bkgcube = ctools.ctbkgcube()
  68 + bkgcube["infile"].filename(self.events_name)
  69 + bkgcube["bkgmdl"].filename(self.bkg_model)
  70 + bkgcube["cntmap"].filename("NONE")
  71 + bkgcube["outfile"].filename("psfcube.fits")
  72 + bkgcube["ebinalg"].string("LOG")
  73 + bkgcube["emin"].real(0.1)
  74 + bkgcube["emax"].real(100.0)
  75 + bkgcube["enumbins"].integer(20)
  76 + bkgcube["nxpix"].integer(10)
  77 + bkgcube["nypix"].integer(10)
  78 + bkgcube["binsz"].real(0.4)
  79 + bkgcube["coordsys"].string("CEL")
  80 + bkgcube["proj"].string("CAR")
  81 + bkgcube["xref"].real(83.63)
  82 + bkgcube["yref"].real(22.01)
  83 +
  84 + # Run tool
  85 + self.test_try("Run ctbkgcube")
  86 + try:
  87 + bkgcube.run()
  88 + self.test_try_success()
  89 + except:
  90 + self.test_try_failure("Exception occured in ctbkgcube.")
  91 +
  92 + # Save background cube
  93 + self.test_try("Save background cube")
  94 + try:
  95 + bkgcube.save()
  96 + self.test_try_success()
  97 + except:
  98 + self.test_try_failure("Exception occured in saving background cube.")
  99 +
  100 + # Return
  101 + return
... ...
test/test_ctcubemask.py
... ... @@ -22,9 +22,9 @@ import gammalib
22 22 import ctools
23 23  
24 24  
25   -# ============================ #
26   -# Test class for ctobssim tool #
27   -# ============================ #
  25 +# ============================== #
  26 +# Test class for ctcubemask tool #
  27 +# ============================== #
28 28 class Test(gammalib.GPythonTestSuite):
29 29 """
30 30 Test class for ctcubemask tool.
... ...
test/test_ctexpcube.py
... ... @@ -22,9 +22,9 @@ import gammalib
22 22 import ctools
23 23  
24 24  
25   -# ============================ #
26   -# Test class for ctobssim tool #
27   -# ============================ #
  25 +# ============================= #
  26 +# Test class for ctexpcube tool #
  27 +# ============================= #
28 28 class Test(gammalib.GPythonTestSuite):
29 29 """
30 30 Test class for ctexpcube tool.
... ...
test/test_ctlike.py
... ... @@ -22,9 +22,9 @@ import gammalib
22 22 import ctools
23 23  
24 24  
25   -# ============================ #
26   -# Test class for ctobssim tool #
27   -# ============================ #
  25 +# ========================== #
  26 +# Test class for ctlike tool #
  27 +# ========================== #
28 28 class Test(gammalib.GPythonTestSuite):
29 29 """
30 30 Test class for ctlike tool.
... ...
test/test_ctmodel.py
... ... @@ -22,9 +22,9 @@ import gammalib
22 22 import ctools
23 23  
24 24  
25   -# ============================ #
26   -# Test class for ctobssim tool #
27   -# ============================ #
  25 +# =========================== #
  26 +# Test class for ctmodel tool #
  27 +# =========================== #
28 28 class Test(gammalib.GPythonTestSuite):
29 29 """
30 30 Test class for ctmodel tool.
... ...
test/test_ctools.sh
... ... @@ -42,6 +42,7 @@ ctselect=../src/ctselect/ctselect
42 42 ctskymap=../src/ctskymap/ctskymap
43 43 ctexpcube=../src/ctexpcube/ctexpcube
44 44 ctpsfcube=../src/ctpsfcube/ctpsfcube
  45 +ctbkgcube=../src/ctbkgcube/ctbkgcube
45 46 ctcubemask=../src/ctcubemask/ctcubemask
46 47  
47 48  
... ... @@ -444,6 +445,51 @@ $ECHO &quot; ok&quot;
444 445  
445 446  
446 447 #
  448 +# Test ctbkgcube
  449 +# ==============
  450 +$ECHO -n "Test ctbkgcube: "
  451 +#
  452 +# Run 1
  453 +$ctbkgcube infile="data/crab_events.fits" \
  454 + bkgmdl="data/crab.xml" \
  455 + cntmap="NONE" \
  456 + outfile="bkgcube1.fits" \
  457 + emin=0.1 \
  458 + emax=100.0 \
  459 + enumbins=20 \
  460 + nxpix=10 \
  461 + nypix=10 \
  462 + binsz=0.4 \
  463 + coordsys="CEL" \
  464 + xref=83.63 \
  465 + yref=22.01 \
  466 + proj="CAR"
  467 +$ECHO -n "."
  468 +if [ -s "bkgcube1.fits" ]
  469 +then
  470 + $ECHO -n "."
  471 +else
  472 + $ECHO " bkgcube1.fits file is not valid"
  473 + exit 1
  474 +fi
  475 +#
  476 +# Run 2
  477 +$ctbkgcube infile="data/crab_events.fits" \
  478 + bkgmdl="data/crab.xml" \
  479 + cntmap="data/crab_cntmap.fits" \
  480 + outfile="bkgcube2.fits"
  481 +$ECHO -n "."
  482 +if [ -s "bkgcube2.fits" ]
  483 +then
  484 + $ECHO -n "."
  485 +else
  486 + $ECHO " bkgcube2.fits file is not valid"
  487 + exit 1
  488 +fi
  489 +$ECHO " ok"
  490 +
  491 +
  492 +#
447 493 # Test ctcubemask
448 494 # ===============
449 495 $ECHO -n "Test ctcubemask: "
... ...
test/test_ctpsfcube.py
... ... @@ -22,9 +22,9 @@ import gammalib
22 22 import ctools
23 23  
24 24  
25   -# ============================ #
26   -# Test class for ctobssim tool #
27   -# ============================ #
  25 +# ============================= #
  26 +# Test class for ctpsfcube tool #
  27 +# ============================= #
28 28 class Test(gammalib.GPythonTestSuite):
29 29 """
30 30 Test class for ctpsfcube tool.
... ...
test/test_ctselect.py
... ... @@ -23,7 +23,7 @@ import ctools
23 23  
24 24  
25 25 # ============================ #
26   -# Test class for ctobssim tool #
  26 +# Test class for ctselect tool #
27 27 # ============================ #
28 28 class Test(gammalib.GPythonTestSuite):
29 29 """
... ...
test/test_ctskymap.py
... ... @@ -23,7 +23,7 @@ import ctools
23 23  
24 24  
25 25 # ============================ #
26   -# Test class for ctobssim tool #
  26 +# Test class for ctskymap tool #
27 27 # ============================ #
28 28 class Test(gammalib.GPythonTestSuite):
29 29 """
... ...
test/test_python.py
... ... @@ -28,9 +28,10 @@ import test_ctbin
28 28 import test_ctlike
29 29 import test_ctmodel
30 30 import test_ctskymap
31   -import test_ctcubemask
32 31 import test_ctexpcube
33 32 import test_ctpsfcube
  33 +import test_ctbkgcube
  34 +import test_ctcubemask
34 35 import test_pipelines
35 36  
36 37  
... ... @@ -51,9 +52,10 @@ if __name__ == &#39;__main__&#39;:
51 52 suite_ctlike = test_ctlike.Test()
52 53 suite_ctmodel = test_ctmodel.Test()
53 54 suite_ctskymap = test_ctskymap.Test()
54   - suite_ctcubemask = test_ctcubemask.Test()
55 55 suite_ctexpcube = test_ctexpcube.Test()
56 56 suite_ctpsfcube = test_ctpsfcube.Test()
  57 + suite_ctbkgcube = test_ctbkgcube.Test()
  58 + suite_ctcubemask = test_ctcubemask.Test()
57 59 suite_pipelines = test_pipelines.Test()
58 60  
59 61 # Setup unit tests
... ... @@ -63,9 +65,10 @@ if __name__ == &#39;__main__&#39;:
63 65 suite_ctlike.set()
64 66 suite_ctmodel.set()
65 67 suite_ctskymap.set()
66   - suite_ctcubemask.set()
67 68 suite_ctexpcube.set()
68 69 suite_ctpsfcube.set()
  70 + suite_ctbkgcube.set()
  71 + suite_ctcubemask.set()
69 72 suite_pipelines.set()
70 73  
71 74 # Append tests to container
... ... @@ -75,9 +78,10 @@ if __name__ == &#39;__main__&#39;:
75 78 suites.append(suite_ctlike)
76 79 suites.append(suite_ctmodel)
77 80 suites.append(suite_ctskymap)
78   - suites.append(suite_ctcubemask)
79 81 suites.append(suite_ctexpcube)
80 82 suites.append(suite_ctpsfcube)
  83 + suites.append(suite_ctbkgcube)
  84 + suites.append(suite_ctcubemask)
81 85 suites.append(suite_pipelines)
82 86  
83 87 # Set PFILES environment variable
... ...