Commit 67fee53149e0dc2ff86d3d0c8e36d48e7dd4a6f8

Authored by Jürgen Knödlseder
1 parent af2a7917

Complete 1DC documentation for stacked analysis and add (empty) cookbook section

doc/source/users/glossary.rst
1 1 Glossary
2 2 ========
3 3  
  4 +.. _glossary_countscube:
  5 +
  6 +.. topic:: Counts cube
  7 +
  8 + Bla bla ...
  9 +
4 10 .. _glossary_eventlist:
5 11  
6 12 .. topic:: Event list
... ...
doc/source/users/tutorials/1dc/first_skymap_residual_stacked.png 0 → 100644

505 KB

doc/source/users/tutorials/1dc/first_spectrum_stacked.png 0 → 100644

51.4 KB

doc/source/users/tutorials/1dc/first_stacked.rst
... ... @@ -3,4 +3,212 @@
3 3 Performing a stacked analysis
4 4 -----------------------------
5 5  
6   -To be written ...
  6 +In the previous example you have fit the model to the data using an unbinned
  7 +maximum likelihood method, which directly operates on the event lists without
  8 +any binning of the data. This is the most precise method to analysis the CTA
  9 +data, yet as you may have recognised, it is a time consuming method, in
  10 +particular if you want to analyse a large number of events.
  11 +
  12 +An alternative analysis method is the stacked analysis, where the data from
  13 +all observations are binned into a single
  14 +:ref:`counts cube <glossary_countscube>`,
  15 +spanned by
  16 +Right Ascension (or Galactic longitude),
  17 +Declination (or Galactic latitude), and energy.
  18 +For observation durations exceeding a few 10 hours, a stacked analysis is
  19 +generally faster than an unbinned analysis, but any temporal information
  20 +is lost.
  21 +
  22 +To perform a stacked analyses, you start with creating a
  23 +:ref:`counts cube <glossary_countscube>`
  24 +by typing
  25 +
  26 +.. code-block:: bash
  27 +
  28 + $ ctbin
  29 + Input event list or observation definition XML file [events.fits] obs.xml
  30 + First coordinate of image center in degrees (RA or galactic l) (0-360) [0] 0.0
  31 + Second coordinate of image center in degrees (DEC or galactic b) (-90-90) [0] 0.0
  32 + Projection method (AIT|AZP|CAR|MER|MOL|STG|TAN) [CAR]
  33 + Coordinate system (CEL - celestial, GAL - galactic) (CEL|GAL) [GAL]
  34 + Image scale (in degrees/pixel) [0.02]
  35 + Size of the X axis in pixels [400]
  36 + Size of the Y axis in pixels [400]
  37 + Algorithm for defining energy bins (FILE|LIN|LOG) [LOG]
  38 + Start value for first energy bin in TeV [0.1]
  39 + Stop value for last energy bin in TeV [100]
  40 + Number of energy bins (1-200) [20]
  41 + Output counts cube file [cntcube.fits]
  42 +
  43 +This creates a 3-dimensional counts cube in Galactic coordinates, centred on
  44 +the Galactic centre and 8 degrees x 8 degrees wide, with 20 logarithmically
  45 +spaced energy bins between 100 GeV and 100 TeV.
  46 +
  47 +As next step you have to compute the effective response function for the
  48 +counts cube. The effective response function is composed of an exposure
  49 +cube, a point spread function cube, and a background cube. You generate
  50 +the cubes by typing
  51 +
  52 +.. code-block:: bash
  53 +
  54 + $ ctexpcube
  55 + Input event list or observation definition XML file [NONE] obs.xml
  56 + Input counts cube file to extract exposure cube definition [NONE] cntcube.fits
  57 + Output exposure cube file [expcube.fits]
  58 +
  59 +.. code-block:: bash
  60 +
  61 + $ ctpsfcube
  62 + Input event list or observation definition XML file [NONE] obs.xml
  63 + Input counts cube file to extract PSF cube definition [NONE]
  64 + First coordinate of image center in degrees (RA or galactic l) (0-360) [83.63] 0.0
  65 + Second coordinate of image center in degrees (DEC or galactic b) (-90-90) [22.01] 0.0
  66 + Projection method (AIT|AZP|CAR|MER|MOL|STG|TAN) [CAR]
  67 + Coordinate system (CEL - celestial, GAL - galactic) (CEL|GAL) [CEL] GAL
  68 + Image scale (in degrees/pixel) [1.0]
  69 + Size of the X axis in pixels [10]
  70 + Size of the Y axis in pixels [10]
  71 + Lower energy limit (TeV) [0.1]
  72 + Upper energy limit (TeV) [100.0]
  73 + Number of energy bins [20]
  74 + Output PSF cube file [psfcube.fits]
  75 +
  76 +.. code-block:: bash
  77 +
  78 + $ ctbkgcube
  79 + Input event list or observation definition XML file [NONE] obs.xml
  80 + Input counts cube file to extract background cube definition [NONE] cntcube.fits
  81 + Input model definition XML file [NONE] models.xml
  82 + Output background cube file [bkgcube.fits]
  83 + Output model definition XML file [NONE] stacked_models.xml
  84 +
  85 +.. note::
  86 + For convenience, the dimensions of the exposure and background cubes were
  87 + taken identical to the dimensions of the counts cube. This is however not
  88 + a requirement, and each of the cubes may have a different dimension and
  89 + size. For the point spread function cube a coarser spatial binning was
  90 + used to keep the size of the cube at a manageable level. The point spread
  91 + function cube varies in fact only slowly over the field of view, and a
  92 + coarse spatial binning is sufficient to capture that variability.
  93 +
  94 +With this prepatory work finished, you can now perform a binned maximum
  95 +likelihood using :ref:`ctlike`. Instead of the
  96 +:ref:`Observation Definition File <glossary_obsdef>`
  97 +specified for the unbinned analysis, you now need to specify the
  98 +:ref:`counts cube <glossary_countscube>`
  99 +on input, and :ref:`ctlike` will then automatically query for the response
  100 +cubes:
  101 +
  102 +.. code-block:: bash
  103 +
  104 + $ ctlike
  105 + Input event list, counts cube or observation definition XML file [obs.xml] cntcube.fits
  106 + Input exposure cube file (only needed for stacked analysis) [NONE] expcube.fits
  107 + Input PSF cube file (only needed for stacked analysis) [NONE] psfcube.fits
  108 + Input background cube file (only needed for stacked analysis) [NONE] bkgcube.fits
  109 + Input model definition XML file [models.xml] stacked_models.xml
  110 + Output model definition XML file [results.xml]
  111 +
  112 +You may recognise that :ref:`ctlike` now runs significantly faster.
  113 +An inspection of the log file ``ctlike.log`` demonstrates that the model fit
  114 +converged properly:
  115 +
  116 +.. code-block:: bash
  117 +
  118 + 2017-02-02T16:39:58: +=================================+
  119 + 2017-02-02T16:39:58: | Maximum likelihood optimisation |
  120 + 2017-02-02T16:39:58: +=================================+
  121 + 2017-02-02T16:40:14: >Iteration 0: -logL=-1011176.684, Lambda=1.0e-03
  122 + 2017-02-02T16:40:30: >Iteration 1: -logL=-1018314.686, Lambda=1.0e-03, delta=7138.002, max(|grad|)=-22791.121954 [DEC:7]
  123 + 2017-02-02T16:40:46: >Iteration 2: -logL=-1020732.797, Lambda=1.0e-04, delta=2418.112, max(|grad|)=-16741.951327 [DEC:7]
  124 + 2017-02-02T16:41:02: >Iteration 3: -logL=-1022040.008, Lambda=1.0e-05, delta=1307.210, max(|grad|)=-10516.727948 [DEC:7]
  125 + 2017-02-02T16:41:19: >Iteration 4: -logL=-1022455.353, Lambda=1.0e-06, delta=415.345, max(|grad|)=-4793.902211 [DEC:7]
  126 + 2017-02-02T16:41:34: >Iteration 5: -logL=-1022499.179, Lambda=1.0e-07, delta=43.827, max(|grad|)=-1120.934327 [DEC:7]
  127 + 2017-02-02T16:41:50: >Iteration 6: -logL=-1022499.914, Lambda=1.0e-08, delta=0.735, max(|grad|)=-84.494765 [RA:6]
  128 + 2017-02-02T16:42:06: >Iteration 7: -logL=-1022499.918, Lambda=1.0e-09, delta=0.003, max(|grad|)=-8.207385 [RA:6]
  129 + 2017-02-02T16:42:22:
  130 + 2017-02-02T16:42:22: +=========================================+
  131 + 2017-02-02T16:42:22: | Maximum likelihood optimisation results |
  132 + 2017-02-02T16:42:22: +=========================================+
  133 + 2017-02-02T16:42:22: === GOptimizerLM ===
  134 + 2017-02-02T16:42:22: Optimized function value ..: -1022499.918
  135 + 2017-02-02T16:42:22: Absolute precision ........: 0.005
  136 + 2017-02-02T16:42:22: Acceptable value decrease .: 2
  137 + 2017-02-02T16:42:22: Optimization status .......: converged
  138 + 2017-02-02T16:42:22: Number of parameters ......: 16
  139 + 2017-02-02T16:42:22: Number of free parameters .: 10
  140 + 2017-02-02T16:42:22: Number of iterations ......: 7
  141 + 2017-02-02T16:42:22: Lambda ....................: 1e-10
  142 + 2017-02-02T16:42:22: Maximum log likelihood ....: 1022499.918
  143 + 2017-02-02T16:42:22: Observed events (Nobs) ...: 3136493.000
  144 + 2017-02-02T16:42:22: Predicted events (Npred) ..: 3136492.994 (Nobs - Npred = 0.00608432479202747)
  145 +
  146 +Similar to the unbinned analysis you can use
  147 +:ref:`csresmap`
  148 +to compute a residual map for a counts cube by typing
  149 +
  150 +.. code-block:: bash
  151 +
  152 + $ csresmap
  153 + Input event list, counts cube, or observation definition XML file [obs.xml] cntcube.fits
  154 + Input model cube file (generated with ctmodel) [NONE]
  155 + Input exposure cube file (only needed for stacked analysis) [NONE] expcube.fits
  156 + Input PSF cube file (only needed for stacked analysis) [NONE] psfcube.fits
  157 + Input background cube file (only needed for stacked analysis) [NONE] bkgcube.fits
  158 + Input model definition XML file [results.xml]
  159 + Residual map computation algorithm (SUB|SUBDIV|SUBDIVSQRT) [SUB]
  160 + Output residual map file [resmap.fits]
  161 +
  162 +which generates a residual map that is indistinguishable to the map shown for
  163 +the unbinned analysis (see below).
  164 +
  165 +.. figure:: first_skymap_residual_stacked.png
  166 + :width: 400px
  167 + :align: center
  168 +
  169 + *Residual sky map after subtraction of the fitted model for a stacked analysis*
  170 +
  171 +You can also use
  172 +:ref:`ctbutterfly`
  173 +to compute a butterfly diagram for a counts cube by typing
  174 +
  175 +.. code-block:: bash
  176 +
  177 + $ ctbutterfly
  178 + Input event list, counts cube or observation definition XML file [obs.xml] cntcube.fits
  179 + Input exposure cube file (only needed for stacked analysis) [NONE] expcube.fits
  180 + Input PSF cube file (only needed for stacked analysis) [NONE] psfcube.fits
  181 + Input background cube file (only needed for stacked analysis) [NONE] bkgcube.fits
  182 + Source of interest [Src002] Src001
  183 + Input model definition XML file [results.xml]
  184 + Start value for first energy bin in TeV [0.1]
  185 + Stop value for last energy bin in TeV [100.0]
  186 + Output ASCII file [butterfly_src002.txt] butterfly_stacked_src001.txt
  187 +
  188 +and you can use
  189 +:ref:`csspec`
  190 +to derive a source spectrum from a counts cube by typing
  191 +
  192 +.. code-block:: bash
  193 +
  194 + $ csspec
  195 + Input event list, counts cube, or observation definition XML file [obs.xml] cntcube.fits
  196 + Input exposure cube file (only needed for stacked analysis) [NONE] expcube.fits
  197 + Input PSF cube file (only needed for stacked analysis) [NONE] psfcube.fits
  198 + Input background cube file (only needed for stacked analysis) [NONE] bkgcube.fits
  199 + Input model definition XML file [results.xml]
  200 + Source name [Src002] Src001
  201 + Binning algorithm (LIN|LOG|FILE) [LOG]
  202 + Lower energy limit (TeV) [0.1]
  203 + Upper energy limit (TeV) [100.0]
  204 + Number of energy bins (0=unbinned) [10]
  205 + Output spectrum file [spectrum_src002.fits] spectrum_stacked_src001.fits
  206 +
  207 +The results are again indistinguishable to the result for unbinned analysis:
  208 +
  209 +.. figure:: first_spectrum_stacked.png
  210 + :width: 600px
  211 + :align: center
  212 +
  213 + *Butterfly diagrams determined with ctbutterfly and spectral points determined with csspec for Src001 (top) and Src002 (bottom) using a stacked analysis*
  214 +
