Commit a4075c609e43cdb037dde85db6f142865c8b3c80

Authored by Jürgen Knödlseder
1 parent 73b1c340

Integrate ctpsfcube tool.

* Checked the code for coding conventions.
* Renamed the angular seperation user parameters to amax and anumbins. "a" stands for angular separation, "d" for delta is less explicit.
* Add ctpsfcube executable unit test
.gitignore
... ... @@ -53,6 +53,7 @@ src/ctobssim/ctobssim
53 53 src/ctselect/ctselect
54 54 src/ctskymap/ctskymap
55 55 src/ctexpcube/ctexpcube
  56 +src/ctpsfcube/ctpsfcube
56 57 src/ctcubemask/ctcubemask
57 58 test/pfiles/
58 59 test/*.fits
... ...
ChangeLog
... ... @@ -5,8 +5,9 @@
5 5  
6 6 Adapt to GammaLib 0.9.0 interface
7 7 ctbin now always merges event lists into a single counts cube
8   - Add ctexpcube tool
9   - Add ctcubemask tool
  8 + Add ctexpcube tool (generates exposure cube)
  9 + Add ctpsfcube tool (generated PSF cube)
  10 + Add ctcubemask tool (masks event bins in event cube)
10 11 Support energy dispersion in ctobssim, ctlike and ctmodel
11 12 Correct ctobssim for thread safety
12 13 Enhance documentation
... ...
... ... @@ -80,27 +80,37 @@ the use for 2D response functions in FITS files.
80 80 ctmodel now also supports the handling of energy dispersion. Energy
81 81 dispersion can be switched on or off using the hidden edisp parameter.
82 82  
83   -10. ctexpcube - CTA exposure cube
84   ----------------------------------
  83 +
  84 +10. ctexpcube - CTA exposure cube generation
  85 +--------------------------------------------
85 86 The first version of the ctexpcube tool is included in the release.
86 87 ctexpcube computes the exposure cube for an observation definition
87   -file. The cube definition may be taken from a counts map or may be
  88 +file. The cube definition may be taken from a counts cube or may be
88 89 specified by user parameters.
89 90  
90 91  
91   -11. ctcubemask - CTA cube filtering
  92 +11. ctpsfcube - CTA point spread function cube generation
  93 +---------------------------------------------------------
  94 +The first version of the ctpsfcube tool is included in the release.
  95 +ctpsfcube computes the point spread function cube for an observation
  96 +definition file. The cube definition may be taken from a counts cube
  97 +or may be specified by user parameters.
  98 +
  99 +
  100 +12. ctcubemask - CTA cube filtering
92 101 -----------------------------------
93 102 The first version of the ctcubemask tool is included in the release.
94 103 ctcubemask allows filtering of bins in a counts cube by setting the
95 104 bin content to -1. Filtering can be done by energy, for a circular
96 105 Region of Interest (ROI) or using ds9 exclusion regions.
97 106  
98   -12. Examples
  107 +
  108 +13. Examples
99 109 ------------
100 110 None
101 111  
102 112  
103   -13. Scripts
  113 +14. Scripts
104 114 -----------
105 115 Add logL and event statistics to cspull output file.
106 116  
... ... @@ -109,11 +119,11 @@ Convert all tabs into spaces.
109 119 The obsutils script has now been moved into the ctools module namespace.
110 120  
111 121  
112   -14. caldb
  122 +15. caldb
113 123 ---------
114 124 None
115 125  
116 126  
117   -15. models
  127 +16. models
118 128 ----------
119 129 None
... ...
pyext/ctcubemask.i
1 1 /***************************************************************************
2   - * ctcubemask.i - CTA mask cube tool *
  2 + * ctcubemask - CTA mask cube tool *
3 3 * ----------------------------------------------------------------------- *
4 4 * copyright (C) 2014 Chia-Chun Lu *
5 5 * ----------------------------------------------------------------------- *
... ... @@ -39,7 +39,7 @@ class ctcubemask : public GApplication {
39 39 public:
40 40 // Constructors and destructors
41 41 ctcubemask(void);
42   - explicit ctcubemask(GObservations obs);
  42 + explicit ctcubemask(const GObservations& obs);
43 43 ctcubemask(int argc, char *argv[]);
44 44 ctcubemask(const ctcubemask& app);
45 45 virtual ~ctcubemask(void);
... ...
pyext/ctpsfcube.i
1 1 /***************************************************************************
2   - * ctpsfcube - CTA PSF cube tool *
  2 + * ctpsfcube - CTA PSF cube tool *
3 3 * ----------------------------------------------------------------------- *
4 4 * copyright (C) 2014 by Chia-Chun Lu *
5 5 * ----------------------------------------------------------------------- *
... ... @@ -40,7 +40,7 @@ class ctpsfcube : public GApplication {
40 40 public:
41 41 // Constructors and destructors
42 42 ctpsfcube(void);
43   - explicit ctpsfcube(GObservations obs);
  43 + explicit ctpsfcube(const GObservations& obs);
44 44 ctpsfcube(int argc, char *argv[]);
45 45 ctpsfcube(const ctpsfcube& app);
46 46 virtual ~ctpsfcube(void);
... ...
src/ctcubemask/ctcubemask.cpp
1 1 /***************************************************************************
2   - * ctcubemask.cpp - CTA cube filter tool *
  2 + * ctcubemask - CTA cube filter tool *
3 3 * ----------------------------------------------------------------------- *
4 4 * copyright (C) 2014 by Chia-Chun Lu *
5 5 * ----------------------------------------------------------------------- *
... ... @@ -70,7 +70,8 @@ ctcubemask::ctcubemask(void) : GApplication(CTCUBEMASK_NAME, CTCUBEMASK_VERSION)
70 70 * This constructor creates an instance of the class that is initialised from
71 71 * an observation container.
72 72 ***************************************************************************/
73   -ctcubemask::ctcubemask(GObservations obs) : GApplication(CTCUBEMASK_NAME, CTCUBEMASK_VERSION)
  73 +ctcubemask::ctcubemask(const GObservations& obs) :
  74 + GApplication(CTCUBEMASK_NAME, CTCUBEMASK_VERSION)
