Commit 591cfd995b4cc026983ecc1c1ba4ff7a900cadfe

Authored by Jürgen Knödlseder
1 parent 04b1443d

Fix exception when calling ctools clear() methods (#1835)

ChangeLog
1   -2016-07-31
  1 +2016-08-04
2 2  
3 3 * Version 1.2.0 released
4 4 ========================
5 5  
  6 + Fix exception when calling ctools clear() methods (#1835)
6 7 Add support modules to cscripts (#1830)
7 8 Fix lacking coverage measure for cscripts execution (#1827)
8 9 Set "addbounds" parameters by default to "no" (#1819)
... ...
1 1 New Features and Important Changes in ctools 1.2.0
2 2  
3   -31 July 2016
  3 +4 August 2016
4 4  
5 5  
6 6 Introduction
... ... @@ -27,82 +27,106 @@ None
27 27  
28 28 ctobssim - CTA observation simulation
29 29 -------------------------------------
30   -None
  30 +The clear() method now calls GApplication::clear() to conserve the properties
  31 +of the tool (#1835).
31 32  
32 33  
33 34 ctselect - CTA event selection
34 35 ------------------------------
35   -None
  36 +The clear() method now calls GApplication::clear() to conserve the properties
  37 +of the tool (#1835).
36 38  
37 39  
38 40 ctbin - CTA event binning
39 41 -------------------------
40   -None
  42 +The clear() method now calls GApplication::clear() to conserve the properties
  43 +of the tool (#1835).
41 44  
42 45  
43 46 ctlike - Maximum likelihood fitting
44 47 -----------------------------------
45   -None
  48 +The clear() method now calls GApplication::clear() to conserve the properties
  49 +of the tool (#1835).
46 50  
47 51  
48 52 cttsmap - Generation of Test Statistic map
49 53 ------------------------------------------
50   -None
  54 +The clear() method now calls GApplication::clear() to conserve the properties
  55 +of the tool (#1835).
51 56  
52 57  
53 58 ctskymap - CTA sky mapping
54 59 --------------------------
55   -None
  60 +The clear() method now calls GApplication::clear() to conserve the properties
  61 +of the tool (#1835).
56 62  
57 63  
58 64 ctmodel - CTA counts cube modelling
59 65 -----------------------------------
60   -None
  66 +The clear() method now calls GApplication::clear() to conserve the properties
  67 +of the tool (#1835).
61 68  
62 69  
63 70 ctexpcube - CTA exposure cube generation
64 71 ----------------------------------------
65 72 Set hidden "addbounds" parameter by default to "no" (#1819).
66 73  
  74 +The clear() method now calls GApplication::clear() to conserve the properties
  75 +of the tool (#1835).
  76 +
67 77  
68 78 ctpsfcube - CTA point spread function cube generation
69 79 -----------------------------------------------------
70 80 Set hidden "addbounds" parameter by default to "no" (#1819).
71 81  
  82 +The clear() method now calls GApplication::clear() to conserve the properties
  83 +of the tool (#1835).
  84 +
72 85  
73 86 ctedispcube - CTA energy dispersion cube generation
74 87 ---------------------------------------------------
75 88 Set hidden "addbounds" parameter by default to "no" (#1819).
76 89  
  90 +The clear() method now calls GApplication::clear() to conserve the properties
  91 +of the tool (#1835).
  92 +
77 93  
78 94 ctbkgcube - CTA background cube generation
79 95 ------------------------------------------
80 96 Set hidden "addbounds" parameter by default to "no" (#1819).
81 97  
  98 +The clear() method now calls GApplication::clear() to conserve the properties
  99 +of the tool (#1835).
  100 +
82 101  
83 102 ctmapcube - CTA map cube generation
84 103 -----------------------------------
85   -None
  104 +The clear() method now calls GApplication::clear() to conserve the properties
  105 +of the tool (#1835).
86 106  
87 107  
88 108 ctcubemask - CTA cube filtering
89 109 -------------------------------
90   -None
  110 +The clear() method now calls GApplication::clear() to conserve the properties
  111 +of the tool (#1835).
91 112  
92 113  
93 114 ctbutterfly - Generate butterfly diagrams
94 115 -----------------------------------------
95   -None
  116 +The clear() method now calls GApplication::clear() to conserve the properties
  117 +of the tool (#1835).
96 118  
97 119  
98 120 ctulimit - Compute upper limit
99 121 ------------------------------
100   -None
  122 +The clear() method now calls GApplication::clear() to conserve the properties
  123 +of the tool (#1835).
101 124  
102 125  
103 126 cterror - Likelihood profile error computation
104 127 ----------------------------------------------
105   -None
  128 +The clear() method now calls GApplication::clear() to conserve the properties
  129 +of the tool (#1835).
106 130  
107 131  
108 132 cscripts
... ...
README.md
1 1 ctools information
2 2 ==================
3   -* Version: 1.2.0.dev1 (31 July 2016)
  3 +* Version: 1.2.0.dev1 (4 August 2016)
4 4 * Author: Juergen Knoedlseder (jurgen.knodlseder@irap.omp.eu)
5 5 * GammaLib dependency: 1.2.0.dev1
6 6  
... ...
src/ctbin/ctbin.cpp
... ... @@ -195,13 +195,17 @@ void ctbin::clear(void)
195 195 // Free members
196 196 free_members();
197 197 this->ctool::free_members();
198   - this->GApplication::free_members();
  198 +
  199 + // Clear base class (needed to conserve tool name and version)
  200 + this->GApplication::clear();
199 201  
200 202 // Initialise members
201   - this->GApplication::init_members();
202 203 this->ctool::init_members();
203 204 init_members();
204 205  
  206 + // Write header into logger
  207 + log_header();
  208 +
205 209 // Return
206 210 return;
207 211 }
... ...
src/ctbkgcube/ctbkgcube.cpp
... ... @@ -175,20 +175,26 @@ ctbkgcube& ctbkgcube::operator=(const ctbkgcube& app)
175 175 ==========================================================================*/
176 176  
177 177 /***********************************************************************//**
178   - * @brief Clear instance
  178 + * @brief Clear ctbkgcube tool
  179 + *
  180 + * Clears ctbkgcube tool.
179 181 ***************************************************************************/
180 182 void ctbkgcube::clear(void)
181 183 {
182 184 // Free members
183 185 free_members();
184 186 this->ctool::free_members();
185   - this->GApplication::free_members();
  187 +
  188 + // Clear base class (needed to conserve tool name and version)
  189 + this->GApplication::clear();
186 190  
187 191 // Initialise members
188   - this->GApplication::init_members();
189 192 this->ctool::init_members();
190 193 init_members();
191 194  
  195 + // Write header into logger
  196 + log_header();
  197 +
192 198 // Return
193 199 return;
194 200 }
... ...
src/ctbutterfly/ctbutterfly.cpp
... ... @@ -176,20 +176,26 @@ ctbutterfly& ctbutterfly::operator=(const ctbutterfly& app)
176 176 ==========================================================================*/
177 177  
178 178 /***********************************************************************//**
179   - * @brief Clear instance
  179 + * @brief Clear ctbutterfly tool
  180 + *
  181 + * Clears ctbutterfly tool.
180 182 ***************************************************************************/
181 183 void ctbutterfly::clear(void)
182 184 {
183 185 // Free members
184 186 free_members();
185 187 this->ctool::free_members();
186   - this->GApplication::free_members();
  188 +
  189 + // Clear base class (needed to conserve tool name and version)
  190 + this->GApplication::clear();
187 191  
188 192 // Initialise members
189   - this->GApplication::init_members();
190 193 this->ctool::init_members();
191 194 init_members();
192 195  
  196 + // Write header into logger
  197 + log_header();
  198 +
193 199 // Return
194 200 return;
195 201 }
... ... @@ -313,10 +319,6 @@ void ctbutterfly::run(void)
313 319 double cov_pg = m_covariance(inx_prefactor,inx_index);
314 320 double cov_gg = m_covariance(inx_index,inx_index);
315 321  
316   - // Initialise min and max intensities
317   - m_min_intensities.assign(m_ebounds.size(), 1e30);
318   - m_max_intensities.assign(m_ebounds.size(), 0.0);
319   -
320 322 // Compute eigenvectors and eigenvalues
321 323 double lambda1;
322 324 double lambda2;
... ... @@ -346,6 +348,12 @@ void ctbutterfly::run(void)
346 348 // Write header into logger
347 349 log_header1(TERSE, "Generate butterfly");
348 350  
  351 + // Initialise result arrays
  352 + m_energies.assign(m_ebounds.size(), 0.0);
  353 + m_intensities.assign(m_ebounds.size(), 0.0);
  354 + m_min_intensities.assign(m_ebounds.size(), 1e30);
  355 + m_max_intensities.assign(m_ebounds.size(), 0.0);
  356 +
349 357 // Walk around the error ellipse
350 358 int nt = 360;
351 359 double dt = gammalib::twopi/double(nt);
... ... @@ -382,7 +390,7 @@ void ctbutterfly::run(void)
382 390  
383 391 // Evaluate power law
384 392 double intensity = plaw.eval(energy, time);
385   -
  393 +
386 394 // Get extremes
387 395 if (intensity < m_min_intensities[k]) {
388 396 m_min_intensities[k] = intensity;
... ... @@ -395,13 +403,10 @@ void ctbutterfly::run(void)
395 403  
396 404 } // endfor: looped over all angles
397 405  
398   - // Write header into logger
399   - log_header1(TERSE, "Results");
400   -
401   - // Setup power law model
  406 + // Setup power law model for mean prefactor and index
402 407 GModelSpectralPlaw plaw(prefactor_mean, index_mean, pivot);
403 408  
404   - // Show results
  409 + // Compute energy and intensity vectors for mean power law
405 410 for (int k = 0; k < m_ebounds.size(); ++k) {
406 411  
407 412 // Get the energy of current bin
... ... @@ -412,16 +417,24 @@ void ctbutterfly::run(void)
412 417 double intensity = plaw.eval(energy, time);
413 418  
414 419 // Store results
415   - m_energies.push_back(energy.MeV());
416   - m_intensities.push_back(intensity);
  420 + m_energies[k] = energy.MeV();
  421 + m_intensities[k] = intensity;
  422 +
  423 + } // endfor: looped over energies
  424 +
  425 + // Write header into logger
  426 + log_header1(TERSE, "Results");
  427 +
  428 + // Show results
  429 + for (int k = 0; k < m_ebounds.size(); ++k) {
417 430  
418 431 // Write results into logger
419   - log_value(NORMAL, "Intensity at "+energy.print(),
420   - gammalib::str(intensity)+" ("+
  432 + log_value(NORMAL, "Intensity at "+gammalib::str(m_energies[k])+" MeV",
  433 + gammalib::str(m_intensities[k])+" ("+
421 434 gammalib::str(m_min_intensities[k])+", "+
422 435 gammalib::str(m_max_intensities[k])+") ph/cm2/s/MeV");
423 436  
424   - } // endfor
  437 + } // endfor: looped over energies
425 438  
426 439 // Restore energy dispersion flag for all CTA observations
427 440 for (int i = 0; i < m_obs.size(); ++i) {
... ...
src/ctcubemask/ctcubemask.cpp
... ... @@ -177,20 +177,26 @@ ctcubemask&amp; ctcubemask::operator=(const ctcubemask&amp; app)
177 177 ==========================================================================*/
178 178  
179 179 /***********************************************************************//**
180   - * @brief Clear instance
  180 + * @brief Clear ctcubemask tool
  181 + *
  182 + * Clears ctcubemask tool.
181 183 ***************************************************************************/
182 184 void ctcubemask::clear(void)
183 185 {
184 186 // Free members
185 187 free_members();
186 188 this->ctool::free_members();
187   - this->GApplication::free_members();
  189 +
  190 + // Clear base class (needed to conserve tool name and version)
  191 + this->GApplication::clear();
188 192  
189 193 // Initialise members
190   - this->GApplication::init_members();
191 194 this->ctool::init_members();
192 195 init_members();
193 196  
  197 + // Write header into logger
  198 + log_header();
  199 +
194 200 // Return
195 201 return;
196 202 }
... ...
src/ctedispcube/ctedispcube.cpp
... ... @@ -195,13 +195,17 @@ void ctedispcube::clear(void)
195 195 // Free members
196 196 free_members();
197 197 this->ctool::free_members();
198   - this->GApplication::free_members();
  198 +
  199 + // Clear base class (needed to conserve tool name and version)
  200 + this->GApplication::clear();
199 201  
200 202 // Initialise members
201   - this->GApplication::init_members();
202 203 this->ctool::init_members();
203 204 init_members();
204 205  
  206 + // Write header into logger
  207 + log_header();
  208 +
205 209 // Return
206 210 return;
207 211 }
... ...
src/cterror/cterror.cpp
... ... @@ -188,22 +188,26 @@ cterror&amp; cterror::operator=(const cterror&amp; app)
188 188 ==========================================================================*/
189 189  
190 190 /***********************************************************************//**
191   - * @brief Clear instance
  191 + * @brief Clear cterror tool
192 192 *
193   - * Resets the cterror tool to a clean initial state.
  193 + * Clears cterror tool.
194 194 ***************************************************************************/
195 195 void cterror::clear(void)
196 196 {
197 197 // Free members
198 198 free_members();
199 199 this->ctool::free_members();
200   - this->GApplication::free_members();
  200 +
  201 + // Clear base class (needed to conserve tool name and version)
  202 + this->GApplication::clear();
201 203  
202 204 // Initialise members
203   - this->GApplication::init_members();
204 205 this->ctool::init_members();
205 206 init_members();
206 207  
  208 + // Write header into logger
  209 + log_header();
  210 +
207 211 // Return
208 212 return;
209 213 }
... ...
src/ctexpcube/ctexpcube.cpp
... ... @@ -175,20 +175,26 @@ ctexpcube&amp; ctexpcube::operator=(const ctexpcube&amp; app)
175 175 ==========================================================================*/
176 176  
177 177 /***********************************************************************//**
178   - * @brief Clear instance
  178 + * @brief Clear ctexpcube tool
  179 + *
  180 + * Clears ctexpcube tool.
179 181 ***************************************************************************/
180 182 void ctexpcube::clear(void)
181 183 {
182 184 // Free members
183 185 free_members();
184 186 this->ctool::free_members();
185   - this->GApplication::free_members();
  187 +
  188 + // Clear base class (needed to conserve tool name and version)
  189 + this->GApplication::clear();
186 190  
187 191 // Initialise members
188   - this->GApplication::init_members();
189 192 this->ctool::init_members();
190 193 init_members();
191 194  
  195 + // Write header into logger
  196 + log_header();
  197 +
192 198 // Return
193 199 return;
194 200 }
... ...
src/ctlike/ctlike.cpp
... ... @@ -171,20 +171,26 @@ ctlike&amp; ctlike::operator=(const ctlike&amp; app)
171 171 ==========================================================================*/
172 172  
173 173 /***********************************************************************//**
174   - * @brief Clear instance
  174 + * @brief Clear ctlike tool
  175 + *
  176 + * Clears ctlike tool.
175 177 ***************************************************************************/
176 178 void ctlike::clear(void)
177 179 {
178 180 // Free members
179 181 free_members();
180 182 this->ctool::free_members();
181   - this->GApplication::free_members();
  183 +
  184 + // Clear base class (needed to conserve tool name and version)
  185 + this->GApplication::clear();
182 186  
183 187 // Initialise members
184   - this->GApplication::init_members();
185 188 this->ctool::init_members();
186 189 init_members();
187 190  
  191 + // Write header into logger
  192 + log_header();
  193 +
188 194 // Return
189 195 return;
190 196 }
... ...
src/ctmapcube/ctmapcube.cpp
... ... @@ -151,20 +151,26 @@ ctmapcube&amp; ctmapcube::operator=(const ctmapcube&amp; app)
151 151 ==========================================================================*/
152 152  
153 153 /***********************************************************************//**
154   - * @brief Clear tool
  154 + * @brief Clear ctmapcube tool
  155 + *
  156 + * Clears ctmapcube tool.
155 157 ***************************************************************************/
156 158 void ctmapcube::clear(void)
157 159 {
158 160 // Free members
159 161 free_members();
160 162 this->ctool::free_members();
161   - this->GApplication::free_members();
  163 +
  164 + // Clear base class (needed to conserve tool name and version)
  165 + this->GApplication::clear();
162 166  
163 167 // Initialise members
164   - this->GApplication::init_members();
165 168 this->ctool::init_members();
166 169 init_members();
167 170  
  171 + // Write header into logger
  172 + log_header();
  173 +
168 174 // Return
169 175 return;
170 176 }
... ...
src/ctmodel/ctmodel.cpp
... ... @@ -175,20 +175,26 @@ ctmodel&amp; ctmodel::operator=(const ctmodel&amp; app)
175 175 ==========================================================================*/
176 176  
177 177 /***********************************************************************//**
178   - * @brief Clear instance
  178 + * @brief Clear ctmodel tool
  179 + *
  180 + * Clears ctmodel tool.
179 181 ***************************************************************************/
180 182 void ctmodel::clear(void)
181 183 {
182 184 // Free members
183 185 free_members();
184 186 this->ctool::free_members();
185   - this->GApplication::free_members();
  187 +
  188 + // Clear base class (needed to conserve tool name and version)
  189 + this->GApplication::clear();
186 190  
187 191 // Initialise members
188   - this->GApplication::init_members();
189 192 this->ctool::init_members();
190 193 init_members();
191 194  
  195 + // Write header into logger
  196 + log_header();
  197 +
192 198 // Return
193 199 return;
194 200 }
... ...
src/ctobssim/ctobssim.cpp
... ... @@ -203,13 +203,17 @@ void ctobssim::clear(void)
203 203 // Free members
204 204 free_members();
205 205 this->ctool::free_members();
206   - this->GApplication::free_members();
  206 +
  207 + // Clear base class (needed to conserve tool name and version)
  208 + this->GApplication::clear();
207 209  
208 210 // Initialise members
209   - this->GApplication::init_members();
210 211 this->ctool::init_members();
211 212 init_members();
212 213  
  214 + // Write header into logger
  215 + log_header();
  216 +
213 217 // Return
214 218 return;
215 219 }
... ...
src/ctpsfcube/ctpsfcube.cpp
... ... @@ -174,20 +174,26 @@ ctpsfcube&amp; ctpsfcube::operator=(const ctpsfcube&amp; app)
174 174 ==========================================================================*/
175 175  
176 176 /***********************************************************************//**
177   - * @brief Clear instance
  177 + * @brief Clear ctpsfcube tool
  178 + *
  179 + * Clears ctpsfcube tool.
178 180 ***************************************************************************/
179 181 void ctpsfcube::clear(void)
180 182 {
181 183 // Free members
182 184 free_members();
183 185 this->ctool::free_members();
184   - this->GApplication::free_members();
  186 +
  187 + // Clear base class (needed to conserve tool name and version)
  188 + this->GApplication::clear();
185 189  
186 190 // Initialise members
187   - this->GApplication::init_members();
188 191 this->ctool::init_members();
189 192 init_members();
190 193  
  194 + // Write header into logger
  195 + log_header();
  196 +
191 197 // Return
192 198 return;
193 199 }
... ...
src/ctselect/ctselect.cpp
... ... @@ -179,20 +179,26 @@ ctselect&amp; ctselect::operator=(const ctselect&amp; app)
179 179 ==========================================================================*/
180 180  
181 181 /***********************************************************************//**
182   - * @brief Clear instance
  182 + * @brief Clear ctselect tool
  183 + *
  184 + * Clears ctselect tool.
183 185 ***************************************************************************/
184 186 void ctselect::clear(void)
185 187 {
186 188 // Free members
187 189 free_members();
188 190 this->ctool::free_members();
189   - this->GApplication::free_members();
  191 +
  192 + // Clear base class (needed to conserve tool name and version)
  193 + this->GApplication::clear();
190 194  
191 195 // Initialise members
192   - this->GApplication::init_members();
193 196 this->ctool::init_members();
194 197 init_members();
195 198  
  199 + // Write header into logger
  200 + log_header();
  201 +
196 202 // Return
197 203 return;
198 204 }
... ...
src/ctskymap/ctskymap.cpp
... ... @@ -175,20 +175,26 @@ ctskymap&amp; ctskymap::operator=(const ctskymap&amp; app)
175 175 ==========================================================================*/
176 176  
177 177 /***********************************************************************//**
178   - * @brief Clear instance
  178 + * @brief Clear ctskymap tool
  179 + *
  180 + * Clears ctskymap tool.
179 181 ***************************************************************************/
180 182 void ctskymap::clear(void)
181 183 {
182 184 // Free members
183 185 free_members();
184 186 this->ctool::free_members();
185   - this->GApplication::free_members();
  187 +
  188 + // Clear base class (needed to conserve tool name and version)
  189 + this->GApplication::clear();
186 190  
187 191 // Initialise members
188   - this->GApplication::init_members();
189 192 this->ctool::init_members();
190 193 init_members();
191 194  
  195 + // Write header into logger
  196 + log_header();
  197 +
192 198 // Return
193 199 return;
194 200 }
... ...
src/cttsmap/cttsmap.cpp
... ... @@ -173,20 +173,26 @@ cttsmap&amp; cttsmap::operator=(const cttsmap&amp; app)
173 173 ==========================================================================*/
174 174  
175 175 /***********************************************************************//**
176   - * @brief Clear instance
  176 + * @brief Clear cttsmap tool
  177 + *
  178 + * Clears cttsmap tool.
177 179 ***************************************************************************/
178 180 void cttsmap::clear(void)
179 181 {
180 182 // Free members
181 183 free_members();
182 184 this->ctool::free_members();
183   - this->GApplication::free_members();
  185 +
  186 + // Clear base class (needed to conserve tool name and version)
  187 + this->GApplication::clear();
184 188  
185 189 // Initialise members
186   - this->GApplication::init_members();
187 190 this->ctool::init_members();
188 191 init_members();
189 192  
  193 + // Write header into logger
  194 + log_header();
  195 +
190 196 // Return
191 197 return;
192 198 }
... ...
src/ctulimit/ctulimit.cpp
... ... @@ -198,13 +198,17 @@ void ctulimit::clear(void)
198 198 // Free members
199 199 free_members();
200 200 this->ctool::free_members();
201   - this->GApplication::free_members();
  201 +
  202 + // Clear base class (needed to conserve tool name and version)
  203 + this->GApplication::clear();
202 204  
203 205 // Initialise members
204   - this->GApplication::init_members();
205 206 this->ctool::init_members();
206 207 init_members();
207 208  
  209 + // Write header into logger
  210 + log_header();
  211 +
208 212 // Return
209 213 return;
210 214 }
... ...
src/support/ctool.cpp
... ... @@ -276,9 +276,7 @@ void ctool::copy_members(const ctool&amp; app)
276 276 void ctool::free_members(void)
277 277 {
278 278 // Write separator into logger
279   - if (logTerse()) {
280   - log << std::endl;
281   - }
  279 + log_string(TERSE, "\n");
282 280  
283 281 // Return
284 282 return;
... ...
test/test_ctbin.py
... ... @@ -179,14 +179,14 @@ class Test(test):
179 179 self._check_cube(evt, 5542)
180 180  
181 181 # Now clear ctbin tool
182   - #bin.clear() # Segfaults, see issue #1835
  182 + bin.clear()
183 183  
184 184 # Check that cleared ctbin has an empty observation container and
185 185 # counts cube
186   - #self.test_value(bin.obs().size(), 0,
187   - # 'Check that empty ctbin has an empty observation container')
188   - #self.test_value(bin.cube().size(), 0,
189   - # 'Check that empty ctbin has an empty counts cube')
  186 + self.test_value(bin.obs().size(), 0,
  187 + 'Check that empty ctbin has an empty observation container')
  188 + self.test_value(bin.cube().size(), 0,
  189 + 'Check that empty ctbin has an empty counts cube')
190 190  
191 191 # Prepare observation container for stacked analysis
192 192 cta = gammalib.GCTAObservation(self._events)
... ...
test/test_ctbkgcube.py
... ... @@ -116,8 +116,6 @@ class Test(test):
116 116 bkgcube['inobs'] = self._events
117 117 bkgcube['inmodel'] = self._model
118 118 bkgcube['incube'] = 'NONE'
119   - bkgcube['outcube'] = 'ctbkgcube_py1.fits'
120   - bkgcube['outmodel'] = 'ctbkgcube_py1.xml'
121 119 bkgcube['caldb'] = self._caldb
122 120 bkgcube['irf'] = self._irf
123 121 bkgcube['ebinalg'] = 'LOG'
... ... @@ -131,6 +129,8 @@ class Test(test):
131 129 bkgcube['proj'] = 'CAR'
132 130 bkgcube['xref'] = 83.63
133 131 bkgcube['yref'] = 22.01
  132 + bkgcube['outcube'] = 'ctbkgcube_py1.fits'
  133 + bkgcube['outmodel'] = 'ctbkgcube_py1.xml'
134 134 bkgcube['logfile'] = 'ctbkgcube_py1.log'
135 135 bkgcube['chatter'] = 2
136 136  
... ... @@ -142,6 +142,87 @@ class Test(test):
142 142 # Check result file
143 143 self._check_result_file('ctbkgcube_py1.fits')
144 144  
  145 + # Set-up ctbkgcube from counts cube
  146 + bkgcube = ctools.ctbkgcube()
  147 + bkgcube['inobs'] = self._events
  148 + bkgcube['inmodel'] = self._model
  149 + bkgcube['incube'] = self._cntcube
  150 + bkgcube['caldb'] = self._caldb
  151 + bkgcube['irf'] = self._irf
  152 + bkgcube['outcube'] = 'ctbkgcube_py2.fits'
  153 + bkgcube['outmodel'] = 'ctbkgcube_py2.xml'
  154 + bkgcube['logfile'] = 'ctbkgcube_py2.log'
  155 + bkgcube['chatter'] = 3
  156 + bkgcube['publish'] = True
  157 + bkgcube['addbounds'] = True
  158 +
  159 + # Execute ctbkgcube tool
  160 + bkgcube.logFileOpen() # Make sure we get a log file
  161 + bkgcube.execute()
  162 +
  163 + # Check result file
  164 + self._check_result_file('ctbkgcube_py2.fits')
  165 +
  166 + # Copy ctbkgcube tool and execute copied tool
  167 + cpy_bkgcube = bkgcube
  168 + cpy_bkgcube['outcube'] = 'ctbkgcube_py3.fits'
  169 + cpy_bkgcube['outmodel'] = 'ctbkgcube_py3.xml'
  170 + cpy_bkgcube['logfile'] = 'ctbkgcube_py3.log'
  171 + cpy_bkgcube['chatter'] = 4
  172 + cpy_bkgcube.execute()
  173 +
  174 + # Check result file
  175 + self._check_result_file('ctbkgcube_py3.fits')
  176 +
  177 + # Clear ctbkgcube tool
  178 + bkgcube.clear()
  179 +
  180 + # TODO: Do some test after clearing of ctbkgcube tool
  181 +
  182 + # Prepare observation container
  183 + obs1 = gammalib.GCTAObservation(self._events)
  184 + obs2 = gammalib.GCTAObservation(self._cntcube)
  185 + obs3 = gammalib.GLATObservation()
  186 + obs1.id('0001')
  187 + obs2.id('0002')
  188 + obs3.id('0001')
  189 + obs3.events(gammalib.GLATEventList())
  190 + obs = gammalib.GObservations()
  191 + obs.append(obs1)
  192 + obs.append(obs2)
  193 + obs.append(obs3)
  194 + obs.models(gammalib.GModels(self._model))
  195 +
  196 + # Set-up ctbkgcube from observation container
  197 + bkgcube = ctools.ctbkgcube(obs)
  198 + #bkgcube['inobs'] = self._events
  199 + #bkgcube['inmodel'] = self._model
  200 + bkgcube['incube'] = 'NONE'
  201 + bkgcube['caldb'] = self._caldb
  202 + bkgcube['irf'] = self._irf
  203 + bkgcube['ebinalg'] = 'LOG'
  204 + bkgcube['emin'] = 0.1
  205 + bkgcube['emax'] = 100
  206 + bkgcube['enumbins'] = 20
  207 + bkgcube['nxpix'] = 10
  208 + bkgcube['nypix'] = 10
  209 + bkgcube['binsz'] = 0.4
  210 + bkgcube['coordsys'] = 'CEL'
  211 + bkgcube['proj'] = 'CAR'
  212 + bkgcube['xref'] = 83.63
  213 + bkgcube['yref'] = 22.01
  214 + bkgcube['outcube'] = 'ctbkgcube_py4.fits'
  215 + bkgcube['outmodel'] = 'ctbkgcube_py4.xml'
  216 + bkgcube['logfile'] = 'ctbkgcube_py4.log'
  217 + bkgcube['chatter'] = 4
  218 +
  219 + # Execute ctbkgcube tool
  220 + bkgcube.logFileOpen() # Make sure we get a log file
  221 + bkgcube.execute()
  222 +
  223 + # Check result file
  224 + self._check_result_file('ctbkgcube_py4.fits')
  225 +
145 226 # Return
146 227 return
147 228  
... ...
test/test_ctbutterfly.py
... ... @@ -138,13 +138,33 @@ class Test(test):
138 138 butterfly['logfile'] = 'ctbutterfly_py2.log'
139 139 butterfly['chatter'] = 3
140 140  
141   - # Run ctbutterfly tool
  141 + # Execute ctbutterfly tool
142 142 butterfly.logFileOpen() # Make sure we get a log file
143 143 butterfly.execute()
144 144  
145 145 # Check result file
146 146 self._check_result_file('ctbutterfly_py2.dat')
147 147  
  148 + # Recover observation container
  149 + obs = butterfly.obs()
  150 +
  151 + # TODO: Do someting test on observation container
  152 +
  153 + # Copy ctbkgcube tool and execute copy
  154 + cpy_butterfly = butterfly
  155 + cpy_butterfly['outfile'] = 'ctbutterfly_py3.dat'
  156 + cpy_butterfly['logfile'] = 'ctbutterfly_py3.log'
  157 + cpy_butterfly['chatter'] = 4
  158 + cpy_butterfly.execute()
  159 +
  160 + # Check result file
  161 + self._check_result_file('ctbutterfly_py3.dat')
  162 +
  163 + # Clear ctbkgcube tool
  164 + butterfly.clear()
  165 +
  166 + # TODO: Do some test after clearing
  167 +
148 168 # Return
149 169 return
150 170  
... ...
test/test_ctcubemask.py
... ... @@ -139,6 +139,7 @@ class Test(test):
139 139 mask['outcube'] = 'ctcubemask_py2.fits'
140 140 mask['logfile'] = 'ctcubemask_py2.log'
141 141 mask['chatter'] = 3
  142 + mask['publish'] = True
142 143  
143 144 # Execute ctcubemask tool
144 145 mask.logFileOpen() # Make sure we get a log file
... ... @@ -147,6 +148,21 @@ class Test(test):
147 148 # Check result file
148 149 self._check_result_file('ctcubemask_py2.fits', events=5542)
149 150  
  151 + # Copy ctcubemask tool and execute copy
  152 + cpy_mask = mask
  153 + cpy_mask['outcube'] = 'ctcubemask_py3.fits'
  154 + cpy_mask['logfile'] = 'ctcubemask_py3.log'
  155 + cpy_mask['chatter'] = 4
  156 + cpy_mask.execute()
  157 +
  158 + # Check result file
  159 + self._check_result_file('ctcubemask_py3.fits', events=5542)
  160 +
  161 + # Clear ctcubemask tool
  162 + mask.clear()
  163 +
  164 + # TODO: Do some test after clearing
  165 +
150 166 # Return
151 167 return
152 168  
... ...