Commit 79cbc023c773bb19d6ebd4735e18c919d18153fa

Authored by Jürgen Knödlseder
1 parent be13013c

Integrate modifications for stacked energy dispersion.

.gitignore
@@ -59,6 +59,7 @@ src/ctselect/ctselect @@ -59,6 +59,7 @@ src/ctselect/ctselect
59 src/ctskymap/ctskymap 59 src/ctskymap/ctskymap
60 src/ctexpcube/ctexpcube 60 src/ctexpcube/ctexpcube
61 src/ctpsfcube/ctpsfcube 61 src/ctpsfcube/ctpsfcube
  62 +src/ctedispcube/ctedispcube
62 src/ctbkgcube/ctbkgcube 63 src/ctbkgcube/ctbkgcube
63 src/ctcubemask/ctcubemask 64 src/ctcubemask/ctcubemask
64 src/ctbutterfly/ctbutterfly 65 src/ctbutterfly/ctbutterfly
cscripts/cslightcrv.py
@@ -40,7 +40,7 @@ class cslightcrv(ctools.cscript): @@ -40,7 +40,7 @@ class cslightcrv(ctools.cscript):
40 40
41 # Set name 41 # Set name
42 self.name = "cslightcrv" 42 self.name = "cslightcrv"
43 - self.version = "1.0.0" 43 + self.version = "1.1.0"
44 44
45 # Initialise some members 45 # Initialise some members
46 self.obs = None 46 self.obs = None
@@ -435,7 +435,7 @@ class cslightcrv(ctools.cscript): @@ -435,7 +435,7 @@ class cslightcrv(ctools.cscript):
435 435
436 # Header 436 # Header
437 if self.logTerse(): 437 if self.logTerse():
438 - self.log.header3("Creating PSF cube") 438 + self.log.header3("Creating point spread function cube")
439 439
440 # Create psf cube 440 # Create psf cube
441 psfcube = ctools.ctpsfcube(select.obs()) 441 psfcube = ctools.ctpsfcube(select.obs())
@@ -454,6 +454,30 @@ class cslightcrv(ctools.cscript): @@ -454,6 +454,30 @@ class cslightcrv(ctools.cscript):
454 psfcube["proj"] = self.m_proj 454 psfcube["proj"] = self.m_proj
455 psfcube.run() 455 psfcube.run()
456 456
  457 + # Check if we need to include energy dispersion
  458 + if self.m_edisp:
  459 +
  460 + # Header
  461 + if self.logTerse():
  462 + self.log.header3("Creating energy dispersion cube")
  463 +
  464 + # Create edisp cube
  465 + edispcube = ctools.ctedispcube(select.obs())
  466 + edispcube["incube"] = "NONE"
  467 + edispcube["usepnt"] = False
  468 + edispcube["ebinalg"] = "LOG"
  469 + edispcube["xref"] = self.m_xref
  470 + edispcube["yref"] = self.m_yref
  471 + edispcube["binsz"] = self.m_binsz
  472 + edispcube["nxpix"] = self.m_nxpix
  473 + edispcube["nypix"] = self.m_nypix
  474 + edispcube["enumbins"] = self.m_ebins
  475 + edispcube["emin"] = self.m_emin
  476 + edispcube["emax"] = self.m_emax
  477 + edispcube["coordsys"] = self.m_coordsys
  478 + edispcube["proj"] = self.m_proj
  479 + edispcube.run()
  480 +
457 # Header 481 # Header
458 if self.logTerse(): 482 if self.logTerse():
459 self.log.header3("Creating background cube") 483 self.log.header3("Creating background cube")
@@ -482,30 +506,12 @@ class cslightcrv(ctools.cscript): @@ -482,30 +506,12 @@ class cslightcrv(ctools.cscript):
482 models = bkgcube.models() 506 models = bkgcube.models()
483 507
484 # Set precomputed binned response 508 # Set precomputed binned response
485 - obs[0].response(expcube.expcube(), psfcube.psfcube(), bkgcube.bkgcube())  
486 -  
487 - # Check if we need to include energy dispersion  
488 if self.m_edisp: 509 if self.m_edisp:
489 -  
490 - # Create edisp cube  
491 - edispcube = ctools.ctedispcube(select.obs())  
492 - edispcube["incube"] = "NONE"  
493 - edispcube["usepnt"] = False  
494 - edispcube["ebinalg"] = "LOG"  
495 - edispcube["xref"] = self.m_xref  
496 - edispcube["yref"] = self.m_yref  
497 - edispcube["binsz"] = self.m_binsz  
498 - edispcube["nxpix"] = self.m_nxpix  
499 - edispcube["nypix"] = self.m_nypix  
500 - edispcube["enumbins"] = self.m_ebins  
501 - edispcube["emin"] = self.m_emin  
502 - edispcube["emax"] = self.m_emax  
503 - edispcube["coordsys"] = self.m_coordsys  
504 - edispcube["proj"] = self.m_proj  
505 - edispcube.run()  
506 -  
507 - # Set precomputed binned response including energy dispersion  
508 - obs[0].response(expcube.expcube(), psfcube.psfcube(), edispcube.edispcube(), bkgcube.bkgcube()) 510 + obs[0].response(expcube.expcube(), psfcube.psfcube(),
  511 + edispcube.edispcube(), bkgcube.bkgcube())
  512 + else:
  513 + obs[0].response(expcube.expcube(), psfcube.psfcube(),
  514 + bkgcube.bkgcube())
509 515
510 # Fix background models if required 516 # Fix background models if required
511 if self.m_fix_bkg: 517 if self.m_fix_bkg:
cscripts/cspull.py
@@ -247,10 +247,13 @@ class cspull(ctools.cscript): @@ -247,10 +247,13 @@ class cspull(ctools.cscript):
247 psfcube["proj"] = self.m_proj 247 psfcube["proj"] = self.m_proj
248 psfcube.run() 248 psfcube.run()
249 249
  250 + # Notify Psf computation
  251 + if self.logTerse():
  252 + self.log("Computed Psf cube\n")
  253 +
  254 + # Optionally get stacked Edisp