74 75 {
75 76 // Initialise members
76 77 init_members();
... ... @@ -302,7 +303,7 @@ void ctcubemask::run(void)
302 303 // Write observation(s) into logger
303 304 if (logTerse()) {
304 305 log << std::endl;
305   - log.header1("Observations after masked");
  306 + log.header1("Observations after event bin masking");
306 307 log << m_obs << std::endl;
307 308 }
308 309  
... ...
src/ctcubemask/ctcubemask.hpp
1 1 /***************************************************************************
2   - * ctcubemask.hpp - CTA cube filter tool *
  2 + * ctcubemask - CTA cube filter tool *
3 3 * ----------------------------------------------------------------------- *
4 4 * copyright (C) 2014 by Chia-Chun Lu *
5 5 * ----------------------------------------------------------------------- *
... ... @@ -47,7 +47,7 @@ class ctcubemask : public GApplication {
47 47 public:
48 48 // Constructors and destructors
49 49 ctcubemask(void);
50   - explicit ctcubemask(GObservations obs);
  50 + explicit ctcubemask(const GObservations& obs);
51 51 ctcubemask(int argc, char *argv[]);
52 52 ctcubemask(const ctcubemask& app);
53 53 virtual ~ctcubemask(void);
... ...
src/ctcubemask/ctcubemask.par
... ... @@ -9,7 +9,7 @@
9 9 # #
10 10 # Author: Chia-Chun Lu #
11 11 # c.lu@mpi-hd.mpg.de #
12   -# IRAP #
  12 +# MPIK #
13 13 # #
14 14 # Purpose: Parameter file for the ctcubemask application #
15 15 # #
... ...
src/ctpsfcube/ctpsfcube.cpp
1 1 /***************************************************************************
2   - * ctpsfcube - CTA PSF cube tool *
  2 + * ctpsfcube - CTA PSF cube tool *
3 3 * ----------------------------------------------------------------------- *
4 4 * copyright (C) 2014 by Chia-Chun Lu *
5 5 * ----------------------------------------------------------------------- *
... ... @@ -68,10 +68,12 @@ ctpsfcube::ctpsfcube(void) : GApplication(CTPSFCUBE_NAME, CTPSFCUBE_VERSION)
68 68 /***********************************************************************//**
69 69 * @brief Observations constructor
70 70 *
  71 + * @param[in] obs Observation container.
  72 + *
71 73 * This method creates an instance of the class by copying an existing
72 74 * observations container.
73 75 ***************************************************************************/
74   -ctpsfcube::ctpsfcube(GObservations obs) : GApplication(CTPSFCUBE_NAME, CTPSFCUBE_VERSION)
  76 +ctpsfcube::ctpsfcube(const GObservations& obs) : GApplication(CTPSFCUBE_NAME, CTPSFCUBE_VERSION)
75 77 {
76 78 // Initialise members
77 79 init_members();
... ... @@ -293,7 +295,6 @@ void ctpsfcube::run(void)
293 295  
294 296 /***********************************************************************//**
295 297 * @brief Save PSF cube
296   - *
297 298 ***************************************************************************/
298 299 void ctpsfcube::save(void)
299 300 {
... ... @@ -349,19 +350,20 @@ void ctpsfcube::get_parameters(void)
349 350 double binsz = (*this)["binsz"].real();
350 351 int nxpix = (*this)["nxpix"].integer();
351 352 int nypix = (*this)["nypix"].integer();
352   - double dmax = (*this)["dmax"].real();
353   - int ndbins = (*this)["ndbins"].integer();
  353 + double dmax = (*this)["amax"].real();
  354 + int ndbins = (*this)["anumbins"].integer();
354 355  
355 356 // Get energy definition
356 357 get_ebounds();
357 358  
358   - // Define exposure cube
  359 + // Define PSF cube
359 360 m_psfcube = GCTAMeanPsf(wcs, coordsys, xref, yref,
360   - -binsz, binsz, nxpix, nypix,
361   - m_ebounds, dmax, ndbins);
362   - }
  361 + -binsz, binsz, nxpix, nypix,
  362 + m_ebounds, dmax, ndbins);
363 363  
364   - // ... otherwise setup the exposure cube from the counts map
  364 + } // endif: PSF cube set from user parameters
  365 +
  366 + // ... otherwise setup the PSF cube from the counts map
