Commit 430afcd8569bf21c62d03b4e67b035b1e4d469b2

Authored by Jürgen Knödlseder
2 parents 7b570a15 79cbc023

Merge branch '1724-ctools-support-edisp-stacked' into integration

.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
configure.ac
@@ -960,6 +960,7 @@ AC_CONFIG_FILES([Makefile @@ -960,6 +960,7 @@ AC_CONFIG_FILES([Makefile
960 src/ctselect/Makefile 960 src/ctselect/Makefile
961 src/ctexpcube/Makefile 961 src/ctexpcube/Makefile
962 src/ctpsfcube/Makefile 962 src/ctpsfcube/Makefile
  963 + src/ctedispcube/Makefile
963 src/ctbkgcube/Makefile 964 src/ctbkgcube/Makefile
964 src/ctcubemask/Makefile 965 src/ctcubemask/Makefile
965 src/cttsmap/Makefile 966 src/cttsmap/Makefile
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
@@ -104,7 +104,9 @@ class cslightcrv(ctools.cscript): @@ -104,7 +104,9 @@ class cslightcrv(ctools.cscript):
104 pars.append(gammalib.GApplicationPar("srcname","s","a","Crab","","","Source name")) 104 pars.append(gammalib.GApplicationPar("srcname","s","a","Crab","","","Source name"))
105 pars.append(gammalib.GApplicationPar("expcube","f","a","NONE","","","Input exposure cube file (only needed for stacked analysis)")) 105 pars.append(gammalib.GApplicationPar("expcube","f","a","NONE","","","Input exposure cube file (only needed for stacked analysis)"))
106 pars.append(gammalib.GApplicationPar("psfcube","f","a","NONE","","","Input PSF cube file (only needed for stacked analysis)")) 106 pars.append(gammalib.GApplicationPar("psfcube","f","a","NONE","","","Input PSF cube file (only needed for stacked analysis)"))
  107 + pars.append(gammalib.GApplicationPar("edispcube","f","a","NONE","","","Input energy dispersion cube file (only needed for stacked analysis)"))
107 pars.append(gammalib.GApplicationPar("bkgcube","s","a","NONE","","","Input background cube file (only needed for stacked analysis)")) 108 pars.append(gammalib.GApplicationPar("bkgcube","s","a","NONE","","","Input background cube file (only needed for stacked analysis)"))
  109 + pars.append(gammalib.GApplicationPar("edisp","b","h","no","","","Apply energy dispersion?"))
108 pars.append(gammalib.GApplicationPar("caldb","s","a","prod2","","","Calibration database")) 110 pars.append(gammalib.GApplicationPar("caldb","s","a","prod2","","","Calibration database"))
109 pars.append(gammalib.GApplicationPar("irf","s","a","South_0.5h","","","Instrument response function")) 111 pars.append(gammalib.GApplicationPar("irf","s","a","South_0.5h","","","Instrument response function"))
110 pars.append(gammalib.GApplicationPar("outfile","f","a","lightcurve.fits","","","Output light curve file")) 112 pars.append(gammalib.GApplicationPar("outfile","f","a","lightcurve.fits","","","Output light curve file"))
@@ -190,6 +192,9 @@ class cslightcrv(ctools.cscript): @@ -190,6 +192,9 @@ class cslightcrv(ctools.cscript):
190 # Get source name 192 # Get source name
191 self.m_srcname = self["srcname"].string() 193 self.m_srcname = self["srcname"].string()
192 194
  195 + # Get energy dispersion flag
  196 + self.m_edisp = self["edisp"].boolean()
  197 +
193 # Get time boundaries 198 # Get time boundaries
194 self.create_tbounds() 199 self.create_tbounds()
195 200
@@ -430,7 +435,7 @@ class cslightcrv(ctools.cscript): @@ -430,7 +435,7 @@ class cslightcrv(ctools.cscript):
430 435
431 # Header 436 # Header
432 if self.logTerse(): 437 if self.logTerse():
433 - self.log.header3("Creating PSF cube") 438 + self.log.header3("Creating point spread function cube")
434 439
435 # Create psf cube 440 # Create psf cube
436 psfcube = ctools.ctpsfcube(select.obs()) 441 psfcube = ctools.ctpsfcube(select.obs())
@@ -449,6 +454,30 @@ class cslightcrv(ctools.cscript): @@ -449,6 +454,30 @@ class cslightcrv(ctools.cscript):
449 psfcube["proj"] = self.m_proj 454 psfcube["proj"] = self.m_proj
450 psfcube.run() 455 psfcube.run()
451 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 +
452 # Header 481 # Header
453 if self.logTerse(): 482 if self.logTerse():
454 self.log.header3("Creating background cube") 483 self.log.header3("Creating background cube")
@@ -472,12 +501,17 @@ class cslightcrv(ctools.cscript): @@ -472,12 +501,17 @@ class cslightcrv(ctools.cscript):
472 501
473 # Set new binned observation 502 # Set new binned observation
474 obs = bin.obs() 503 obs = bin.obs()
475 -  
476 - # Set precomputed binned response  
477 - obs[0].response(expcube.expcube(), psfcube.psfcube(), bkgcube.bkgcube())  
478 - 504 +
479 # Get new models 505 # Get new models
480 models = bkgcube.models() 506 models = bkgcube.models()
  507 +
  508 + # Set precomputed binned response
  509 + if self.m_edisp:
  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())
481 515
482 # Fix background models if required 516 # Fix background models if required
483 if self.m_fix_bkg: 517 if self.m_fix_bkg:
@@ -495,6 +529,7 @@ class cslightcrv(ctools.cscript): @@ -495,6 +529,7 @@ class cslightcrv(ctools.cscript):
495 529
496 # Likelihood 530 # Likelihood
497 like = ctools.ctlike(obs) 531 like = ctools.ctlike(obs)
  532 + like["edisp"] = self.m_edisp
498 like.run() 533 like.run()
499 534
500 # Skip bin if no event was present 535 # Skip bin if no event was present
cscripts/cspull.py
@@ -52,6 +52,7 @@ class cspull(ctools.cscript): @@ -52,6 +52,7 @@ class cspull(ctools.cscript):
52 self.m_exposure = None 52 self.m_exposure = None
53 self.m_psfcube = None 53 self.m_psfcube = None
54 self.m_bckcube = None 54 self.m_bckcube = None
  55 + self.m_edispcube = None
55 self.m_stackmodels = None 56 self.m_stackmodels = None
56 self.m_coordsys = "CEL" 57 self.m_coordsys = "CEL"
57 self.m_proj = "TAN" 58 self.m_proj = "TAN"
@@ -250,6 +251,29 @@ class cspull(ctools.cscript): @@ -250,6 +251,29 @@ class cspull(ctools.cscript):
250 if self.logTerse(): 251 if self.logTerse():
251 self.log("Computed Psf cube\n") 252 self.log("Computed Psf cube\n")
252 253
  254 + # Optionally get stacked Edisp
  255 + if self.m_edisp:
  256 + edispcube = ctools.edispcube(self.obs)
  257 + edispcube["incube"] = "NONE"
  258 + edispcube["usepnt"] = True
  259 + edispcube["ebinalg"] = "LOG"
  260 + edispcube["binsz"] = self.m_binsz*10.0
  261 + edispcube["nxpix"] = self.m_npix/10
  262 + edispcube["nypix"] = self.m_npix/10
  263 + edispcube["enumbins"] = self.m_enumbins
  264 + edispcube["emin"] = self["emin"].real()
  265 + edispcube["emax"] = self["emax"].real()
  266 + edispcube["coordsys"] = self.m_coordsys
  267 + edispcube["proj"] = self.m_proj
  268 + edispcube.run()
  269 +
  270 + # Store result
  271 + self.m_edispcube = edispcube.edispcube().copy()
  272 +
  273 + # Logging
  274 + if self.logTerse():
  275 + self.log("Computed energy dispersion cube\n")
  276 +
253 # Get stacked background 277 # Get stacked background
254 bkgcube = ctools.ctbkgcube(self.obs) 278 bkgcube = ctools.ctbkgcube(self.obs)
255 bkgcube["incube"] = "NONE" 279 bkgcube["incube"] = "NONE"
@@ -325,7 +349,6 @@ class cspull(ctools.cscript): @@ -325,7 +349,6 @@ class cspull(ctools.cscript):
325 for n in result['colnames']: 349 for n in result['colnames']:
326 headers[n] = n 350 headers[n] = n
327 writer.writerow(headers) 351 writer.writerow(headers)
328 - #writer.writerow(dict((_,_) for _ in result['colnames']))  
329 else: 352 else:
330 file = open(self.m_outfile.url(), 'a') 353 file = open(self.m_outfile.url(), 'a')
331 writer = csv.DictWriter(file, result['colnames']) 354 writer = csv.DictWriter(file, result['colnames'])
@@ -391,7 +414,12 @@ class cspull(ctools.cscript): @@ -391,7 +414,12 @@ class cspull(ctools.cscript):
391 414
392 # If stacked, add stacked responses and model 415 # If stacked, add stacked responses and model
393 if self.obs.size() > 1 and self.m_enumbins > 0: 416 if self.obs.size() > 1 and self.m_enumbins > 0:
394 - obs[0].response(self.m_exposure, self.m_psfcube, self.m_bckcube) 417 + if self.m_edisp:
  418 + obs[0].response(self.m_exposure, self.m_psfcube,
  419 + self.m_edispcube, self.m_bckcube)
  420 + else:
  421 + obs[0].response(self.m_exposure, self.m_psfcube,
  422 + self.m_bckcube)
395 obs.models(self.m_stackmodels) 423 obs.models(self.m_stackmodels)
396 424
397 # Determine number of events in simulation 425 # Determine number of events in simulation
cscripts/csresmap.py
@@ -108,6 +108,7 @@ class csresmap(ctools.cscript): @@ -108,6 +108,7 @@ class csresmap(ctools.cscript):
108 pars.append(gammalib.GApplicationPar("modcube","f","a","NONE","","","Input model cube file (generated with ctmodel)")) 108 pars.append(gammalib.GApplicationPar("modcube","f","a","NONE","","","Input model cube file (generated with ctmodel)"))
109 pars.append(gammalib.GApplicationPar("expcube","f","a","NONE","","","Input exposure cube file (only needed for stacked analysis)")) 109 pars.append(gammalib.GApplicationPar("expcube","f","a","NONE","","","Input exposure cube file (only needed for stacked analysis)"))
110 pars.append(gammalib.GApplicationPar("psfcube","f","a","NONE","","","Input PSF cube file (only needed for stacked analysis)")) 110 pars.append(gammalib.GApplicationPar("psfcube","f","a","NONE","","","Input PSF cube file (only needed for stacked analysis)"))
  111 + pars.append(gammalib.GApplicationPar("edispcube","f","a","NONE","","","Input energy dispersion cube file (only needed for stacked analysis)"))
111 pars.append(gammalib.GApplicationPar("bkgcube","f","a","NONE","","","Input background cube file (only needed for stacked analysis)")) 112 pars.append(gammalib.GApplicationPar("bkgcube","f","a","NONE","","","Input background cube file (only needed for stacked analysis)"))
112 pars.append(gammalib.GApplicationPar("inmodel","f","a","$CTOOLS/share/models/crab.xml","","","Input model XML file")) 113 pars.append(gammalib.GApplicationPar("inmodel","f","a","$CTOOLS/share/models/crab.xml","","","Input model XML file"))
113 pars.append(gammalib.GApplicationPar("caldb","s","a","prod2","","","Calibration database")) 114 pars.append(gammalib.GApplicationPar("caldb","s","a","prod2","","","Calibration database"))
@@ -174,7 +175,6 @@ class csresmap(ctools.cscript): @@ -174,7 +175,6 @@ class csresmap(ctools.cscript):
174 # Skip ctbin step later on 175 # Skip ctbin step later on
175 self.m_skip_binning = True 176 self.m_skip_binning = True
176 177
177 -  
178 # Set models if we have none 178 # Set models if we have none
179 if self.obs.models().size() == 0: 179 if self.obs.models().size() == 0:
180 self.obs.models(self["inmodel"].filename()) 180 self.obs.models(self["inmodel"].filename())
@@ -371,7 +371,6 @@ class csresmap(ctools.cscript): @@ -371,7 +371,6 @@ class csresmap(ctools.cscript):
371 # Get model map into GSkyMap object 371 # Get model map into GSkyMap object
372 modelmap = model.cube().map().copy() 372 modelmap = model.cube().map().copy()
373 373
374 -  
375 # Store counts map as residual map. Note that we need a 374 # Store counts map as residual map. Note that we need a
376 # special construct here to avoid memory leaks. This seems 375 # special construct here to avoid memory leaks. This seems
377 # 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()
@@ -105,6 +105,7 @@ class csspec(ctools.cscript): @@ -105,6 +105,7 @@ class csspec(ctools.cscript):
105 pars.append(gammalib.GApplicationPar("srcname","s","a","Crab","","","Source name")) 105 pars.append(gammalib.GApplicationPar("srcname","s","a","Crab","","","Source name"))
106 pars.append(gammalib.GApplicationPar("expcube","f","a","NONE","","","Input exposure cube file (only needed for stacked analysis)")) 106 pars.append(gammalib.GApplicationPar("expcube","f","a","NONE","","","Input exposure cube file (only needed for stacked analysis)"))
107 pars.append(gammalib.GApplicationPar("psfcube","f","a","NONE","","","Input PSF cube file (only needed for stacked analysis)")) 107 pars.append(gammalib.GApplicationPar("psfcube","f","a","NONE","","","Input PSF cube file (only needed for stacked analysis)"))
  108 + pars.append(gammalib.GApplicationPar("edispcube","f","a","NONE","","","Input energy dispersion cube file (only needed for stacked analysis)"))
108 pars.append(gammalib.GApplicationPar("bkgcube","f","a","NONE","","","Input background cube file (only needed for stacked analysis)")) 109 pars.append(gammalib.GApplicationPar("bkgcube","f","a","NONE","","","Input background cube file (only needed for stacked analysis)"))
109 pars.append(gammalib.GApplicationPar("caldb","s","a","prod2","","","Calibration database")) 110 pars.append(gammalib.GApplicationPar("caldb","s","a","prod2","","","Calibration database"))
110 pars.append(gammalib.GApplicationPar("irf","s","a","South_0.5h","","","Instrument response function")) 111 pars.append(gammalib.GApplicationPar("irf","s","a","South_0.5h","","","Instrument response function"))
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
@@ -99,6 +99,7 @@ class cstsdist(ctools.cscript): @@ -99,6 +99,7 @@ class cstsdist(ctools.cscript):
99 pars.append(gammalib.GApplicationPar("srcname","s","a","Crab","","","Source name")) 99 pars.append(gammalib.GApplicationPar("srcname","s","a","Crab","","","Source name"))
100 pars.append(gammalib.GApplicationPar("expcube","s","a","NONE","","","Input exposure cube file (only needed for stacked analysis)")) 100 pars.append(gammalib.GApplicationPar("expcube","s","a","NONE","","","Input exposure cube file (only needed for stacked analysis)"))
101 pars.append(gammalib.GApplicationPar("psfcube","s","a","NONE","","","Input PSF cube file (only needed for stacked analysis)")) 101 pars.append(gammalib.GApplicationPar("psfcube","s","a","NONE","","","Input PSF cube file (only needed for stacked analysis)"))
  102 + pars.append(gammalib.GApplicationPar("edispcube","f","a","NONE","","","Input energy dispersion cube file (only needed for stacked analysis)"))
102 pars.append(gammalib.GApplicationPar("bkgcube","s","a","NONE","","","Input background cube file (only needed for stacked analysis)")) 103 pars.append(gammalib.GApplicationPar("bkgcube","s","a","NONE","","","Input background cube file (only needed for stacked analysis)"))
103 pars.append(gammalib.GApplicationPar("caldb","s","a","prod2","","","Calibration database")) 104 pars.append(gammalib.GApplicationPar("caldb","s","a","prod2","","","Calibration database"))
104 pars.append(gammalib.GApplicationPar("irf","s","a","South_0.5h","","","Instrument response function")) 105 pars.append(gammalib.GApplicationPar("irf","s","a","South_0.5h","","","Instrument response function"))
doc/source/reference_manual/ctedispcube.rst 0 → 100644
  1 +.. _ctedispcube:
  2 +
  3 +ctedispcube
  4 +=========
  5 +
  6 +Generate energy dispersion cube for a counts cube.
  7 +
  8 +
  9 +Synopsis
  10 +--------
  11 +
  12 +This tool generates an energy dispersion cube for a counts cube. An energy
  13 +dispersion cube is a 4-dimensional cube spanned by Right Ascension or
  14 +Galactic longitude, Declination or Galactic latitude, energy, and fraction
  15 +between recontructed and true photon energy. The energy binning of the cube
  16 +may be either linear, logarithmic, or custom defined using an input file.
  17 +
  18 +ctedispcube requires on input the event list or observation definition file
  19 +that has been used in the generation of the counts cube using :doc:`ctbin`.
  20 +
  21 +It is not recommended to use the counts cube for the energy dispersion
  22 +cube definition, although this is formally possible by specifying the counts
  23 +cube as ``incube`` parameter. This leads however to a large FITS file on
  24 +output since the number of bins in the counts cube will be multiplied by
  25 +the number of offset angle bins (typically 200). Since the energy dispersion
  26 +varies only little over the field of view of the camera it is
  27 +recommended to use a rather coarse spatial binning to keep the file size
  28 +manageable (with a typical value of ``binsz=1.0``).
  29 +
  30 +ctedispcube generates an energy dispersion cube FITS file comprising three
  31 +extensions. The primary extension contains a 3-dimensional image that contains
  32 +the energy disperison values. The energy and fraction dimensions of the enrgy
  33 +dispersion cube are folded into the 3rd dimension of the FITS image. The next
  34 +extension named ``EBOUNDS`` contains a binary table that defines the energy
  35 +boundaries of the exposure cube. The last extension named ``DELTAS`` contains
  36 +a binary table that defines the fraction between recontructed and true photon
  37 +energy.
  38 +
  39 +
  40 +General parameters
  41 +------------------
  42 +
  43 +``inobs [file]``
  44 + Input event list or observation definition XML file.
  45 +
  46 +``incube [file]``
  47 + Input counts cube file to extract energy dispersion cube definition.
  48 +
  49 +``caldb [string]``
  50 + Calibration database.
  51 +
  52 +``irf [string]``
  53 + Instrument response function.
  54 +
  55 +``(edisp = no) [boolean]``
  56 + Apply energy dispersion for response computation.
  57 +
  58 +``outcube [file]``
  59 + Output energy dispersion cube file.
  60 +
  61 +``ebinalg <FILE|LIN|LOG> [string]``
  62 + Algorithm for defining energy bins.
  63 +
  64 +``emin [real]``
  65 + Lower energy value for first energy bin (in TeV).
  66 +
  67 +``emax [real]``
  68 + Upper energy value for last energy bin (in TeV).
  69 +
  70 +``enumbins [integer]``
  71 + Number of energy bins.
  72 +
  73 +``ebinfile [file]``
  74 + Name of the file containing the energy bin definition.
  75 +
  76 +``(usepnt = no) [boolean]``
  77 + Use CTA pointing direction for cube centre instead of xref/yref parameters?
  78 +
  79 +``nxpix [integer]``
  80 + Number of cube bins in Right Ascension or Galactic longitude.
  81 +
  82 +``nypix [integer]``
  83 + Number of cube bins in Declination or Galactic latitude.
  84 +
  85 +``binsz [real]``
  86 + Cube bin size (in degrees/pixel).
  87 +
  88 +``coordsys <CEL|GAL> [string]``
  89 + Coordinate system (CEL - celestial, GAL - galactic).
  90 +
  91 +``xref [real]``
  92 + Right Ascension / Galactic longitude of cube centre (J2000, in degrees).
  93 +
  94 +``yref [real]``
  95 + Declination / Galactic latitude of cube centre (J2000, in degrees).
  96 +
  97 +``proj <AIT|AZP|CAR|MER|MOL|STG|TAN> [string]``
  98 + Projection method.
  99 +
  100 +``(mmax = 10.0) [real]``
  101 + Upper bound of fraction between recontructed and true photon energy.
  102 +
  103 +``(migrabins = 200) [integer]``
  104 + Number of migration bins.
  105 +
  106 +
  107 +Standard parameters
  108 +-------------------
  109 +
  110 +``(chatter = 2) [integer]``
  111 + Verbosity of the executable:
  112 + chatter = 0: no information will be logged
  113 +
  114 + chatter = 1: only errors will be logged
  115 +
  116 + chatter = 2: errors and actions will be logged
  117 +
  118 + chatter = 3: report about the task execution
  119 +
  120 + chatter = 4: detailed report about the task execution
  121 +
  122 +``(clobber = yes) [boolean]``
  123 + Specifies whether an existing output energy dispersion cube file should be overwritten.
  124 +
  125 +``(debug = no) [boolean]``
  126 + Enables debug mode. In debug mode the executable will dump any log file output to the console.
  127 +
  128 +``(mode = ql) [string]``
  129 + Mode of automatic parameters (default is "ql", i.e. "query and learn").
  130 +
  131 +``(logfile = ctedispcube.log) [string]``
  132 + Name of log file.
  133 +
  134 +
  135 +Related tools or scripts
  136 +------------------------
  137 +
  138 +:doc:`ctbin`
doc/source/reference_manual/ctpsfcube.rst
@@ -20,7 +20,7 @@ ctpsfcube requires on input the event list or observation definition file @@ -20,7 +20,7 @@ ctpsfcube requires on input the event list or observation definition file
20 that has been used in the generation of the counts cube using :doc:`ctbin`. 20 that has been used in the generation of the counts cube using :doc:`ctbin`.
21 21
22 It is not recommended to use the counts cube for the point spread function 22 It is not recommended to use the counts cube for the point spread function
23 -cube definition, although this is formally possibly by specifying the counts 23 +cube definition, although this is formally possible by specifying the counts
24 cube as ``incube`` parameter. This leads however to a large FITS file on 24 cube as ``incube`` parameter. This leads however to a large FITS file on
25 output since the number of bins in the counts cube will be multiplied by 25 output since the number of bins in the counts cube will be multiplied by
26 the number of offset angle bins (typically 200). Since the point spread 26 the number of offset angle bins (typically 200). Since the point spread
doc/source/reference_manual/index.rst
@@ -19,6 +19,7 @@ ctools @@ -19,6 +19,7 @@ ctools
19 ctbkgcube --- Generates background cube <ctbkgcube> 19 ctbkgcube --- Generates background cube <ctbkgcube>
20 ctbutterfly --- Compute butterfly <ctbutterfly> 20 ctbutterfly --- Compute butterfly <ctbutterfly>
21 ctcubemask --- Filter counts cube <ctcubemask> 21 ctcubemask --- Filter counts cube <ctcubemask>
  22 + ctedispcube --- Generates energy dispersion cube <ctedispcube>
22 ctexpcube --- Generates exposure cube <ctexpcube> 23 ctexpcube --- Generates exposure cube <ctexpcube>
23 ctlike --- Performs maximum likelihood fitting <ctlike> 24 ctlike --- Performs maximum likelihood fitting <ctlike>
24 ctmodel --- Computes model counts cube <ctmodel> 25 ctmodel --- Computes model counts cube <ctmodel>
src/Makefile.am
@@ -14,6 +14,7 @@ SUBDIRS = support \ @@ -14,6 +14,7 @@ SUBDIRS = support \
14 ctskymap \ 14 ctskymap \
15 ctexpcube \ 15 ctexpcube \
16 ctpsfcube \ 16 ctpsfcube \
  17 + ctedispcube \
17 ctbkgcube \ 18 ctbkgcube \
18 ctcubemask \ 19 ctcubemask \
19 cttsmap \ 20 cttsmap \
@@ -40,6 +41,7 @@ libctools_la_LIBADD = support/libsupport.la \ @@ -40,6 +41,7 @@ libctools_la_LIBADD = support/libsupport.la \
40 ctskymap/libctskymap.la \ 41 ctskymap/libctskymap.la \
41 ctexpcube/libctexpcube.la \ 42 ctexpcube/libctexpcube.la \
42 ctpsfcube/libctpsfcube.la \ 43 ctpsfcube/libctpsfcube.la \
  44 + ctedispcube/libctedispcube.la \
43 ctbkgcube/libctbkgcube.la \ 45 ctbkgcube/libctbkgcube.la \
44 ctcubemask/libctcubemask.la \ 46 ctcubemask/libctcubemask.la \
45 cttsmap/libcttsmap.la \ 47 cttsmap/libcttsmap.la \
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 #
@@ -22,6 +22,7 @@ inmodel, f, a, &quot;$CTOOLS/share/models/crab.xml&quot;,,, &quot;Input model XML file&quot; @@ -22,6 +22,7 @@ inmodel, f, a, &quot;$CTOOLS/share/models/crab.xml&quot;,,, &quot;Input model XML file&quot;
22 srcname, s, a, "Crab",,,"Source of interest" 22 srcname, s, a, "Crab",,,"Source of interest"
23 expcube, f, a, "NONE",,, "Input exposure cube file (only needed for stacked analysis)" 23 expcube, f, a, "NONE",,, "Input exposure cube file (only needed for stacked analysis)"
24 psfcube, f, a, "NONE",,, "Input PSF cube file (only needed for stacked analysis)" 24 psfcube, f, a, "NONE",,, "Input PSF cube file (only needed for stacked analysis)"
  25 +edispcube, f, a, "NONE",,, "Input energy dispersion cube file (only needed for stacked analysis)"
25 bkgcube, f, a, "NONE",,, "Input background cube file (only needed for stacked analysis)" 26 bkgcube, f, a, "NONE",,, "Input background cube file (only needed for stacked analysis)"
26 caldb, s, a, "prod2",,, "Calibration database" 27 caldb, s, a, "prod2",,, "Calibration database"
27 irf, s, a, "South_0.5h",,, "Instrument response function" 28 irf, s, a, "South_0.5h",,, "Instrument response function"
src/ctedispcube/Makefile.am 0 → 100644
  1 +## Process this file with automake to produce Makefile.in
  2 +
  3 +# Set include directories
  4 +INCLUDES = -I$(top_srcdir)/src/support
  5 +
  6 +# Program name
  7 +bin_PROGRAMS = ctedispcube
  8 +
  9 +# Sources
  10 +sources = ctedispcube.cpp
  11 +
  12 +# Libtool library
  13 +noinst_LTLIBRARIES = libctedispcube.la
  14 +libctedispcube_la_SOURCES = $(sources)
  15 +libctedispcube_la_LDFLAGS = @OPENMP_LIB_LDFLAGS@
  16 +
  17 +# Program definition
  18 +ctedispcube_SOURCES = main.cpp
  19 +ctedispcube_LDFLAGS = $(LIB_LINK_OPTION) @LDFLAGS@
  20 +ctedispcube_CPPFLAGS = @CPPFLAGS@
  21 +ctedispcube_LDADD = libctedispcube.la $(top_srcdir)/src/support/libsupport.la
  22 +
  23 +# Parameter files
  24 +pfilesdir = $(prefix)/syspfiles
  25 +pfiles_DATA = ctedispcube.par
src/ctedispcube/ctedispcube.cpp 0 → 100644
  1 +/***************************************************************************
  2 + * ctedispcube - Energy dispersion cube generation tool *
  3 + * ----------------------------------------------------------------------- *
  4 + * copyright (C) 2016 by Maria Haupt *
  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 ctedispcube.cpp
  23 + * @brief Energy dispersion cube generation tool implementation
  24 + * @author Maria Haupt
  25 + */
  26 +
  27 +/* __ Includes ___________________________________________________________ */
  28 +#ifdef HAVE_CONFIG_H
  29 +#include <config.h>
  30 +#endif
  31 +#include <cstdio>
  32 +#include "ctedispcube.hpp"
  33 +#include "GTools.hpp"
  34 +#include "GWcs.hpp"
  35 +
  36 +/* __ Method name definitions ____________________________________________ */
  37 +#define G_GET_PARAMETERS "ctedispcube::get_parameters()"
  38 +
  39 +/* __ Debug definitions __________________________________________________ */
  40 +
  41 +/* __ Coding definitions _________________________________________________ */
  42 +
  43 +
  44 +/*==========================================================================
  45 + = =
  46 + = Constructors/destructors =
  47 + = =
  48 + ==========================================================================*/
  49 +
  50 +/***********************************************************************//**
  51 + * @brief Void constructor
  52 + *
  53 + * Constructs an empty energy dispersion tool.
  54 + ***************************************************************************/
  55 +ctedispcube::ctedispcube(void) : ctool(CTEDISPCUBE_NAME, CTEDISPCUBE_VERSION)
  56 +{
  57 + // Initialise members
  58 + init_members();
  59 +
  60 + // Return
  61 + return;
  62 +}
  63 +
  64 +
  65 +/***********************************************************************//**
  66 + * @brief Observations constructor
  67 + *
  68 + * @param[in] obs Observation container.
  69 + *
  70 + * Constructs an energy dispersion tool from the information that is provided
  71 + * in an observation container @p obs.
  72 + ***************************************************************************/
  73 +ctedispcube::ctedispcube(const GObservations& obs) :
  74 + ctool(CTEDISPCUBE_NAME, CTEDISPCUBE_VERSION)
  75 +{
  76 + // Initialise members
  77 + init_members();
  78 +
  79 + // Set observations
  80 + m_obs = obs;
  81 +
  82 + // Return
  83 + return;
  84 +}
  85 +
  86 +
  87 +
  88 +/***********************************************************************//**
  89 + * @brief Command line constructor
  90 + *
  91 + * @param[in] argc Number of arguments in command line.
  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.
  96 + ***************************************************************************/
  97 +ctedispcube::ctedispcube(int argc, char *argv[]) :
  98 + ctool(CTEDISPCUBE_NAME, CTEDISPCUBE_VERSION, argc, argv)
  99 +{
  100 + // Initialise members
  101 + init_members();
  102 +
  103 + // Return
  104 + return;
  105 +}
  106 +
  107 +
  108 +/***********************************************************************//**
  109 + * @brief Copy constructor
  110 + *
  111 + * @param[in] app Energy dispersion tool.
  112 + *
  113 + * Constructs an energy dispersion tool by copying anothere energy
  114 + * dispersion tool.
  115 + ***************************************************************************/
  116 +ctedispcube::ctedispcube(const ctedispcube& app) : ctool(app)
  117 +{
  118 + // Initialise members
  119 + init_members();
  120 +
  121 + // Copy members
  122 + copy_members(app);
  123 +
  124 + // Return
  125 + return;
  126 +}
  127 +
  128 +
  129 +/***********************************************************************//**
  130 + * @brief Destructor
  131 + *
  132 + * Desctructs an energy dispersion tool.
  133 + ***************************************************************************/
  134 +ctedispcube::~ctedispcube(void)
  135 +{
  136 + // Free members
  137 + free_members();
  138 +
  139 + // Return
  140 + return;
  141 +}
  142 +
  143 +
  144 +/*==========================================================================
  145 + = =
  146 + = Operators =
  147 + = =
  148 + ==========================================================================*/
  149 +
  150 +/***********************************************************************//**
  151 + * @brief Assignment operator
  152 + *
  153 + * @param[in] app Energy dispersion tool.
  154 + * @return Energy dispersion tool.
  155 + *
  156 + * Assigns energy dispersion tool.
  157 + ***************************************************************************/
  158 +ctedispcube& ctedispcube::operator=(const ctedispcube& app)
  159 +{
  160 + // Execute only if object is not identical
  161 + if (this != &app) {
  162 +
  163 + // Copy base class members
  164 + this->ctool::operator=(app);
  165 +
  166 + // Free members
  167 + free_members();
  168 +
  169 + // Initialise members
  170 + init_members();
  171 +
  172 + // Copy members
  173 + copy_members(app);
  174 +
  175 + } // endif: object was not identical
  176 +
  177 + // Return this object
  178 + return *this;
  179 +}
  180 +
  181 +
  182 +/*==========================================================================
  183 + = =
  184 + = Public methods =
  185 + = =
  186 + ==========================================================================*/
  187 +
  188 +/***********************************************************************//**
  189 + * @brief Clear energy dispersion tool
  190 + *
  191 + * Set the energy disperison tool to an empty tool.
  192 + ***************************************************************************/
  193 +void ctedispcube::clear(void)
  194 +{
  195 + // Free members
  196 + free_members();
  197 + this->ctool::free_members();
  198 + this->GApplication::free_members();
  199 +
  200 + // Initialise members
  201 + this->GApplication::init_members();
  202 + this->ctool::init_members();
  203 + init_members();
  204 +
  205 + // Return
  206 + return;
  207 +}
  208 +
  209 +
  210 +/***********************************************************************//**
  211 + * @brief Generate the energy dispersion cube
  212 + *
  213 + * Generates the energy dispersion cube by looping over all unbinned CTA
  214 + * observations in the observation container.
  215 + ***************************************************************************/
  216 +void ctedispcube::run(void)
  217 +{
  218 + // If we're in debug mode then all output is also dumped on the screen
  219 + if (logDebug()) {
  220 + log.cout(true);
  221 + }
  222 +
  223 + // Get task parameters
  224 + get_parameters();
  225 +
  226 + // Write parameters into logger
  227 + if (logTerse()) {
  228 + log_parameters();
  229 + log << std::endl;
  230 + }
  231 +
  232 + // Write observation(s) into logger
  233 + if (logTerse()) {
  234 + log << std::endl;
  235 + if (m_obs.size() > 1) {
  236 + log.header1("Observations");
  237 + }
  238 + else {
  239 + log.header1("Observation");
  240 + }
  241 + log << m_obs << std::endl;
  242 + }
  243 +
  244 + // Write header
  245 + if (logTerse()) {
  246 + log << std::endl;
  247 + log.header1("Generate energy dispersion cube");
  248 + }
  249 +
  250 + // Fill Edisp
  251 + m_edispcube.fill(m_obs, &log);
  252 +
  253 + // Return
  254 + return;
  255 +}
  256 +
  257 +
  258 +/***********************************************************************//**
  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.
  263 + ***************************************************************************/
  264 +void ctedispcube::save(void)
  265 +{
  266 + // Write header
  267 + if (logTerse()) {
  268 + log << std::endl;
  269 + log.header1("Save Edisp cube");
  270 + }
  271 +
  272 + // Get output filename
  273 + m_outcube = (*this)["outcube"].filename();
  274 +
  275 + // Save only if filename is non-empty
  276 + if (!m_outcube.is_empty()) {
  277 +
  278 + // Log filename
  279 + if (logTerse()) {
  280 + log << "Save energy dispersion cube into file \""+m_outcube+"\".";
  281 + log << std::endl;
  282 + }
  283 +
  284 + // Save energy dispersion cube
  285 + m_edispcube.save(m_outcube, clobber());
  286 +
  287 + }
  288 +
  289 + // Return
  290 + return;
  291 +}
  292 +
  293 +
  294 +/*==========================================================================
  295 + = =
  296 + = Private methods =
  297 + = =
  298 + ==========================================================================*/
  299 +
  300 +/***********************************************************************//**
  301 + * @brief Initialise class members
  302 + ***************************************************************************/
  303 +void ctedispcube::init_members(void)
  304 +{
  305 + // Initialise members
  306 + m_outcube.clear();
  307 + m_obs.clear();
  308 + m_edispcube.clear();
  309 +
  310 + // Return
  311 + return;
  312 +}
  313 +
  314 +
  315 +/***********************************************************************//**
  316 + * @brief Copy class members
  317 + *
  318 + * @param[in] app Energy dispersion cube.
  319 + ***************************************************************************/
  320 +void ctedispcube::copy_members(const ctedispcube& app)
  321 +{
  322 + // Copy members
  323 + m_outcube = app.m_outcube;
  324 + m_obs = app.m_obs;
  325 + m_edispcube = app.m_edispcube;
  326 +
  327 + // Return
  328 + return;
  329 +}
  330 +
  331 +
  332 +/***********************************************************************//**
  333 + * @brief Delete class members
  334 + ***************************************************************************/
  335 +void ctedispcube::free_members(void)
  336 +{
  337 + // Return
  338 + return;
  339 +}
  340 +
  341 +
  342 +/***********************************************************************//**
  343 + * @brief Get application parameters
  344 + *
  345 + * Get all task parameters from parameter file or (if required) by querying
  346 + * the user. The parameters are read in the correct order.
  347 + ***************************************************************************/
  348 +void ctedispcube::get_parameters(void)
  349 +{
  350 + // If there are no observations in container then load them via user
  351 + // parameters
  352 + if (m_obs.size() == 0) {
  353 +
  354 + // Throw exception if no input observation file is given
  355 + require_inobs(G_GET_PARAMETERS);
  356 +
  357 + // Throw exception if counts cube is given
  358 + require_inobs_nocube(G_GET_PARAMETERS);
  359 +
  360 + // Build observation container
  361 + m_obs = get_observations();
  362 +
  363 + } // endif: there was no observation in the container
  364 +
  365 + // Get the incube filename
  366 + std::string incube = (*this)["incube"].filename();
  367 +
  368 + // Get additional binning parameters
  369 + double migramax = (*this)["migramax"].real();
  370 + int migrabins = (*this)["migrabins"].integer();
  371 +
  372 + // Check for filename validity
  373 + if ((incube == "NONE") || (gammalib::strip_whitespace(incube) == "")) {
  374 +
  375 + // Create an event cube based on task parameters
  376 + GCTAEventCube cube = create_cube(m_obs);
  377 +
  378 + // Define edisp cube
  379 + m_edispcube = GCTACubeEdisp(cube, migramax, migrabins);
  380 +
  381 + }
  382 +
  383 + // ... otherwise setup the exposure cube from the counts map
  384 + else {
  385 +
  386 + // Load event cube from filename
  387 + GCTAEventCube cube(incube);
  388 +
  389 + // Define Edisp cube
  390 + m_edispcube = GCTACubeEdisp(cube, migramax, migrabins);
  391 +
  392 + } // endelse: cube loaded from file
  393 +
  394 + // Read output filename (if needed)
  395 + if (read_ahead()) {
  396 + m_outcube = (*this)["outcube"].filename();
  397 + }
  398 +
  399 + // Return
  400 + return;
  401 +}
src/ctedispcube/ctedispcube.hpp 0 → 100644
  1 +/***************************************************************************
  2 + * ctedispcube - Energy dispersion cube generation tool *
  3 + * ----------------------------------------------------------------------- *
  4 + * copyright (C) 2016 by Maria Haupt *
  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 ctedispcube.hpp
  23 + * @brief Energy dispersion cube generation tool definition
  24 + * @author Chia-Chun Lu
  25 + */
  26 +
  27 +#ifndef CTEDISPCUBE_HPP
  28 +#define CTEDISPCUBE_HPP
  29 +
  30 +/* __ Includes ___________________________________________________________ */
  31 +#include "GammaLib.hpp"
  32 +#include "GCTALib.hpp"
  33 +#include "ctool.hpp"
  34 +
  35 +/* __Definitions _________________________________________________________ */
  36 +#define CTEDISPCUBE_NAME "ctedispcube"
  37 +#define CTEDISPCUBE_VERSION "1.1.0"
  38 +
  39 +
  40 +/***********************************************************************//**
  41 + * @class ctedispcube
  42 + *
  43 + * @brief Energy dispersion cube generation tool
  44 + ***************************************************************************/
  45 +class ctedispcube : public ctool {
  46 +
  47 +public:
  48 + // Constructors and destructors
  49 + ctedispcube(void);
  50 + explicit ctedispcube(const GObservations& obs);
  51 + ctedispcube(int argc, char *argv[]);
  52 + ctedispcube(const ctedispcube& app);
  53 + virtual ~ctedispcube(void);
  54 +
  55 + // Operators
  56 + ctedispcube& operator=(const ctedispcube& app);
  57 +
  58 + // Methods
  59 + void clear(void);
  60 + void run(void);
  61 + void save(void);
  62 + const GCTACubeEdisp& edispcube(void) const;
  63 +
  64 +protected:
  65 + // Protected methods
  66 + void init_members(void);
  67 + void copy_members(const ctedispcube& app);
  68 + void free_members(void);
  69 + void get_parameters(void);
  70 +
  71 + // User parameters
  72 + GFilename m_outcube; //!< Output energy dispersion cube file name
  73 +
  74 + // Protected members
  75 + GObservations m_obs; //!< Observation container
  76 + GCTACubeEdisp m_edispcube; //!< Energy dispersion cube
  77 +};
  78 +
  79 +
  80 +/***********************************************************************//**
  81 + * @brief Return energy dispersion cube
  82 + *
  83 + * @return Energy dispersion cube
  84 + ***************************************************************************/
  85 +inline
  86 +const GCTACubeEdisp& ctedispcube::edispcube(void) const
  87 +{
  88 + return (m_edispcube);
  89 +}
  90 +
  91 +#endif /* CTEDISPCUBE_HPP */
src/ctedispcube/ctedispcube.par 0 → 100644
  1 +#############################################################################
  2 +# #
  3 +# CTA Science Analysis Tools #
  4 +# #
  5 +# ------------------------------------------------------------------------- #
  6 +# #
  7 +# File: ctedispcube.par #
  8 +# Version: 1.1.0 #
  9 +# #
  10 +# Author: Maria Haupt #
  11 +# maria.haupt@desy.de #
  12 +# DESY #
  13 +# #
  14 +# Purpose: Parameter file for the ctedispcube application #
  15 +# #
  16 +#############################################################################
  17 +#
  18 +# Observational parameters
  19 +#===================
  20 +inobs, f, a, "NONE",,, "Input event list or observation definition XML file"
  21 +incube, f, a, "NONE",,, "Input counts cube file to extract energy dispersion cube definition"
  22 +caldb, s, a, "prod2",,, "Calibration database"
  23 +irf, s, a, "South_0.5h",,, "Instrument response function"
  24 +outcube, f, a, "edispcube.fits",,, "Output energy dispersion cube file"
  25 +
  26 +#
  27 +# Energy binning parameters
  28 +#==========================
  29 +ebinalg, s, h, "LOG", FILE|LIN|LOG,, "Algorithm for defining energy bins"
  30 +emin, r, a, 0.1,,, "Lower energy limit (TeV)"
  31 +emax, r, a, 100.0,,, "Upper energy limit (TeV)"
  32 +enumbins, i, a, 20,,, "Number of energy bins"
  33 +ebinfile, f, h, "NONE",,, "Name of the file containing the energy bin definition"
  34 +
  35 +#
  36 +# Spatial binning parameters
  37 +#===========================
  38 +usepnt, b, h, no,,, "Use pointing instead of xref/yref parameters?"
  39 +nxpix, i, a, 10,,, "Size of the X axis in pixels"
  40 +nypix, i, a, 10,,, "Size of the Y axis in pixels"
  41 +binsz, r, a, 1.0,,, "Image scale (in degrees/pixel)"
  42 +coordsys, s, a, "CEL", CEL|GAL,,"Coordinate system (CEL - celestial, GAL - galactic)"
  43 +xref, r, a, 83.63,0,360, "First coordinate of image center in degrees (RA or galactic l)"
  44 +yref, r, a, 22.01,-90,90, "Second coordinate of image center in degrees (DEC or galactic b)"
  45 +proj, s, a, "CAR", AIT|AZP|CAR|MER|MOL|STG|TAN,, "Projection method"
  46 +
  47 +#
  48 +# Angular separation binning parameters
  49 +#======================================
  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"
  52 +
  53 +#
  54 +# Standard parameters
  55 +#====================
  56 +chatter, i, h, 2,0,4, "Chattiness of output"
  57 +clobber, b, h, yes,,, "Overwrite existing output files with new output files?"
  58 +debug, b, h, no,,, "Debugging mode activated"
  59 +mode, s, h, "ql",,, "Mode of automatic parameters"
  60 +logfile, f, h, "ctedispcube.log",,, "Log filename"
src/ctedispcube/main.cpp 0 → 100644
  1 +/***************************************************************************
  2 + * ctedispcube - Energy dispersion cube generation tool *
  3 + * ----------------------------------------------------------------------- *
  4 + * copyright (C) 2016 by Maria Haupt *
  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 ctedispcube/main.cpp
  23 + * @brief Energy dispersion cube tool main code
  24 + * @author Maria Haupt
  25 + */
  26 +
  27 +/* __ Includes ___________________________________________________________ */
  28 +#ifdef HAVE_CONFIG_H
  29 +#include <config.h>
  30 +#endif
  31 +#include <cstdio>
  32 +#include "ctedispcube.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 ctedispcube application. It allocates a
  42 + * ctedispcube 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 + ctedispcube 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 + " ctedispcube. 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/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 #
@@ -23,6 +23,7 @@ inmodel, f, a, &quot;$CTOOLS/share/models/crab.xml&quot;,,, &quot;Input model XML file&quot; @@ -23,6 +23,7 @@ inmodel, f, a, &quot;$CTOOLS/share/models/crab.xml&quot;,,, &quot;Input model XML file&quot;
23 srcname, s, a, "Crab",,, "Source of interest" 23 srcname, s, a, "Crab",,, "Source of interest"
24 expcube, f, a, "NONE",,, "Input exposure cube file (only needed for stacked analysis)" 24 expcube, f, a, "NONE",,, "Input exposure cube file (only needed for stacked analysis)"
25 psfcube, f, a, "NONE",,, "Input PSF cube file (only needed for stacked analysis)" 25 psfcube, f, a, "NONE",,, "Input PSF cube file (only needed for stacked analysis)"
  26 +edispcube,f, a, "NONE",,, "Input energy dispersion cube file (only needed for stacked analysis)"
26 bkgcube, f, a, "NONE",,, "Input background cube file (only needed for stacked analysis)" 27 bkgcube, f, a, "NONE",,, "Input background cube file (only needed for stacked analysis)"
27 caldb, s, a, "prod2",,, "Calibration database" 28 caldb, s, a, "prod2",,, "Calibration database"
28 irf, s, a, "South_0.5h",,, "Instrument response function" 29 irf, s, a, "South_0.5h",,, "Instrument response function"
src/ctexpcube/ctexpcube.cpp
@@ -217,18 +217,6 @@ void ctexpcube::run(void) @@ -217,18 +217,6 @@ void ctexpcube::run(void)
217 log << std::endl; 217 log << std::endl;
218 } 218 }
219 219
220 - // Set energy dispersion flag for all CTA observations and save old  
221 - // values in save_edisp vector  
222 - std::vector<bool> save_edisp;  
223 - save_edisp.assign(m_obs.size(), false);  
224 - for (int i = 0; i < m_obs.size(); ++i) {  
225 - GCTAObservation* obs = dynamic_cast<GCTAObservation*>(m_obs[i]);  
226 - if (obs != NULL) {  
227 - save_edisp[i] = obs->response()->apply_edisp();  
228 - obs->response()->apply_edisp(m_apply_edisp);  
229 - }  
230 - }  
231 -  
232 // Write observation(s) into logger 220 // Write observation(s) into logger
233 if (logTerse()) { 221 if (logTerse()) {
234 log << std::endl; 222 log << std::endl;
@@ -250,14 +238,6 @@ void ctexpcube::run(void) @@ -250,14 +238,6 @@ void ctexpcube::run(void)
250 // Fill exposure 238 // Fill exposure
251 m_expcube.fill(m_obs, &log); 239 m_expcube.fill(m_obs, &log);
252 240
253 - // Restore energy dispersion flag for all CTA observations  
254 - for (int i = 0; i < m_obs.size(); ++i) {  
255 - GCTAObservation* obs = dynamic_cast<GCTAObservation*>(m_obs[i]);  
256 - if (obs != NULL) {  
257 - obs->response()->apply_edisp(save_edisp[i]);  
258 - }  
259 - }  
260 -  
261 // Optionally publish exposure cube 241 // Optionally publish exposure cube
262 if (m_publish) { 242 if (m_publish) {
263 publish(); 243 publish();
@@ -348,7 +328,6 @@ void ctexpcube::init_members(void) @@ -348,7 +328,6 @@ void ctexpcube::init_members(void)
348 { 328 {
349 // Initialise members 329 // Initialise members
350 m_outcube.clear(); 330 m_outcube.clear();
351 - m_apply_edisp = false;  
352 m_publish = false; 331 m_publish = false;
353 332
354 // Initialise protected members 333 // Initialise protected members
@@ -369,7 +348,6 @@ void ctexpcube::copy_members(const ctexpcube&amp; app) @@ -369,7 +348,6 @@ void ctexpcube::copy_members(const ctexpcube&amp; app)
369 { 348 {
370 // Copy attributes 349 // Copy attributes
371 m_outcube = app.m_outcube; 350 m_outcube = app.m_outcube;
372 - m_apply_edisp = app.m_apply_edisp;  
373 m_publish = app.m_publish; 351 m_publish = app.m_publish;
374 352
375 // Copy protected members 353 // Copy protected members
@@ -414,9 +392,6 @@ void ctexpcube::get_parameters(void) @@ -414,9 +392,6 @@ void ctexpcube::get_parameters(void)
414 392
415 } // endif: there was no observation in the container 393 } // endif: there was no observation in the container
416 394
417 - // Read energy dispersion flag  
418 - m_apply_edisp = (*this)["edisp"].boolean();  
419 -  
420 // Get the incube filename 395 // Get the incube filename
421 std::string incube = (*this)["incube"].filename(); 396 std::string incube = (*this)["incube"].filename();
422 397
src/ctexpcube/ctexpcube.hpp
@@ -71,7 +71,6 @@ protected: @@ -71,7 +71,6 @@ protected:
71 71
72 // User parameters 72 // User parameters
73 GFilename m_outcube; //!< Output exposure cube file 73 GFilename m_outcube; //!< Output exposure cube file
74 - bool m_apply_edisp; //!< Apply energy dispersion?  
75 bool m_publish; //!< Publish exposure cube? 74 bool m_publish; //!< Publish exposure cube?
76 75
77 // Protected members 76 // Protected members
src/ctexpcube/ctexpcube.par
@@ -21,7 +21,6 @@ inobs, f, a, &quot;NONE&quot;,,, &quot;Input event list or observation definition XML file&quot; @@ -21,7 +21,6 @@ inobs, f, a, &quot;NONE&quot;,,, &quot;Input event list or observation definition XML file&quot;
21 incube, f, a, "NONE",,, "Input counts cube file to extract exposure cube definition" 21 incube, f, a, "NONE",,, "Input counts cube file to extract exposure 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 -edisp, b, h, no,,, "Apply energy dispersion?"  
25 outcube, f, a, "expcube.fits",,, "Output exposure cube file" 24 outcube, f, a, "expcube.fits",,, "Output exposure cube file"
26 25
27 # 26 #
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 #
@@ -21,6 +21,7 @@ inobs, f, a, &quot;events.fits&quot;,,, &quot;Input event list, counts cube or observ @@ -21,6 +21,7 @@ inobs, f, a, &quot;events.fits&quot;,,, &quot;Input event list, counts cube or observ
21 inmodel, f, a, "$CTOOLS/share/models/crab.xml",,, "Input model XML file" 21 inmodel, f, a, "$CTOOLS/share/models/crab.xml",,, "Input model XML file"
22 expcube, f, a, "NONE",,, "Input exposure cube file (only needed for stacked analysis)" 22 expcube, f, a, "NONE",,, "Input exposure cube file (only needed for stacked analysis)"
23 psfcube, f, a, "NONE",,, "Input PSF cube file (only needed for stacked analysis)" 23 psfcube, f, a, "NONE",,, "Input PSF cube file (only needed for stacked analysis)"
  24 +edispcube, f, a, "NONE",,, "Input energy dispersion cube file (only needed for stacked analysis)"
24 bkgcube, f, a, "NONE",,, "Input background cube file (only needed for stacked analysis)" 25 bkgcube, f, a, "NONE",,, "Input background cube file (only needed for stacked analysis)"
25 caldb, s, a, "prod2",,, "Calibration database" 26 caldb, s, a, "prod2",,, "Calibration database"
26 irf, s, a, "South_0.5h",,, "Instrument response function" 27 irf, s, a, "South_0.5h",,, "Instrument response function"
src/ctmodel/ctmodel.par
@@ -22,6 +22,7 @@ incube, f, a, &quot;NONE&quot;,,, &quot;Input counts cube file to extract model cube definiti @@ -22,6 +22,7 @@ incube, f, a, &quot;NONE&quot;,,, &quot;Input counts cube file to extract model cube definiti
22 inmodel, f, a, "$CTOOLS/share/models/crab.xml",,, "Input model XML file" 22 inmodel, f, a, "$CTOOLS/share/models/crab.xml",,, "Input model XML file"
23 expcube, f, a, "NONE",,, "Input exposure cube file (only needed for stacked analysis)" 23 expcube, f, a, "NONE",,, "Input exposure cube file (only needed for stacked analysis)"
24 psfcube, f, a, "NONE",,, "Input PSF cube file (only needed for stacked analysis)" 24 psfcube, f, a, "NONE",,, "Input PSF cube file (only needed for stacked analysis)"
  25 +edispcube,f, a, "NONE",,, "Input energy dispersion cube file (only needed for stacked analysis)"
25 bkgcube, f, a, "NONE",,, "Input background cube file (only needed for stacked analysis)" 26 bkgcube, f, a, "NONE",,, "Input background cube file (only needed for stacked analysis)"
26 caldb, s, a, "prod2",,, "Calibration database" 27 caldb, s, a, "prod2",,, "Calibration database"
27 irf, s, a, "South_0.5h",,, "Instrument response function" 28 irf, s, a, "South_0.5h",,, "Instrument response function"
src/ctpsfcube/ctpsfcube.cpp
@@ -216,18 +216,6 @@ void ctpsfcube::run(void) @@ -216,18 +216,6 @@ void ctpsfcube::run(void)
216 log << std::endl; 216 log << std::endl;
217 } 217 }
218 218
219 - // Set energy dispersion flag for all CTA observations and save old  
220 - // values in save_edisp vector  
221 - std::vector<bool> save_edisp;  
222 - save_edisp.assign(m_obs.size(), false);  
223 - for (int i = 0; i < m_obs.size(); ++i) {  
224 - GCTAObservation* obs = dynamic_cast<GCTAObservation*>(m_obs[i]);  
225 - if (obs != NULL) {  
226 - save_edisp[i] = obs->response()->apply_edisp();  
227 - obs->response()->apply_edisp(m_apply_edisp);  
228 - }  
229 - }  
230 -  
231 // Write observation(s) into logger 219 // Write observation(s) into logger
232 if (logTerse()) { 220 if (logTerse()) {
233 log << std::endl; 221 log << std::endl;
@@ -249,14 +237,6 @@ void ctpsfcube::run(void) @@ -249,14 +237,6 @@ void ctpsfcube::run(void)
249 // Fill PSF 237 // Fill PSF
250 m_psfcube.fill(m_obs, &log); 238 m_psfcube.fill(m_obs, &log);
251 239
252 - // Restore energy dispersion flag for all CTA observations  
253 - for (int i = 0; i < m_obs.size(); ++i) {  
254 - GCTAObservation* obs = dynamic_cast<GCTAObservation*>(m_obs[i]);  
255 - if (obs != NULL) {  
256 - obs->response()->apply_edisp(save_edisp[i]);  
257 - }  
258 - }  
259 -  
260 // Return 240 // Return
261 return; 241 return;
262 } 242 }
@@ -308,7 +288,6 @@ void ctpsfcube::init_members(void) @@ -308,7 +288,6 @@ void ctpsfcube::init_members(void)
308 { 288 {
309 // Initialise members 289 // Initialise members
310 m_outcube.clear(); 290 m_outcube.clear();
311 - m_apply_edisp = false;  
312 291
313 // Initialise protected members 292 // Initialise protected members
314 m_obs.clear(); 293 m_obs.clear();
@@ -328,7 +307,6 @@ void ctpsfcube::copy_members(const ctpsfcube&amp; app) @@ -328,7 +307,6 @@ void ctpsfcube::copy_members(const ctpsfcube&amp; app)
328 { 307 {
329 // Copy attributes 308 // Copy attributes
330 m_outcube = app.m_outcube; 309 m_outcube = app.m_outcube;
331 - m_apply_edisp = app.m_apply_edisp;  
332 310
333 // Copy protected members 311 // Copy protected members
334 m_obs = app.m_obs; 312 m_obs = app.m_obs;
@@ -401,9 +379,6 @@ void ctpsfcube::get_parameters(void) @@ -401,9 +379,6 @@ void ctpsfcube::get_parameters(void)
401 379
402 } // endelse: cube loaded from file 380 } // endelse: cube loaded from file
403 381
404 - // Read energy dispersion flag  
405 - m_apply_edisp = (*this)["edisp"].boolean();  
406 -  
407 // Read output filename (if needed) 382 // Read output filename (if needed)
408 if (read_ahead()) { 383 if (read_ahead()) {
409 m_outcube = (*this)["outcube"].filename(); 384 m_outcube = (*this)["outcube"].filename();
src/ctpsfcube/ctpsfcube.hpp
@@ -70,7 +70,6 @@ protected: @@ -70,7 +70,6 @@ protected:
70 70
71 // User parameters 71 // User parameters
72 GFilename m_outcube; //!< Output PSF cube file name 72 GFilename m_outcube; //!< Output PSF cube file name
73 - bool m_apply_edisp; //!< Apply energy dispersion?  
74 73
75 // Protected members 74 // Protected members
76 GObservations m_obs; //!< Observation container 75 GObservations m_obs; //!< Observation container
src/ctpsfcube/ctpsfcube.par
@@ -21,7 +21,6 @@ inobs, f, a, &quot;NONE&quot;,,, &quot;Input event list or observation definition XML file&quot; @@ -21,7 +21,6 @@ inobs, f, a, &quot;NONE&quot;,,, &quot;Input event list or observation definition XML file&quot;
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 PSF 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 -edisp, b, h, no,,, "Apply energy dispersion?"  
25 outcube, f, a, "psfcube.fits",,, "Output PSF cube file" 24 outcube, f, a, "psfcube.fits",,, "Output PSF cube file"
26 25
27 # 26 #
src/cttsmap/cttsmap.par
@@ -17,35 +17,36 @@ @@ -17,35 +17,36 @@
17 # 17 #
18 # General parameters 18 # General parameters
19 #=================== 19 #===================
20 -inobs, f, a, "events.fits",,, "Input event list, counts cube or observation definition XML file"  
21 -inmodel, f, a, "$CTOOLS/share/models/crab.xml",,, "Input model XML file"  
22 -srcname, s, a, "Crab",,, "Test source name"  
23 -expcube, f, a, "NONE",,, "Input exposure cube file (only needed for stacked analysis)"  
24 -psfcube, f, a, "NONE",,, "Input PSF cube file (only needed for stacked analysis)"  
25 -bkgcube, f, a, "NONE",,, "Input background cube file (only needed for stacked analysis)"  
26 -caldb, s, a, "prod2",,, "Calibration database"  
27 -irf, s, a, "South_0.5h",,, "Instrument response function"  
28 -edisp, b, h, no,,, "Apply energy dispersion?"  
29 -outmap, f, a, "tsmap.fits",,, "Output Test Statistic map file" 20 +inobs, f, a, "events.fits",,, "Input event list, counts cube or observation definition XML file"
  21 +inmodel, f, a, "$CTOOLS/share/models/crab.xml",,, "Input model XML file"
  22 +srcname, s, a, "Crab",,, "Test source name"
  23 +expcube, f, a, "NONE",,, "Input exposure cube file (only needed for stacked analysis)"
  24 +psfcube, f, a, "NONE",,, "Input PSF cube file (only needed for stacked analysis)"
  25 +edispcube, f, a, "NONE",,, "Input energy dispersion cube file (only needed for stacked analysis)"
  26 +bkgcube, f, a, "NONE",,, "Input background cube file (only needed for stacked analysis)"
  27 +caldb, s, a, "prod2",,, "Calibration database"
  28 +irf, s, a, "South_0.5h",,, "Instrument response function"
  29 +edisp, b, h, no,,, "Apply energy dispersion?"
  30 +outmap, f, a, "tsmap.fits",,, "Output Test Statistic map file"
30 31
31 # 32 #
32 # Spatial binning parameters 33 # Spatial binning parameters
33 #=========================== 34 #===========================
34 -usepnt, b, h, no,,, "Use pointing instead of xref/yref parameters?"  
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,0,360, "First coordinate of image center in degrees (RA or galactic l)"  
40 -yref, r, a, 22.01,-90,90, "Second coordinate of image center in degrees (DEC or galactic b)"  
41 -proj, s, a, "CAR", AIT|AZP|CAR|MER|MOL|STG|TAN,, "Projection method" 35 +usepnt, b, h, no,,, "Use pointing instead of xref/yref parameters?"
  36 +nxpix, i, a, 200,,, "Size of the X axis in pixels"
  37 +nypix, i, a, 200,,, "Size of the Y axis in pixels"
  38 +binsz, r, a, 0.02,,, "Image scale (in degrees/pixel)"
  39 +coordsys, s, a, "CEL", CEL|GAL,,"Coordinate system (CEL - celestial, GAL - galactic)"
  40 +xref, r, a, 83.63,0,360, "First coordinate of image center in degrees (RA or galactic l)"
  41 +yref, r, a, 22.01,-90,90, "Second coordinate of image center in degrees (DEC or galactic b)"
  42 +proj, s, a, "CAR", AIT|AZP|CAR|MER|MOL|STG|TAN,, "Projection method"
42 43
43 # 44 #
44 # Parameters for splitting and speed purpose 45 # Parameters for splitting and speed purpose
45 #=========================== 46 #===========================
46 -binmin, i, h, -1,,, "First bin to compute"  
47 -binmax, i, h, -1,,, "Last bin to compute"  
48 -logL0, r, h, 0.0,,, "LogLikelihood value of null hypothesis" 47 +binmin, i, h, -1,,, "First bin to compute"
  48 +binmax, i, h, -1,,, "Last bin to compute"
  49 +logL0, r, h, 0.0,,, "LogLikelihood value of null hypothesis"
49 50
50 # 51 #
51 # Standard parameters 52 # Standard parameters
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 #
@@ -22,6 +22,7 @@ inmodel, f, a, &quot;$CTOOLS/share/models/crab.xml&quot;,,, &quot;Input model XML file&quot; @@ -22,6 +22,7 @@ inmodel, f, a, &quot;$CTOOLS/share/models/crab.xml&quot;,,, &quot;Input model XML file&quot;
22 srcname, s, a, "Crab",,, "Source of interest" 22 srcname, s, a, "Crab",,, "Source of interest"
23 expcube, f, a, "NONE",,, "Input exposure cube file (only needed for stacked analysis)" 23 expcube, f, a, "NONE",,, "Input exposure cube file (only needed for stacked analysis)"
24 psfcube, f, a, "NONE",,, "Input PSF cube file (only needed for stacked analysis)" 24 psfcube, f, a, "NONE",,, "Input PSF cube file (only needed for stacked analysis)"
  25 +edispcube,f, a, "NONE",,, "Input energy dispersion cube file (only needed for stacked analysis)"
25 bkgcube, f, a, "NONE",,, "Input background cube file (only needed for stacked analysis)" 26 bkgcube, f, a, "NONE",,, "Input background cube file (only needed for stacked analysis)"
26 caldb, s, a, "prod2",,, "Calibration database" 27 caldb, s, a, "prod2",,, "Calibration database"
27 irf, s, a, "South_0.5h",,, "Instrument response function" 28 irf, s, a, "South_0.5h",,, "Instrument response function"
src/support/ctool.cpp
@@ -862,15 +862,18 @@ void ctool::set_obs_response(GCTAObservation* obs) @@ -862,15 +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")) { 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();  
870 - std::string bkgcube = (*this)["bkgcube"].filename(); 869 + std::string expcube = (*this)["expcube"].filename();
  870 + std::string psfcube = (*this)["psfcube"].filename();
  871 + std::string edispcube = (*this)["edispcube"].filename();
  872 + std::string bkgcube = (*this)["bkgcube"].filename();
871 873
872 // Extract response information if available 874 // Extract response information if available
873 - if ((expcube != "NONE") && (psfcube != "NONE") && (bkgcube != "NONE") && 875 + if ((expcube != "NONE") && (psfcube != "NONE") &&
  876 + (bkgcube != "NONE") &&
874 (gammalib::strip_whitespace(expcube) != "") && 877 (gammalib::strip_whitespace(expcube) != "") &&
875 (gammalib::strip_whitespace(psfcube) != "") && 878 (gammalib::strip_whitespace(psfcube) != "") &&
876 (gammalib::strip_whitespace(bkgcube) != "")) { 879 (gammalib::strip_whitespace(bkgcube) != "")) {
@@ -880,8 +883,16 @@ void ctool::set_obs_response(GCTAObservation* obs) @@ -880,8 +883,16 @@ void ctool::set_obs_response(GCTAObservation* obs)
880 GCTACubePsf psf(psfcube); 883 GCTACubePsf psf(psfcube);
881 GCTACubeBackground background(bkgcube); 884 GCTACubeBackground background(bkgcube);
882 885
883 - // Set reponse  
884 - obs->response(exposure, psf, background); 886 + // Optionally load energy dispersion cube
  887 + if ((edispcube != "NONE") &&
  888 + (gammalib::strip_whitespace(edispcube) != "")) {
  889 + GCTACubeEdisp edisp(edispcube);
  890 + obs->response(exposure, psf, edisp, background);
  891 + }
  892 + else {
  893 + // Set reponse
  894 + obs->response(exposure, psf, background);
  895 + }
885 896
886 // Signal response availability 897 // Signal response availability
887 has_response = true; 898 has_response = true;
@@ -904,8 +915,9 @@ void ctool::set_obs_response(GCTAObservation* obs) @@ -904,8 +915,9 @@ void ctool::set_obs_response(GCTAObservation* obs)
904 // to the observation definition XML file, in case an observation 915 // to the observation definition XML file, in case an observation
905 // definition XML file is written. 916 // definition XML file is written.
906 std::string parameter = "parameter name=\"Calibration\"" 917 std::string parameter = "parameter name=\"Calibration\""
907 - " database=\""+database+"\""  
908 - " response=\""+irf+"\""; 918 + " database=\""+database+"\""
  919 + " response=\""+irf+"\"";
  920 +
909 GXmlElement xml; 921 GXmlElement xml;
910 xml.append(parameter); 922 xml.append(parameter);
911 923
@@ -915,22 +927,6 @@ void ctool::set_obs_response(GCTAObservation* obs) @@ -915,22 +927,6 @@ void ctool::set_obs_response(GCTAObservation* obs)
915 // Attach response to observation 927 // Attach response to observation
916 obs->response(response); 928 obs->response(response);
917 929
918 - // Set calibration database. If "database" is a valid directory then use  
919 - // this as the pathname to the calibration database. Otherwise, interpret  
920 - // "database" as the instrument name, the mission being "cta"  
921 - /*  
922 - GCaldb caldb;  
923 - if (gammalib::dir_exists(database)) {  
924 - caldb.rootdir(database);  
925 - }  
926 - else {  
927 - caldb.open("cta", database);  
928 - }  
929 - */  
930 -  
931 - // Set reponse  
932 - //obs->response(irf, caldb);  
933 -  
934 // Signal response availability 930 // Signal response availability
935 has_response = true; 931 has_response = true;
936 932
@@ -967,11 +963,13 @@ void ctool::set_obs_bounds(GObservations&amp; obs) @@ -967,11 +963,13 @@ void ctool::set_obs_bounds(GObservations&amp; obs)
967 // parameters and add them 963 // parameters and add them
968 if (list->ebounds().is_empty()) { 964 if (list->ebounds().is_empty()) {
969 965
970 - // If there are "emin" and "emax" parameters then use them 966 + // If there are "emin" and "emax" parameters then use
  967 + // them
971 if (has_par("emin") && has_par("emax")) { 968 if (has_par("emin") && has_par("emax")) {
972 double emin = (*this)["emin"].real(); 969 double emin = (*this)["emin"].real();
973 double emax = (*this)["emax"].real(); 970 double emax = (*this)["emax"].real();
974 - GEbounds ebounds(GEnergy(emin, "TeV"), GEnergy(emax, "TeV")); 971 + GEbounds ebounds(GEnergy(emin, "TeV"),
  972 + GEnergy(emax, "TeV"));
975 list->ebounds(ebounds); 973 list->ebounds(ebounds);
976 } 974 }
977 975
@@ -996,7 +994,6 @@ void ctool::set_obs_bounds(GObservations&amp; obs) @@ -996,7 +994,6 @@ void ctool::set_obs_bounds(GObservations&amp; obs)
996 994
997 } // endfor: looped over observations 995 } // endfor: looped over observations
998 996
999 -  
1000 // Return 997 // Return
1001 return; 998 return;
1002 } 999 }
@@ -1126,7 +1123,7 @@ void ctool::provide_help(void) const @@ -1126,7 +1123,7 @@ void ctool::provide_help(void) const
1126 char* ptr = std::getenv("CTOOLS"); 1123 char* ptr = std::getenv("CTOOLS");
1127 if (ptr == NULL) { 1124 if (ptr == NULL) {
1128 std::string msg = "CTOOLS environment variable not set, cannot " 1125 std::string msg = "CTOOLS environment variable not set, cannot "
1129 - "display help file. Please define CTOOLS " 1126 + "display help file. Please set the CTOOLS "
1130 "environment variable."; 1127 "environment variable.";
1131 throw GException::invalid_value(G_PROVIDE_HELP, msg); 1128 throw GException::invalid_value(G_PROVIDE_HELP, msg);
1132 } 1129 }
test/data/crab_edispcube.fits.gz 0 → 100644
No preview for this file type
test/test_cscripts.sh.in
@@ -405,6 +405,7 @@ fi @@ -405,6 +405,7 @@ fi
405 inobs="data/crab_cntmap_small.fits.gz" \ 405 inobs="data/crab_cntmap_small.fits.gz" \
406 expcube="data/crab_expcube.fits.gz" \ 406 expcube="data/crab_expcube.fits.gz" \
407 psfcube="data/crab_psfcube.fits.gz" \ 407 psfcube="data/crab_psfcube.fits.gz" \
  408 + edispcube="data/crab_edispcube.fits.gz" \
408 bkgcube="data/crab_bkgcube.fits.gz" \ 409 bkgcube="data/crab_bkgcube.fits.gz" \
409 inmodel="data/crab_bkgcube.xml" \ 410 inmodel="data/crab_bkgcube.xml" \
410 ebinalg="LOG" \ 411 ebinalg="LOG" \
test/test_ctedispcube.py 0 → 100755
  1 +#! /usr/bin/env python
  2 +# ==========================================================================
  3 +# This scripts performs unit tests for the ctedispcube tool.
  4 +#
  5 +# Copyright (C) 2016 Maria Haupt
  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 ctedispcube tool #
  27 +# ============================= #
  28 +class Test(gammalib.GPythonTestSuite):
  29 + """
  30 + Test class for ctedispcube 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.caldb = "irf"
  43 + self.irf = "cta_dummy_irf"
  44 +
  45 + # Return
  46 + return
  47 +
  48 + # Set test functions
  49 + def set(self):
  50 + """
  51 + Set all test functions.
  52 + """
  53 + # Set test name
  54 + self.name("ctedispcube")
  55 +
  56 + # Append tests
  57 + self.append(self.test_functional, "Test ctedispcube functionality")
  58 +
  59 + # Return
  60 + return
  61 +
  62 + # Test ctedispcube functionnality
  63 + def test_functional(self):
  64 + """
  65 + Test ctedispcube functionnality.
  66 + """
  67 + # Set-up 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["migramax"] = 2.0
  86 + edispcube["migrabins"] = 10
  87 +
  88 + # Run tool
  89 + self.test_try("Run ctedispcube")
  90 + try:
  91 + edispcube.run()
  92 + self.test_try_success()
  93 + #except Exception as e:
  94 + # msg = "Exception occured in ctedispcube: %s." % (e,)
  95 + except:
  96 + msg = "Exception occured in ctedispcube."
  97 + self.test_try_failure(msg)
  98 +
  99 + # Save EDISP cube
  100 + self.test_try("Save EDISP cube")
  101 + try:
  102 + edispcube.save()
  103 + self.test_try_success()
  104 + #except Exception as e:
  105 + # msg = "Exception occured in saving EDISP cube: %s." % (e,)
  106 + except:
  107 + msg = "Exception occured in saving EDISP cubes."
  108 + self.test_try_failure(msg)
  109 +
  110 + # Return
  111 + return
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
@@ -43,6 +43,7 @@ ctselect=../src/ctselect/ctselect @@ -43,6 +43,7 @@ ctselect=../src/ctselect/ctselect
43 ctskymap=../src/ctskymap/ctskymap 43 ctskymap=../src/ctskymap/ctskymap
44 ctexpcube=../src/ctexpcube/ctexpcube 44 ctexpcube=../src/ctexpcube/ctexpcube
45 ctpsfcube=../src/ctpsfcube/ctpsfcube 45 ctpsfcube=../src/ctpsfcube/ctpsfcube
  46 +ctedispcube=../src/ctedispcube/ctedispcube
46 ctbkgcube=../src/ctbkgcube/ctbkgcube 47 ctbkgcube=../src/ctbkgcube/ctbkgcube
47 ctcubemask=../src/ctcubemask/ctcubemask 48 ctcubemask=../src/ctcubemask/ctcubemask
48 ctbutterfly=../src/ctbutterfly/ctbutterfly 49 ctbutterfly=../src/ctbutterfly/ctbutterfly
@@ -272,6 +273,57 @@ $ECHO &quot; ok&quot; @@ -272,6 +273,57 @@ $ECHO &quot; ok&quot;
272 273
273 274
274 # 275 #
  276 +# Test ctedispcube
  277 +# ==============
  278 +$ECHO -n "Test ctedispcube: "
  279 +#
  280 +# Run 1
  281 +$ctedispcube inobs="data/crab_events.fits" \
  282 + incube="NONE" \
  283 + outcube="edispcube1.fits" \
  284 + caldb="irf" \
  285 + irf="cta_dummy_irf" \
  286 + emin=0.1 \
  287 + emax=100.0 \
  288 + enumbins=20 \
  289 + nxpix=10 \
  290 + nypix=10 \
  291 + binsz=0.4 \
  292 + coordsys="CEL" \
  293 + xref=83.63 \
  294 + yref=22.01 \
  295 + proj="CAR" \
  296 + migramax=3.0 \
  297 + migrabins=10
  298 +$ECHO -n "."
  299 +if [ -s "edispcube1.fits" ]
  300 +then
  301 +$ECHO -n "."
  302 +else
  303 +$ECHO " edispcube1.fits file is not found"
  304 +exit 1
  305 +fi
  306 +#
  307 +# Run 2
  308 +$ctedispcube inobs="events.fits" \
  309 + incube="cntmap2.fits" \
  310 + outcube="edispcube2.fits" \
  311 + caldb="irf" \
  312 + irf="cta_dummy_irf" \
  313 + migramax=3.0 \
  314 + migrabins=3
  315 +$ECHO -n "."
  316 +if [ -s "edispcube2.fits" ]
  317 +then
  318 +$ECHO -n "."
  319 +else
  320 +$ECHO " edispcube2.fits file is not found"
  321 +exit 1
  322 +fi
  323 +$ECHO " ok"
  324 +
  325 +
  326 +#
275 # Test ctbkgcube 327 # Test ctbkgcube
276 # ============== 328 # ==============
277 $ECHO -n "Test ctbkgcube: " 329 $ECHO -n "Test ctbkgcube: "
@@ -336,7 +388,6 @@ fi @@ -336,7 +388,6 @@ fi
336 $ECHO " ok" 388 $ECHO " ok"
337 389
338 390
339 -  
340 # 391 #
341 # Test ctmodel 392 # Test ctmodel
342 # ============ 393 # ============
@@ -349,6 +400,7 @@ $ctmodel inobs=&quot;cntmap1.fits&quot; \ @@ -349,6 +400,7 @@ $ctmodel inobs=&quot;cntmap1.fits&quot; \
349 expcube="NONE" \ 400 expcube="NONE" \
350 psfcube="NONE" \ 401 psfcube="NONE" \
351 bkgcube="NONE" \ 402 bkgcube="NONE" \
  403 + edispcube="NONE" \
352 caldb="irf" \ 404 caldb="irf" \
353 irf="cta_dummy_irf" \ 405 irf="cta_dummy_irf" \
354 inmodel="data/crab.xml" 406 inmodel="data/crab.xml"
@@ -368,6 +420,7 @@ $ctmodel inobs=&quot;cntmap2.fits&quot; \ @@ -368,6 +420,7 @@ $ctmodel inobs=&quot;cntmap2.fits&quot; \
368 outcube="modmap2.fits" \ 420 outcube="modmap2.fits" \
369 expcube="expcube2.fits" \ 421 expcube="expcube2.fits" \
370 psfcube="psfcube2.fits" \ 422 psfcube="psfcube2.fits" \
  423 + edispcube="edispcube2.fits" \
371 bkgcube="bkgcube2.fits" \ 424 bkgcube="bkgcube2.fits" \
372 caldb="irf" \ 425 caldb="irf" \
373 irf="cta_dummy_irf" \ 426 irf="cta_dummy_irf" \
@@ -388,6 +441,7 @@ $ctmodel inobs=&quot;NONE&quot; \ @@ -388,6 +441,7 @@ $ctmodel inobs=&quot;NONE&quot; \
388 outcube="modmap3.fits" \ 441 outcube="modmap3.fits" \
389 expcube="NONE" \ 442 expcube="NONE" \
390 psfcube="NONE" \ 443 psfcube="NONE" \
  444 + edispcube="NONE" \
391 bkgcube="NONE" \ 445 bkgcube="NONE" \
392 caldb="irf" \ 446 caldb="irf" \
393 irf="cta_dummy_irf" \ 447 irf="cta_dummy_irf" \
@@ -453,6 +507,7 @@ $ctlike inobs=&quot;cntmap1.fits&quot; \ @@ -453,6 +507,7 @@ $ctlike inobs=&quot;cntmap1.fits&quot; \
453 outmodel="results_binned.xml" \ 507 outmodel="results_binned.xml" \
454 expcube="NONE" \ 508 expcube="NONE" \
455 psfcube="NONE" \ 509 psfcube="NONE" \
  510 + edispcube="NONE" \
456 bkgcube="NONE" \ 511 bkgcube="NONE" \
457 caldb="irf" \ 512 caldb="irf" \
458 irf="cta_dummy_irf" 513 irf="cta_dummy_irf"
@@ -487,6 +542,7 @@ $ctlike inobs=&quot;cntmap2.fits&quot; \ @@ -487,6 +542,7 @@ $ctlike inobs=&quot;cntmap2.fits&quot; \
487 outmodel="results_binned_cube_background.xml" \ 542 outmodel="results_binned_cube_background.xml" \
488 expcube="expcube2.fits" \ 543 expcube="expcube2.fits" \
489 psfcube="psfcube2.fits" \ 544 psfcube="psfcube2.fits" \
  545 + edispcube="NONE" \
490 bkgcube="bkgcube2.fits" \ 546 bkgcube="bkgcube2.fits" \
491 caldb="irf" \ 547 caldb="irf" \
492 irf="cta_dummy_irf" 548 irf="cta_dummy_irf"
@@ -498,6 +554,28 @@ else @@ -498,6 +554,28 @@ else
498 $ECHO " results_binned_cube_background.xml file is not found" 554 $ECHO " results_binned_cube_background.xml file is not found"
499 exit 1 555 exit 1
500 fi 556 fi
  557 +
  558 +
  559 +#
  560 +# Run 4
  561 +$ctlike inobs="cntmap2.fits" \
  562 + inmodel="bkgcube2.xml" \
  563 + outmodel="results_binned_cube_background_edisp.xml" \
  564 + expcube="expcube2.fits" \
  565 + psfcube="psfcube2.fits" \
  566 + edispcube="edispcube2.fits" \
  567 + bkgcube="bkgcube2.fits" \
  568 + edisp="yes"
  569 + caldb="irf" \
  570 + irf="cta_dummy_irf"
  571 +$ECHO -n "."
  572 +if [ -s "results_binned_cube_background_edisp.xml" ]
  573 +then
  574 + $ECHO -n "."
  575 +else
  576 + $ECHO " results_binned_cube_background_edisp.xml file is not found"
  577 + exit 1
  578 +fi
501 $ECHO " ok" 579 $ECHO " ok"
502 580
503 581
@@ -529,8 +607,6 @@ fi @@ -529,8 +607,6 @@ fi
529 $ECHO " ok" 607 $ECHO " ok"
530 608
531 609
532 -  
533 -  
534 # 610 #
535 # Test ctcubemask 611 # Test ctcubemask
536 # =============== 612 # ===============