250 if self.m_edisp: 255 if self.m_edisp:
251 -  
252 - # Get stacked Edisp  
253 - edispcube = ctools.ctpsfcube(self.obs) 256 + edispcube = ctools.edispcube(self.obs)
254 edispcube["incube"] = "NONE" 257 edispcube["incube"] = "NONE"
255 edispcube["usepnt"] = True 258 edispcube["usepnt"] = True
256 edispcube["ebinalg"] = "LOG" 259 edispcube["ebinalg"] = "LOG"
@@ -263,17 +266,13 @@ class cspull(ctools.cscript): @@ -263,17 +266,13 @@ class cspull(ctools.cscript):
263 edispcube["coordsys"] = self.m_coordsys 266 edispcube["coordsys"] = self.m_coordsys
264 edispcube["proj"] = self.m_proj 267 edispcube["proj"] = self.m_proj
265 edispcube.run() 268 edispcube.run()
266 - 269 +
267 # Store result 270 # Store result
268 self.m_edispcube = edispcube.edispcube().copy() 271 self.m_edispcube = edispcube.edispcube().copy()
269 272
270 # Logging 273 # Logging
271 if self.logTerse(): 274 if self.logTerse():
272 - self.log("Computed Edisp cube\n")  
273 -  
274 - # Notify Psf computation  
275 - if self.logTerse():  
276 - self.log("Computed Psf cube\n") 275 + self.log("Computed energy dispersion cube\n")
277 276
278 # Get stacked background 277 # Get stacked background
279 bkgcube = ctools.ctbkgcube(self.obs) 278 bkgcube = ctools.ctbkgcube(self.obs)
@@ -350,7 +349,6 @@ class cspull(ctools.cscript): @@ -350,7 +349,6 @@ class cspull(ctools.cscript):
350 for n in result['colnames']: 349 for n in result['colnames']:
351 headers[n] = n 350 headers[n] = n
352 writer.writerow(headers) 351 writer.writerow(headers)
353 - #writer.writerow(dict((_,_) for _ in result['colnames']))  
354 else: 352 else:
355 file = open(self.m_outfile.url(), 'a') 353 file = open(self.m_outfile.url(), 'a')
356 writer = csv.DictWriter(file, result['colnames']) 354 writer = csv.DictWriter(file, result['colnames'])
@@ -417,9 +415,11 @@ class cspull(ctools.cscript): @@ -417,9 +415,11 @@ class cspull(ctools.cscript):
417 # If stacked, add stacked responses and model 415 # If stacked, add stacked responses and model
418 if self.obs.size() > 1 and self.m_enumbins > 0: 416 if self.obs.size() > 1 and self.m_enumbins > 0:
419 if self.m_edisp: 417 if self.m_edisp:
420 - obs[0].response(self.m_exposure, self.m_psfcube, self.m_edispcube, self.m_bckcube) 418 + obs[0].response(self.m_exposure, self.m_psfcube,
  419 + self.m_edispcube, self.m_bckcube)
421 else: 420 else:
422 - obs[0].response(self.m_exposure, self.m_psfcube, self.m_bckcube) 421 + obs[0].response(self.m_exposure, self.m_psfcube,
  422 + self.m_bckcube)