365 367 else {
366 368  
367 369 // Set PSF cube from counts map
... ... @@ -401,7 +403,6 @@ void ctpsfcube::get_obs(void)
401 403 // Append CTA observation to container
402 404 m_obs.append(obs);
403 405  
404   -
405 406 }
406 407  
407 408 // ... otherwise try to open as XML file
... ... @@ -420,7 +421,7 @@ void ctpsfcube::get_obs(void)
420 421 /***********************************************************************//**
421 422 * @brief Set observation response
422 423 *
423   - * Set response for all observations that so have no response.
  424 + * Set response for all observations that have no response.
424 425 ***************************************************************************/
425 426 void ctpsfcube::set_response(void)
426 427 {
... ... @@ -537,12 +538,12 @@ void ctpsfcube::get_ebounds(void)
537 538  
538 539  
539 540 /***********************************************************************//**
540   - * @brief Set exposure cube definition from counts map
  541 + * @brief Set PSF cube definition from counts map
541 542 *
542 543 * @exception GException::invalid_value
543 544 * Invalid counts map projection or invalid events encountered.
544 545 *
545   - * Set exposure cube definition from counts map.
  546 + * Set PSF cube definition from counts map.
546 547 ***************************************************************************/
547 548 void ctpsfcube::set_from_cntmap(const std::string& filename)
548 549 {
... ... @@ -552,7 +553,7 @@ void ctpsfcube::set_from_cntmap(const std::string&amp; filename)
552 553 // Load counts map in CTA observation
553 554 obs.load(filename);
554 555  
555   - // Set exposure cube from counts map
  556 + // Set PSF cube from counts map
556 557 const GCTAEventCube* cube = dynamic_cast<const GCTAEventCube*>(obs.events());
557 558  
558 559 // Continue only if cube is valid
... ... @@ -573,16 +574,16 @@ void ctpsfcube::set_from_cntmap(const std::string&amp; filename)
573 574 double dy = wcs->cdelt(1);
574 575 int nx = cube->map().nx();
575 576 int ny = cube->map().ny();
576   - double dmax = (*this)["dmax"].real();
577   - int ndbins = (*this)["ndbins"].integer();
  577 + double amax = (*this)["amax"].real();
  578 + int anumbins = (*this)["anumbins"].integer();
578 579  
579 580 // Get energy definition
580 581 m_ebounds = cube->ebounds();
581 582  
582   - // Define exposure cube
  583 + // Define PSF cube
583 584 m_psfcube = GCTAMeanPsf(proj, coordsys, xref, yref,
584   - dx, dy, nx, ny,
585   - m_ebounds, dmax, ndbins);
  585 + dx, dy, nx, ny,
  586 + m_ebounds, amax, anumbins);
586 587  
587 588 } // endif: WCS projection was valid
588 589  
... ...
src/ctpsfcube/ctpsfcube.hpp
1 1 /***************************************************************************
2   - * ctpsfcube - CTA PSF cube tool *
  2 + * ctpsfcube - CTA PSF cube tool *
3 3 * ----------------------------------------------------------------------- *
4 4 * copyright (C) 2014 by Chia-Chun Lu *
5 5 * ----------------------------------------------------------------------- *
... ... @@ -46,7 +46,7 @@ class ctpsfcube : public GApplication {
46 46 public:
47 47 // Constructors and destructors
48 48 ctpsfcube(void);
49   - explicit ctpsfcube(GObservations obs);
  49 + explicit ctpsfcube(const GObservations& obs);
50 50 ctpsfcube(int argc, char *argv[]);
51 51 ctpsfcube(const ctpsfcube& app);
52 52 virtual ~ctpsfcube(void);
... ...
src/ctpsfcube/ctpsfcube.par
... ... @@ -4,14 +4,14 @@
4 4 # #
5 5 # ------------------------------------------------------------------------- #
6 6 # #
7   -# File: ctexpcube.par #
  7 +# File: ctpsfcube.par #
8 8 # Version: 00-01-00 #
9 9 # #
10   -# Author: Juergen Knoedlseder #
11   -# Jurgen.Knodlseder@irap.omp.eu #
12   -# IRAP #
  10 +# Author: Chia-Chun Lu #
  11 +# c.lu@mpi-hd.mpg.de #
  12 +# MPIK #
13 13 # #
14   -# Purpose: Parameter file for the ctexpcube application #
  14 +# Purpose: Parameter file for the ctpsfcube application #
15 15 # #
16 16 #############################################################################
17 17 #
... ... @@ -19,7 +19,7 @@
19 19 #===================
20 20 infile, f, a, "NONE",,, "Observation definition file"
21 21 cntmap, f, a, "NONE",,, "Counts map for exposure cube definition"
22   -outfile, f, a, "expcube.fits",,, "Output exposure cube file"
  22 +outfile, f, a, "psfcube.fits",,, "Output exposure cube file"
23 23 caldb, s, a, "dummy",,, "Calibration database"
24 24 irf, s, a, "cta_dummy_irf",,, "Instrument response function"
25 25 edisp, b, h, no,,, "Apply energy dispersion?"
... ... @@ -43,10 +43,10 @@ yref, r, a, 22.01,,, &quot;Second coordinate of image center in degrees (DEC or g
43 43 axisrot, r, h, 0.0,,, "Rotation angle of image axis, in degrees"
44 44 proj, s, a, "CAR", AIT|AZP|CAR|MER|STG|TAN,, "Projection method e.g. AIT|AZP|CAR|MER|STG|TAN"
45 45 #
46   -# Histogram binning parameters
47   -#=============================
48   -dmax, r, a, 0.3,,, "Upper bound of delta"
49   -ndbins, i, a, 60,,, "Number of delta bins"
  46 +# Angular separation binning parameters
  47 +#======================================
  48 +amax, r, h, 0.3,,, "Upper bound of angular separation between true and measued photon direction (degrees)"
  49 +anumbins, i, h, 60,,, "Number of angular separation bins"
50 50 #
51 51 # Standard parameters
52 52 #====================
... ... @@ -54,4 +54,4 @@ chatter, i, h, 2,0,4, &quot;Chattiness of output&quot;
54 54 clobber, b, h, yes,,, "Overwrite existing output files with new output files?"
55 55 debug, b, h, no,,, "Debugging mode activated"
56 56 mode, s, h, "ql",,, "Mode of automatic parameters"
57   -logfile, f, h, "ctexpcube.log",,, "Log filename"
  57 +logfile, f, h, "ctpsfcube.log",,, "Log filename"
... ...
src/ctpsfcube/main.cpp
1 1 /***************************************************************************
2   - * ctpsfcube - CTA PSF cube tool *
  2 + * ctpsfcube - CTA PSF cube tool *
3 3 * ----------------------------------------------------------------------- *
4 4 * copyright (C) 2014 by Chia-Chun Lu *
5 5 * ----------------------------------------------------------------------- *
... ...
test/test_ctools.sh
... ... @@ -41,6 +41,7 @@ ctobssim=../src/ctobssim/ctobssim
41 41 ctselect=../src/ctselect/ctselect
42 42 ctskymap=../src/ctskymap/ctskymap
43 43 ctexpcube=../src/ctexpcube/ctexpcube
  44 +ctpsfcube=../src/ctpsfcube/ctpsfcube
44 45 ctcubemask=../src/ctcubemask/ctcubemask
45 46  
46 47  
... ... @@ -392,6 +393,53 @@ $ECHO &quot; ok&quot;
392 393  
393 394  
394 395 #
  396 +# Test ctpsfcube
  397 +# ==============
  398 +$ECHO -n "Test ctpsfcube: "
  399 +#
  400 +# Run 1
  401 +$ctpsfcube infile="data/crab_events.fits" \
  402 + cntmap="NONE" \
  403 + outfile="psfcube1.fits" \
  404 + caldb="irf" \
  405 + irf="cta_dummy_irf" \
  406 + emin=0.1 \
  407 + emax=100.0 \
  408 + enumbins=20 \
  409 + nxpix=200 \
  410 + nypix=200 \
  411 + binsz=0.02 \
  412 + coordsys="CEL" \
  413 + xref=83.63 \
  414 + yref=22.01 \
  415 + proj="CAR"
  416 +$ECHO -n "."
  417 +if [ -s "psfcube1.fits" ]
  418 +then
  419 + $ECHO -n "."
  420 +else
  421 + $ECHO " psfcube1.fits file is not valid"
  422 + exit 1
  423 +fi
  424 +#
  425 +# Run 2
  426 +$ctpsfcube infile="data/crab_events.fits" \
  427 + cntmap="data/crab_cntmap.fits" \
  428 + outfile="psfcube2.fits" \
  429 + caldb="irf" \
  430 + irf="cta_dummy_irf"
  431 +$ECHO -n "."
  432 +if [ -s "psfcube2.fits" ]
  433 +then
  434 + $ECHO -n "."
  435 +else
  436 + $ECHO " psfcube2.fits file is not valid"
  437 + exit 1
  438 +fi
  439 +$ECHO " ok"
  440 +
  441 +
  442 +#
395 443 # Test ctcubemask
396 444 # ===============
397 445 $ECHO -n "Test ctcubemask: "
... ...