... ...
doc/source/users/tutorials/1dc/howto.rst 0 → 100644
  1 +.. _1dc_howto:
  2 +
  3 +Analysis cookbook
  4 +=================
  5 +
  6 +The following sections provide some working examples for the analysis
  7 +of data from the
  8 +:ref:`first CTA Data Challenge <glossary_1dc>`.
  9 +
  10 +.. toctree::
  11 + :maxdepth: 2
  12 +
  13 + howto_ts
  14 + howto_tsmap
  15 + howto_ulimit
  16 + howto_lightcurve
  17 + howto_exclude
... ...
doc/source/users/tutorials/1dc/howto_exclude.rst 0 → 100644
  1 +.. _1dc_howto_exclude:
  2 +
  3 +How to exclude pixels from a counts cube?
  4 +-----------------------------------------
  5 +
  6 +To be written ...
... ...
doc/source/users/tutorials/1dc/howto_lightcurve.rst 0 → 100644
  1 +.. _1dc_howto_ligutcurve:
  2 +
  3 +How to generate a light curve?
  4 +------------------------------
  5 +
  6 +To be written ...
... ...
doc/source/users/tutorials/1dc/howto_ts.rst 0 → 100644
  1 +.. _1dc_howto_ts:
  2 +
  3 +How to compute the signifiance of a source?
  4 +-------------------------------------------
  5 +
  6 +To be written ...
... ...
doc/source/users/tutorials/1dc/howto_tsmap.rst 0 → 100644
  1 +.. _1dc_howto_tsmap:
  2 +
  3 +How to generate a Test Statistic map?
  4 +-------------------------------------
  5 +
  6 +To be written ...
... ...
doc/source/users/tutorials/1dc/howto_ulimit.rst 0 → 100644
  1 +.. _1dc_howto_ulimit:
  2 +
  3 +How to compute upper limits?
  4 +----------------------------
  5 +
  6 +To be written ...
... ...
doc/source/users/tutorials/1dc/index.rst
... ... @@ -11,4 +11,5 @@ First CTA Data Challenge
11 11 getting_data
12 12 data_organisation
13 13 first
  14 + howto
14 15  
... ...