423 obs.models(self.m_stackmodels) 423 obs.models(self.m_stackmodels)
424 424
425 # Determine number of events in simulation 425 # Determine number of events in simulation
cscripts/csresmap.py
@@ -175,7 +175,6 @@ class csresmap(ctools.cscript): @@ -175,7 +175,6 @@ class csresmap(ctools.cscript):
175 # Skip ctbin step later on 175 # Skip ctbin step later on
176 self.m_skip_binning = True 176 self.m_skip_binning = True
177 177
178 -  
179 # Set models if we have none 178 # Set models if we have none
180 if self.obs.models().size() == 0: 179 if self.obs.models().size() == 0:
181 self.obs.models(self["inmodel"].filename()) 180 self.obs.models(self["inmodel"].filename())
@@ -372,7 +371,6 @@ class csresmap(ctools.cscript): @@ -372,7 +371,6 @@ class csresmap(ctools.cscript):
372 # Get model map into GSkyMap object 371 # Get model map into GSkyMap object
373 modelmap = model.cube().map().copy() 372 modelmap = model.cube().map().copy()
374 373
375 -  
376 # Store counts map as residual map. Note that we need a 374 # Store counts map as residual map. Note that we need a
377 # special construct here to avoid memory leaks. This seems 375 # special construct here to avoid memory leaks. This seems
378 # to be a SWIG feature as SWIG creates a new object when 376 # to be a SWIG feature as SWIG creates a new object when
cscripts/csspec.py
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 # ========================================================================== 2 # ==========================================================================
3 # Spectral points generation script. 3 # Spectral points generation script.
4 # 4 #
5 -# Copyright (C) 2014-2015 Michael Mayer 5 +# Copyright (C) 2014-2016 Michael Mayer
6 # 6 #
7 # This program is free software: you can redistribute it and/or modify 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 8 # it under the terms of the GNU General Public License as published by
@@ -40,7 +40,7 @@ class csspec(ctools.cscript): @@ -40,7 +40,7 @@ class csspec(ctools.cscript):
40 40
41 # Set name 41 # Set name
42 self.name = "csspec" 42 self.name = "csspec"
43 - self.version = "1.0.0" 43 + self.version = "1.1.0"
44 44
45 # Initialise some members 45 # Initialise some members
46 self.obs = gammalib.GObservations() 46 self.obs = gammalib.GObservations()
cscripts/cstsdist.py
@@ -42,7 +42,7 @@ class cstsdist(ctools.cscript): @@ -42,7 +42,7 @@ class cstsdist(ctools.cscript):
42 """ 42 """
43 # Set name 43 # Set name
44 self.name = "cstsdist" 44 self.name = "cstsdist"
45 - self.version = "1.0.0" 45 + self.version = "1.1.0"
46 46
47 # Initialise some members 47 # Initialise some members
48 self.obs = None 48 self.obs = None
src/ctbutterfly/ctbutterfly.par
@@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
5 # ------------------------------------------------------------------------- # 5 # ------------------------------------------------------------------------- #
6 # # 6 # #
7 # File: ctbutterfly # 7 # File: ctbutterfly #
8 -# Version: 1.0.0 # 8 +# Version: 1.1.0 #
9 # # 9 # #
10 # Author: Michael Mayer # 10 # Author: Michael Mayer #
11 # michael.mayer@physik.hu-berlin.de # 11 # michael.mayer@physik.hu-berlin.de #
src/ctedispcube/ctedispcube.cpp
1 /*************************************************************************** 1 /***************************************************************************
2 - * ctedispcube - EDISP cube generation tool * 2 + * ctedispcube - Energy dispersion cube generation tool *
3 * ----------------------------------------------------------------------- * 3 * ----------------------------------------------------------------------- *
4 * copyright (C) 2016 by Maria Haupt * 4 * copyright (C) 2016 by Maria Haupt *
5 * ----------------------------------------------------------------------- * 5 * ----------------------------------------------------------------------- *
@@ -20,7 +20,7 @@ @@ -20,7 +20,7 @@
20 ***************************************************************************/ 20 ***************************************************************************/
21 /** 21 /**
22 * @file ctedispcube.cpp 22 * @file ctedispcube.cpp
23 - * @brief EDISP cube generation tool implementation 23 + * @brief Energy dispersion cube generation tool implementation
24 * @author Maria Haupt 24 * @author Maria Haupt
25 */ 25 */
26 26
@@ -34,7 +34,7 @@ @@ -34,7 +34,7 @@
34 #include "GWcs.hpp" 34 #include "GWcs.hpp"
35 35
36 /* __ Method name definitions ____________________________________________ */ 36 /* __ Method name definitions ____________________________________________ */
37 -#define G_GET_PARAMETERS "ctedispcube::get_parameters()" 37 +#define G_GET_PARAMETERS "ctedispcube::get_parameters()"
38 38
39 /* __ Debug definitions __________________________________________________ */ 39 /* __ Debug definitions __________________________________________________ */
40 40
@@ -49,6 +49,8 @@ @@ -49,6 +49,8 @@
49 49
50 /***********************************************************************//** 50 /***********************************************************************//**
51 * @brief Void constructor 51 * @brief Void constructor
  52 + *
  53 + * Constructs an empty energy dispersion tool.
52 ***************************************************************************/ 54 ***************************************************************************/
53 ctedispcube::ctedispcube(void) : ctool(CTEDISPCUBE_NAME, CTEDISPCUBE_VERSION) 55 ctedispcube::ctedispcube(void) : ctool(CTEDISPCUBE_NAME, CTEDISPCUBE_VERSION)
54 { 56 {
@@ -65,11 +67,11 @@ ctedispcube::ctedispcube(void) : ctool(CTEDISPCUBE_NAME, CTEDISPCUBE_VERSION) @@ -65,11 +67,11 @@ ctedispcube::ctedispcube(void) : ctool(CTEDISPCUBE_NAME, CTEDISPCUBE_VERSION)
65 * 67 *
66 * @param[in] obs Observation container. 68 * @param[in] obs Observation container.
67 * 69 *
68 - * This method creates an instance of the class by copying an existing  
69 - * observations container. 70 + * Constructs an energy dispersion tool from the information that is provided
  71 + * in an observation container @p obs.
70 ***************************************************************************/ 72 ***************************************************************************/
71 ctedispcube::ctedispcube(const GObservations& obs) : 73 ctedispcube::ctedispcube(const GObservations& obs) :
72 - ctool(CTEDISPCUBE_NAME, CTEDISPCUBE_VERSION) 74 + ctool(CTEDISPCUBE_NAME, CTEDISPCUBE_VERSION)
73 { 75 {
74 // Initialise members 76 // Initialise members
75 init_members(); 77 init_members();
@@ -88,9 +90,12 @@ ctedispcube::ctedispcube(const GObservations& obs) : @@ -88,9 +90,12 @@ ctedispcube::ctedispcube(const GObservations& obs) :
88 * 90 *
89 * @param[in] argc Number of arguments in command line. 91 * @param[in] argc Number of arguments in command line.
90 * @param[in] argv Array of command line arguments. 92 * @param[in] argv Array of command line arguments.
  93 + *
  94 + * Constructs an energy dispersion tool by parsing the arguments provided
  95 + * on the command line.
91 ***************************************************************************/ 96 ***************************************************************************/
92 ctedispcube::ctedispcube(int argc, char *argv[]) : 97 ctedispcube::ctedispcube(int argc, char *argv[]) :
93 - ctool(CTEDISPCUBE_NAME, CTEDISPCUBE_VERSION, argc, argv) 98 + ctool(CTEDISPCUBE_NAME, CTEDISPCUBE_VERSION, argc, argv)
94 { 99 {
95 // Initialise members 100 // Initialise members
96 init_members(); 101 init_members();
@@ -103,7 +108,10 @@ ctedispcube::ctedispcube(int argc, char *argv[]) : @@ -103,7 +108,10 @@ ctedispcube::ctedispcube(int argc, char *argv[]) :
103 /***********************************************************************//** 108 /***********************************************************************//**
104 * @brief Copy constructor 109 * @brief Copy constructor
105 * 110 *
106 - * @param[in] app Application. 111 + * @param[in] app Energy dispersion tool.
  112 + *
  113 + * Constructs an energy dispersion tool by copying anothere energy
  114 + * dispersion tool.
107 ***************************************************************************/ 115 ***************************************************************************/
108 ctedispcube::ctedispcube(const ctedispcube& app) : ctool(app) 116 ctedispcube::ctedispcube(const ctedispcube& app) : ctool(app)
109 { 117 {
@@ -120,6 +128,8 @@ ctedispcube::ctedispcube(const ctedispcube& app) : ctool(app) @@ -120,6 +128,8 @@ ctedispcube::ctedispcube(const ctedispcube& app) : ctool(app)
120 128
121 /***********************************************************************//** 129 /***********************************************************************//**
122 * @brief Destructor 130 * @brief Destructor
  131 + *
  132 + * Desctructs an energy dispersion tool.
123 ***************************************************************************/ 133 ***************************************************************************/
124 ctedispcube::~ctedispcube(void) 134 ctedispcube::~ctedispcube(void)
125 { 135 {
@@ -140,8 +150,10 @@ ctedispcube::~ctedispcube(void) @@ -140,8 +150,10 @@ ctedispcube::~ctedispcube(void)
140 /***********************************************************************//** 150 /***********************************************************************//**
141 * @brief Assignment operator 151 * @brief Assignment operator
142 * 152 *
143 - * @param[in] app Application.  
144 - * @return Application. 153 + * @param[in] app Energy dispersion tool.
  154 + * @return Energy dispersion tool.
  155 + *
  156 + * Assigns energy dispersion tool.
145 ***************************************************************************/ 157 ***************************************************************************/
146 ctedispcube& ctedispcube::operator=(const ctedispcube& app) 158 ctedispcube& ctedispcube::operator=(const ctedispcube& app)
147 { 159 {
@@ -174,7 +186,9 @@ ctedispcube& ctedispcube::operator=(const ctedispcube& app) @@ -174,7 +186,9 @@ ctedispcube& ctedispcube::operator=(const ctedispcube& app)
174 ==========================================================================*/ 186 ==========================================================================*/
175 187
176 /***********************************************************************//** 188 /***********************************************************************//**
177 - * @brief Clear instance 189 + * @brief Clear energy dispersion tool
  190 + *
  191 + * Set the energy disperison tool to an empty tool.
178 ***************************************************************************/ 192 ***************************************************************************/
179 void ctedispcube::clear(void) 193 void ctedispcube::clear(void)
180 { 194 {
@@ -194,11 +208,10 @@ void ctedispcube::clear(void) @@ -194,11 +208,10 @@ void ctedispcube::clear(void)
194 208
195 209
196 /***********************************************************************//** 210 /***********************************************************************//**
197 - * @brief Generate the model map(s) 211 + * @brief Generate the energy dispersion cube
198 * 212 *
199 - * This method reads the task parameters from the parfile, sets up the  
200 - * observation container, loops over all CTA observations in the container  
201 - * and generates an EDISP cube from the CTA observations. 213 + * Generates the energy dispersion cube by looping over all unbinned CTA
  214 + * observations in the observation container.
202 ***************************************************************************/ 215 ***************************************************************************/
203 void ctedispcube::run(void) 216 void ctedispcube::run(void)
204 { 217 {
@@ -231,7 +244,7 @@ void ctedispcube::run(void) @@ -231,7 +244,7 @@ void ctedispcube::run(void)
231 // Write header 244 // Write header
232 if (logTerse()) { 245 if (logTerse()) {
233 log << std::endl; 246 log << std::endl;
234 - log.header1("Generate EDISP cube"); 247 + log.header1("Generate energy dispersion cube");
235 } 248 }
236 249
237 // Fill Edisp 250 // Fill Edisp
@@ -243,7 +256,10 @@ void ctedispcube::run(void) @@ -243,7 +256,10 @@ void ctedispcube::run(void)
243 256
244 257
245 /***********************************************************************//** 258 /***********************************************************************//**
246 - * @brief Save Edisp cube 259 + * @brief Save energy dispersion cube
  260 + *
  261 + * Saves the energy dispersion cube in a FITS file. The FITS filename is
  262 + * provided by the "outcube" parameter.
247 ***************************************************************************/ 263 ***************************************************************************/
248 void ctedispcube::save(void) 264 void ctedispcube::save(void)
249 { 265 {
@@ -261,11 +277,11 @@ void ctedispcube::save(void) @@ -261,11 +277,11 @@ void ctedispcube::save(void)
261 277
262 // Log filename 278 // Log filename
263 if (logTerse()) { 279 if (logTerse()) {
264 - log << "Save Edisp cube into file \""+m_outcube+"\"."; 280 + log << "Save energy dispersion cube into file \""+m_outcube+"\".";
265 log << std::endl; 281 log << std::endl;
266 } 282 }
267 283
268 - // Save EDISP cube 284 + // Save energy dispersion cube
269 m_edispcube.save(m_outcube, clobber()); 285 m_edispcube.save(m_outcube, clobber());
270 286
271 } 287 }
@@ -288,8 +304,6 @@ void ctedispcube::init_members(void) @@ -288,8 +304,6 @@ void ctedispcube::init_members(void)
288 { 304 {
289 // Initialise members 305 // Initialise members
290 m_outcube.clear(); 306 m_outcube.clear();
291 -  
292 - // Initialise protected members  
293 m_obs.clear(); 307 m_obs.clear();
294 m_edispcube.clear(); 308 m_edispcube.clear();
295 309
@@ -301,16 +315,14 @@ void ctedispcube::init_members(void) @@ -301,16 +315,14 @@ void ctedispcube::init_members(void)
301 /***********************************************************************//** 315 /***********************************************************************//**
302 * @brief Copy class members 316 * @brief Copy class members
303 * 317 *
304 - * @param[in] app Application. 318 + * @param[in] app Energy dispersion cube.
305 ***************************************************************************/ 319 ***************************************************************************/
306 void ctedispcube::copy_members(const ctedispcube& app) 320 void ctedispcube::copy_members(const ctedispcube& app)
307 { 321 {
308 - // Copy attributes  
309 - m_outcube = app.m_outcube;  
310 -  
311 - // Copy protected members  
312 - m_obs = app.m_obs;  
313 - m_edispcube = app.m_edispcube; 322 + // Copy members
  323 + m_outcube = app.m_outcube;
  324 + m_obs = app.m_obs;
  325 + m_edispcube = app.m_edispcube;
314 326
315 // Return 327 // Return
316 return; 328 return;
@@ -354,7 +366,7 @@ void ctedispcube::get_parameters(void) @@ -354,7 +366,7 @@ void ctedispcube::get_parameters(void)
354 std::string incube = (*this)["incube"].filename(); 366 std::string incube = (*this)["incube"].filename();
355 367
356 // Get additional binning parameters 368 // Get additional binning parameters
357 - double mmax = (*this)["mmax"].real(); 369 + double migramax = (*this)["migramax"].real();
358 int migrabins = (*this)["migrabins"].integer(); 370 int migrabins = (*this)["migrabins"].integer();
359 371
360 // Check for filename validity 372 // Check for filename validity
@@ -364,7 +376,7 @@ void ctedispcube::get_parameters(void) @@ -364,7 +376,7 @@ void ctedispcube::get_parameters(void)
364 GCTAEventCube cube = create_cube(m_obs); 376 GCTAEventCube cube = create_cube(m_obs);
365 377
366 // Define edisp cube 378 // Define edisp cube
367 - m_edispcube = GCTACubeEdisp(cube, mmax, migrabins); 379 + m_edispcube = GCTACubeEdisp(cube, migramax, migrabins);
368 380
369 } 381 }
370 382
@@ -375,7 +387,7 @@ void ctedispcube::get_parameters(void) @@ -375,7 +387,7 @@ void ctedispcube::get_parameters(void)
375 GCTAEventCube cube(incube); 387 GCTAEventCube cube(incube);
376 388
377 // Define Edisp cube 389 // Define Edisp cube
378 - m_edispcube = GCTACubeEdisp(cube, mmax, migrabins); 390 + m_edispcube = GCTACubeEdisp(cube, migramax, migrabins);
379 391
380 } // endelse: cube loaded from file 392 } // endelse: cube loaded from file
381 393
src/ctedispcube/ctedispcube.hpp
1 /*************************************************************************** 1 /***************************************************************************
2 - * ctedispcube - EDISP cube generation tool * 2 + * ctedispcube - Energy dispersion cube generation tool *
3 * ----------------------------------------------------------------------- * 3 * ----------------------------------------------------------------------- *
4 - * copyright (C) 2014-2016 by Chia-Chun Lu * 4 + * copyright (C) 2016 by Maria Haupt *
5 * ----------------------------------------------------------------------- * 5 * ----------------------------------------------------------------------- *
6 * * 6 * *
7 * This program is free software: you can redistribute it and/or modify * 7 * This program is free software: you can redistribute it and/or modify *
@@ -20,7 +20,7 @@ @@ -20,7 +20,7 @@
20 ***************************************************************************/ 20 ***************************************************************************/
21 /** 21 /**
22 * @file ctedispcube.hpp 22 * @file ctedispcube.hpp
23 - * @brief EDISP cube generation tool definition 23 + * @brief Energy dispersion cube generation tool definition
24 * @author Chia-Chun Lu 24 * @author Chia-Chun Lu
25 */ 25 */
26 26
@@ -40,7 +40,7 @@ @@ -40,7 +40,7 @@
40 /***********************************************************************//** 40 /***********************************************************************//**
41 * @class ctedispcube 41 * @class ctedispcube
42 * 42 *
43 - * @brief EDISP cube generation tool 43 + * @brief Energy dispersion cube generation tool
44 ***************************************************************************/ 44 ***************************************************************************/
45 class ctedispcube : public ctool { 45 class ctedispcube : public ctool {
46 46
@@ -56,9 +56,9 @@ public: @@ -56,9 +56,9 @@ public:
56 ctedispcube& operator=(const ctedispcube& app); 56 ctedispcube& operator=(const ctedispcube& app);
57 57
58 // Methods 58 // Methods
59 - void clear(void);  
60 - void run(void);  
61 - void save(void); 59 + void clear(void);
  60 + void run(void);
  61 + void save(void);
62 const GCTACubeEdisp& edispcube(void) const; 62 const GCTACubeEdisp& edispcube(void) const;
63 63
64 protected: 64 protected:
@@ -69,18 +69,18 @@ protected: @@ -69,18 +69,18 @@ protected:
69 void get_parameters(void); 69 void get_parameters(void);
70 70
71 // User parameters 71 // User parameters
72 - GFilename m_outcube; //!< Output Edisp cube file name 72 + GFilename m_outcube; //!< Output energy dispersion cube file name
73 73
74 // Protected members 74 // Protected members
75 - GObservations m_obs; //!< Observation container  
76 - GCTACubeEdisp m_edispcube; //!< Edisp cube 75 + GObservations m_obs; //!< Observation container
  76 + GCTACubeEdisp m_edispcube; //!< Energy dispersion cube
77 }; 77 };
78 78
79 79
80 /***********************************************************************//** 80 /***********************************************************************//**
81 - * @brief Return EDISP cube 81 + * @brief Return energy dispersion cube
82 * 82 *
83 - * @return EDISP cube 83 + * @return Energy dispersion cube
84 ***************************************************************************/ 84 ***************************************************************************/
85 inline 85 inline
86 const GCTACubeEdisp& ctedispcube::edispcube(void) const 86 const GCTACubeEdisp& ctedispcube::edispcube(void) const
src/ctedispcube/ctedispcube.par
@@ -18,10 +18,10 @@ @@ -18,10 +18,10 @@
18 # Observational parameters 18 # Observational parameters
19 #=================== 19 #===================
20 inobs, f, a, "NONE",,, "Input event list or observation definition XML file" 20 inobs, f, a, "NONE",,, "Input event list or observation definition XML file"
21 -incube, f, a, "NONE",,, "Input counts cube file to extract PSF cube definition" 21 +incube, f, a, "NONE",,, "Input counts cube file to extract energy dispersion cube definition"
22 caldb, s, a, "prod2",,, "Calibration database" 22 caldb, s, a, "prod2",,, "Calibration database"
23 irf, s, a, "South_0.5h",,, "Instrument response function" 23 irf, s, a, "South_0.5h",,, "Instrument response function"
24 -outcube, f, a, "edispcube.fits",,, "Output PSF cube file" 24 +outcube, f, a, "edispcube.fits",,, "Output energy dispersion cube file"
25 25
26 # 26 #
27 # Energy binning parameters 27 # Energy binning parameters
@@ -47,7 +47,7 @@ proj, s, a, &quot;CAR&quot;, AIT|AZP|CAR|MER|MOL|STG|TAN,, &quot;Projection method&quot; @@ -47,7 +47,7 @@ proj, s, a, &quot;CAR&quot;, AIT|AZP|CAR|MER|MOL|STG|TAN,, &quot;Projection method&quot;
47 # 47 #
48 # Angular separation binning parameters 48 # Angular separation binning parameters
49 #====================================== 49 #======================================
50 -mmax, r, h, 10.0,,, "Upper bound of fraction between recontructed and true photon energy" 50 +migramax, r, h, 2.0,,, "Upper bound of ratio of recontructed to true photon energy"
51 migrabins, i, h, 100,,, "Number of migration bins" 51 migrabins, i, h, 100,,, "Number of migration bins"
52 52
53 # 53 #
src/ctedispcube/main.cpp
1 /*************************************************************************** 1 /***************************************************************************
2 - * ctedispcube - CTA EDISP cube tool * 2 + * ctedispcube - Energy dispersion cube generation tool *
3 * ----------------------------------------------------------------------- * 3 * ----------------------------------------------------------------------- *
4 * copyright (C) 2016 by Maria Haupt * 4 * copyright (C) 2016 by Maria Haupt *
5 * ----------------------------------------------------------------------- * 5 * ----------------------------------------------------------------------- *
@@ -20,7 +20,7 @@ @@ -20,7 +20,7 @@
20 ***************************************************************************/ 20 ***************************************************************************/
21 /** 21 /**
22 * @file ctedispcube/main.cpp 22 * @file ctedispcube/main.cpp
23 - * @brief CTA EDISP cube tool main code 23 + * @brief Energy dispersion cube tool main code
24 * @author Maria Haupt 24 * @author Maria Haupt
25 */ 25 */
26 26
src/cterror/cterror.par
@@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
6 # ------------------------------------------------------------------------- # 6 # ------------------------------------------------------------------------- #
7 # # 7 # #
8 # File: cterror.par # 8 # File: cterror.par #
9 -# Version: 1.0.0 # 9 +# Version: 1.1.0 #
10 # # 10 # #
11 # Author: Florent Forest # 11 # Author: Florent Forest #
12 # florent.forest@isae.fr # 12 # florent.forest@isae.fr #
src/ctlike/ctlike.par
@@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
5 # ------------------------------------------------------------------------- # 5 # ------------------------------------------------------------------------- #
6 # # 6 # #
7 # File: ctlike.par # 7 # File: ctlike.par #
8 -# Version: 1.0.0 # 8 +# Version: 1.1.0 #
9 # # 9 # #
10 # Author: Jurgen Knodlseder # 10 # Author: Jurgen Knodlseder #
11 # Jurgen.Knodlseder@irap.omp.eu # 11 # Jurgen.Knodlseder@irap.omp.eu #
src/ctulimit/ctulimit.par
@@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
5 # ------------------------------------------------------------------------- # 5 # ------------------------------------------------------------------------- #
6 # # 6 # #
7 # File: ctulimit.par # 7 # File: ctulimit.par #
8 -# Version: 01-00-00 # 8 +# Version: 1.1.0 #
9 # # 9 # #
10 # Author: Michael Mayer # 10 # Author: Michael Mayer #
11 # michael.mayer@physik.hu-berlin.de # 11 # michael.mayer@physik.hu-berlin.de #
src/support/ctool.cpp
@@ -862,16 +862,18 @@ void ctool::set_obs_response(GCTAObservation* obs) @@ -862,16 +862,18 @@ void ctool::set_obs_response(GCTAObservation* obs)
862 // If the observation contains a counts cube, then first check whether 862 // If the observation contains a counts cube, then first check whether
863 // the expcube and psfcube parameters exist and are not NONE 863 // the expcube and psfcube parameters exist and are not NONE
864 if (dynamic_cast<const GCTAEventCube*>(obs->events()) != NULL) { 864 if (dynamic_cast<const GCTAEventCube*>(obs->events()) != NULL) {
865 - if (has_par("expcube") && has_par("psfcube") && has_par("bkgcube") && has_par("edispcube")) { 865 + if (has_par("expcube") && has_par("psfcube") &&
  866 + has_par("edispcube") && has_par("bkgcube")) {
866 867
867 // Get filenames 868 // Get filenames
868 - std::string expcube = (*this)["expcube"].filename();  
869 - std::string psfcube = (*this)["psfcube"].filename(); 869 + std::string expcube = (*this)["expcube"].filename();
  870 + std::string psfcube = (*this)["psfcube"].filename();
870 std::string edispcube = (*this)["edispcube"].filename(); 871 std::string edispcube = (*this)["edispcube"].filename();
871 - std::string bkgcube = (*this)["bkgcube"].filename(); 872 + std::string bkgcube = (*this)["bkgcube"].filename();
872 873
873 // Extract response information if available 874 // Extract response information if available
874 - if ((expcube != "NONE") && (psfcube != "NONE") && (bkgcube != "NONE") && 875 + if ((expcube != "NONE") && (psfcube != "NONE") &&
  876 + (bkgcube != "NONE") &&
875 (gammalib::strip_whitespace(expcube) != "") && 877 (gammalib::strip_whitespace(expcube) != "") &&
876 (gammalib::strip_whitespace(psfcube) != "") && 878 (gammalib::strip_whitespace(psfcube) != "") &&
877 (gammalib::strip_whitespace(bkgcube) != "")) { 879 (gammalib::strip_whitespace(bkgcube) != "")) {
@@ -881,8 +883,9 @@ void ctool::set_obs_response(GCTAObservation* obs) @@ -881,8 +883,9 @@ void ctool::set_obs_response(GCTAObservation* obs)
881 GCTACubePsf psf(psfcube); 883 GCTACubePsf psf(psfcube);
882 GCTACubeBackground background(bkgcube); 884 GCTACubeBackground background(bkgcube);
883 885
884 - // Optionally load Edisp cube  
885 - if (edispcube != "NONE" && (gammalib::strip_whitespace(edispcube) != "")) { 886 + // Optionally load energy dispersion cube
  887 + if ((edispcube != "NONE") &&
  888 + (gammalib::strip_whitespace(edispcube) != "")) {
886 GCTACubeEdisp edisp(edispcube); 889 GCTACubeEdisp edisp(edispcube);
887 obs->response(exposure, psf, edisp, background); 890 obs->response(exposure, psf, edisp, background);
888 } 891 }
@@ -912,8 +915,9 @@ void ctool::set_obs_response(GCTAObservation* obs) @@ -912,8 +915,9 @@ void ctool::set_obs_response(GCTAObservation* obs)
912 // to the observation definition XML file, in case an observation 915 // to the observation definition XML file, in case an observation
913 // definition XML file is written. 916 // definition XML file is written.
914 std::string parameter = "parameter name=\"Calibration\"" 917 std::string parameter = "parameter name=\"Calibration\""
915 - " database=\""+database+"\""  
916 - " response=\""+irf+"\""; 918 + " database=\""+database+"\""
  919 + " response=\""+irf+"\"";
  920 +
917 GXmlElement xml; 921 GXmlElement xml;
918 xml.append(parameter); 922 xml.append(parameter);
919 923
@@ -923,22 +927,6 @@ void ctool::set_obs_response(GCTAObservation* obs) @@ -923,22 +927,6 @@ void ctool::set_obs_response(GCTAObservation* obs)
923 // Attach response to observation 927 // Attach response to observation
924 obs->response(response); 928 obs->response(response);
925 929
926 - // Set calibration database. If "database" is a valid directory then use  
927 - // this as the pathname to the calibration database. Otherwise, interpret  
928 - // "database" as the instrument name, the mission being "cta"  
929 - /*  
930 - GCaldb caldb;  
931 - if (gammalib::dir_exists(database)) {  
932 - caldb.rootdir(database);  
933 - }  
934 - else {  
935 - caldb.open("cta", database);  
936 - }  
937 - */  
938 -  
939 - // Set reponse  
940 - //obs->response(irf, caldb);  
941 -  
942 // Signal response availability 930 // Signal response availability
943 has_response = true; 931 has_response = true;
944 932
@@ -975,11 +963,13 @@ void ctool::set_obs_bounds(GObservations&amp; obs) @@ -975,11 +963,13 @@ void ctool::set_obs_bounds(GObservations&amp; obs)
975 // parameters and add them 963 // parameters and add them
976 if (list->ebounds().is_empty()) { 964 if (list->ebounds().is_empty()) {
977 965
978 - // If there are "emin" and "emax" parameters then use them 966 + // If there are "emin" and "emax" parameters then use
  967 + // them
979 if (has_par("emin") && has_par("emax")) { 968 if (has_par("emin") && has_par("emax")) {
980 double emin = (*this)["emin"].real(); 969 double emin = (*this)["emin"].real();
981 double emax = (*this)["emax"].real(); 970 double emax = (*this)["emax"].real();
982 - GEbounds ebounds(GEnergy(emin, "TeV"), GEnergy(emax, "TeV")); 971 + GEbounds ebounds(GEnergy(emin, "TeV"),
  972 + GEnergy(emax, "TeV"));
983 list->ebounds(ebounds); 973 list->ebounds(ebounds);
984 } 974 }
985 975
@@ -1004,7 +994,6 @@ void ctool::set_obs_bounds(GObservations&amp; obs) @@ -1004,7 +994,6 @@ void ctool::set_obs_bounds(GObservations&amp; obs)
1004 994
1005 } // endfor: looped over observations 995 } // endfor: looped over observations
1006 996
1007 -  
1008 // Return 997 // Return
1009 return; 998 return;
1010 } 999 }
@@ -1134,7 +1123,7 @@ void ctool::provide_help(void) const @@ -1134,7 +1123,7 @@ void ctool::provide_help(void) const
1134 char* ptr = std::getenv("CTOOLS"); 1123 char* ptr = std::getenv("CTOOLS");
1135 if (ptr == NULL) { 1124 if (ptr == NULL) {
1136 std::string msg = "CTOOLS environment variable not set, cannot " 1125 std::string msg = "CTOOLS environment variable not set, cannot "
1137 - "display help file. Please define CTOOLS " 1126 + "display help file. Please set the CTOOLS "
1138 "environment variable."; 1127 "environment variable.";
1139 throw GException::invalid_value(G_PROVIDE_HELP, msg); 1128 throw GException::invalid_value(G_PROVIDE_HELP, msg);
1140 } 1129 }
test/data/crab_edispcube.fits.gz
No preview for this file type
test/test_ctedispcube.py
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 # ========================================================================== 2 # ==========================================================================
3 # This scripts performs unit tests for the ctedispcube tool. 3 # This scripts performs unit tests for the ctedispcube tool.
4 # 4 #
5 -# Copyright (C) 2014-2016 Juergen Knoedlseder 5 +# Copyright (C) 2016 Maria Haupt
6 # 6 #
7 # This program is free software: you can redistribute it and/or modify 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 8 # it under the terms of the GNU General Public License as published by
@@ -66,23 +66,23 @@ class Test(gammalib.GPythonTestSuite): @@ -66,23 +66,23 @@ class Test(gammalib.GPythonTestSuite):
66 """ 66 """
67 # Set-up ctedispcube 67 # Set-up ctedispcube
68 edispcube = ctools.ctedispcube() 68 edispcube = ctools.ctedispcube()
69 - edispcube["inobs"] = self.events_name  
70 - edispcube["incube"] = "NONE"  
71 - edispcube["outcube"] = "edispcube.fits"  
72 - edispcube["caldb"] = self.caldb  
73 - edispcube["irf"] = self.irf  
74 - edispcube["ebinalg"] = "LOG"  
75 - edispcube["emin"] = 0.1  
76 - edispcube["emax"] = 100  
77 - edispcube["enumbins"] = 20  
78 - edispcube["nxpix"] = 10  
79 - edispcube["nypix"] = 10  
80 - edispcube["binsz"] = 0.4  
81 - edispcube["coordsys"] = "CEL"  
82 - edispcube["proj"] = "CAR"  
83 - edispcube["xref"] = 83.63  
84 - edispcube["yref"] = 22.01  
85 - edispcube["mmax"] = 0.3 69 + edispcube["inobs"] = self.events_name
  70 + edispcube["incube"] = "NONE"
  71 + edispcube["outcube"] = "edispcube.fits"
  72 + edispcube["caldb"] = self.caldb
  73 + edispcube["irf"] = self.irf
  74 + edispcube["ebinalg"] = "LOG"
  75 + edispcube["emin"] = 0.1
  76 + edispcube["emax"] = 100
  77 + edispcube["enumbins"] = 20
  78 + edispcube["nxpix"] = 10
  79 + edispcube["nypix"] = 10
  80 + edispcube["binsz"] = 0.4
  81 + edispcube["coordsys"] = "CEL"
  82 + edispcube["proj"] = "CAR"
  83 + edispcube["xref"] = 83.63
  84 + edispcube["yref"] = 22.01
  85 + edispcube["migramax"] = 2.0
86 edispcube["migrabins"] = 10 86 edispcube["migrabins"] = 10
87 87
88 # Run tool 88 # Run tool
test/test_ctools.sh
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 # ========================================================================== 2 # ==========================================================================
3 # This script tests all ctools 3 # This script tests all ctools
4 # 4 #
5 -# Copyright (C) 2011-2015 Juergen Knoedlseder 5 +# Copyright (C) 2011-2016 Juergen Knoedlseder
6 # 6 #
7 # This program is free software: you can redistribute it and/or modify 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 8 # it under the terms of the GNU General Public License as published by
@@ -293,7 +293,7 @@ $ctedispcube inobs=&quot;data/crab_events.fits&quot; \ @@ -293,7 +293,7 @@ $ctedispcube inobs=&quot;data/crab_events.fits&quot; \
293 xref=83.63 \ 293 xref=83.63 \
294 yref=22.01 \ 294 yref=22.01 \
295 proj="CAR" \ 295 proj="CAR" \
296 - mmax=3.0 \ 296 + migramax=3.0 \
297 migrabins=10 297 migrabins=10
298 $ECHO -n "." 298 $ECHO -n "."
299 if [ -s "edispcube1.fits" ] 299 if [ -s "edispcube1.fits" ]
@@ -310,7 +310,7 @@ $ctedispcube inobs=&quot;events.fits&quot; \ @@ -310,7 +310,7 @@ $ctedispcube inobs=&quot;events.fits&quot; \
310 outcube="edispcube2.fits" \ 310 outcube="edispcube2.fits" \
311 caldb="irf" \ 311 caldb="irf" \
312 irf="cta_dummy_irf" \ 312 irf="cta_dummy_irf" \
313 - mmax=3.0 \ 313 + migramax=3.0 \
314 migrabins=3 314 migrabins=3
315 $ECHO -n "." 315 $ECHO -n "."
316 if [ -s "edispcube2.fits" ] 316 if [ -s "edispcube2.fits" ]
@@ -388,7 +388,6 @@ fi @@ -388,7 +388,6 @@ fi
388 $ECHO " ok" 388 $ECHO " ok"
389 389
390 390
391 -  
392 # 391 #
393 # Test ctmodel 392 # Test ctmodel
394 # ============ 393 # ============
@@ -580,7 +579,6 @@ fi @@ -580,7 +579,6 @@ fi
580 $ECHO " ok" 579 $ECHO " ok"
581 580
582 581
583 -  
584 # 582 #
585 # Test cttsmap 583 # Test cttsmap
586 # ============ 584 # ============
@@ -609,8 +607,6 @@ fi @@ -609,8 +607,6 @@ fi
609 $ECHO " ok" 607 $ECHO " ok"
610 608
611 609
612 -  
613 -  
614 # 610 #
615 # Test ctcubemask 611 # Test ctcubemask
616 # =============== 612 # ===============