Commit 40b51184af8edb155d5c67ba7813bac7ca266d3f

Authored by Jürgen Knödlseder
1 parent 3a4b7a91

Update documentation

doc/source/users/user_manual/iact_analysis/analysis.rst
... ... @@ -137,7 +137,7 @@ effective area and the Gaussian background models. You may have a look at
137 137 You may also note that the :ref:`csiactobs` script has created a ``csiactobs.log``
138 138 file that logs the complete energy range of the observations that have been
139 139 selected. These values may be important for later, in particular if you
140   -intend to do a binned or stacked analysis.
  140 +intend to do a stacked analysis.
141 141  
142 142 In case that you have already a model definition XML file that describes a model
143 143 of the celestial source distribution (a.k.a. a sky model), you may provide this
... ... @@ -179,11 +179,11 @@ about :ref:`modelling CTA data <models>`.
179 179  
180 180 Example XML files
181 181 -----------------
182   -To get familiar with the XML syntax and format, example files for an observation container and a model container
183   -are shown in the following.
  182 +To get familiar with the XML syntax and format, example files for an observation
  183 +definition XML file and a model definition XML file are shown in the following.
184 184  
185   -Observation XML file
186   -^^^^^^^^^^^^^^^^^^^^
  185 +Observation definition XML file
  186 +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
187 187  
188 188 .. code-block:: xml
189 189  
... ... @@ -219,8 +219,9 @@ Observation XML file
219 219 </observation>
220 220 </observation_list>
221 221  
222   -Model XML file
223   -^^^^^^^^^^^^^^
  222 +
  223 +Model definition XML file
  224 +^^^^^^^^^^^^^^^^^^^^^^^^^
224 225  
225 226 .. code-block:: xml
226 227  
... ... @@ -261,15 +262,20 @@ Model XML file
261 262  
262 263 .. note::
263 264  
264   - It is important to ensure background models are properly linked to their respective observation.
265   - Therefore it is required to keep the attributes ``instrument`` and ``id`` the same for the observation
266   - and the corresponding background model. The tool :ref:`csiactobs` assures this automatically.
  265 + It is important to ensure background models are properly linked to their
  266 + respective observation. Therefore it is required to keep the attributes
  267 + ``instrument`` and ``id`` the same for the observation and the corresponding
  268 + background model. The tool :ref:`csiactobs` assures this automatically.
  269 +
267 270  
268 271 Run ctselect
269 272 ------------
270   -To prepare the data for analysis, cuts have to be applied to the event data. The selection is performed by :ref:`ctselect`.
271   -This tool writes out selected event lists into the local directory. If the observation XML file contains several runs, it is recommended
272   -to first create a separate folder and specify this folder in the hidden ``prefix`` argument.
  273 +To prepare the data for analysis, cuts have to be applied to the event data.
  274 +The selection is performed by :ref:`ctselect`.
  275 +This tool writes out selected event lists into the local directory. If the
  276 +observation definition XML file contains several runs, it is recommended
  277 +to first create a separate folder and specify this folder in the hidden
  278 +``prefix`` argument.
273 279  
274 280 .. code-block:: bash
275 281  
... ... @@ -286,21 +292,27 @@ to first create a separate folder and specify this folder in the hidden ``prefix
286 292 End time (CTA MET in seconds) [0.0]
287 293 Output event list or observation definition file [selected_events.fits] selected_obs.xml
288 294  
289   -For IACT analysis, it is recommended to use the hidden parameter ``usethres="DEFAULT"``. This instructs :ref:`ctselect`
290   -to extract the safe energy range from the instrument response functions and apply them to the data. This safe energy range
291   -is thus superior to the energy limit passed via the user parameters. In addition, to analyse the complete field of view,
292   -the parameter ``usepnt=yes`` uses, for each observation, the pointing position as centre for the selection radius.
293   -The radius parameter is dependent on the intrument, for an instrument with a 5 degree field of view, a radius of 2.5 degrees
  295 +For IACT analysis, it is recommended to use the hidden parameter
  296 +``usethres="DEFAULT"``. This instructs :ref:`ctselect` to extract the safe
  297 +energy range from the instrument response functions and apply them to the
  298 +data. This safe energy range is thus superior to the energy limit passed via
  299 +the user parameters. In addition, to analyse the complete field of view, the
  300 +parameter ``usepnt=yes`` uses, for each observation, the pointing position as
  301 +centre for the selection radius. The radius parameter is dependent on the
  302 +intrument, for an instrument with a 5° field of view, a radius of 2.5°
294 303 seems reasonable. The time selection is not applied in the above example;
295   -specifying 0 as start and end time skips the time selection.
296   -For time-resolved analysis, it is important to know the MET time that is required to extract.
297   -The result of the selection step is written into the observation XML file ``selected_obs.xml``, which now contains references
298   -to the new selected event FITS files.
  304 +specifying 0 as start and end time skips the time selection. For time-resolved
  305 +analysis, it is important to know the MET time that is required to extract.
  306 +The result of the selection step is written into the observation XML file
  307 +``selected_obs.xml``, which now contains references to the new selected event
  308 +FITS files.
  309 +
299 310  
300 311 Unbinned analysis
301 312 -----------------
302   -Once the data is selected, the easiest way to analyse is an unbinned analysis. Note that the input model XML
303   -file must now contain the background models and source components to describe the field of view.
  313 +Once the data is selected, the easiest way to analyse is an unbinned analysis.
  314 +Note that the input model definition XML file must now contain the background
  315 +models and source components to describe the field of view.
304 316  
305 317 .. code-block:: bash
306 318  
... ... @@ -309,20 +321,26 @@ file must now contain the background models and source components to describe th
309 321 Source model [$CTOOLS/share/models/crab.xml] crab_models.xml
310 322 Source model output file [crab_results.xml]
311 323  
312   -The result of the fit was stored in ``crab_results.xml``. Note that fitted parameters, ``Prefactors`` in particular,
313   -typically use MeV as energy unit. To monitor the progress of the fit on the screen, one can simply run with the option ``debug=yes``.
314   -Alternatively, the logfile ``ctlike.log`` can be inspected after the fit.
315   -
316   -On default, energy dispersion is not considered in the fit. To switch on the usage of the energy migration matrix,
317   -the hidden parameter ``edisp=yes`` can be provided. Note that this will cause a significant reduction of the computing
318   -speed.
319   -
320   -Stacked (binned) analysis
321   --------------------------
322   -The stacked analysis mode is using a binned analysis where all observations are included and stacked into one event cube.
323   -This analysis mode is much faster than unbinned analysis when having a large dataset (e.g. > 100 hours).
324   -For this type of binned analysis, some intermediate data products have to be produced. The products are a binned data cube,
325   -an exposure cube, a PSF cube, and a background cube.
  324 +The result of the fit was stored in ``crab_results.xml``. Note that fitted
  325 +parameters, ``Prefactors`` in particular, typically use MeV as energy unit.
  326 +To monitor the progress of the fit on the screen, one can simply run with the
  327 +option ``debug=yes``. Alternatively, the logfile ``ctlike.log`` can be inspected
  328 +after the fit.
  329 +
  330 +On default, energy dispersion is not considered in the fit. To switch on the
  331 +usage of the energy migration matrix, the hidden parameter ``edisp=yes`` can
  332 +be provided. Note that this will cause a significant reduction of the
  333 +computing speed.
  334 +
  335 +
  336 +Stacked analysis
  337 +----------------
  338 +In a stacked analysis the events of all observations are stacked into a single
  339 +counts cube. This analysis mode is much faster than unbinned analysis when
  340 +having a large dataset (e.g. > 100 hours). For this type of analysis, some
  341 +intermediate data products have to be produced. The products are a binned counts
  342 +cube, an exposure cube, a point spead function cube, optionally an energy
  343 +dispersion cube, and a background cube.
326 344  
327 345 Bin events
328 346 ^^^^^^^^^^
... ... @@ -344,23 +362,25 @@ Bin events
344 362 Number of energy bins [20]
345 363 Output counts cube [cntcube.fits]
346 364  
347   -Note that bins only get filled if the bin of the cube is fully contained in the energy range and RoI of a considered observation.
348   -It is therefore useful to provide the energy range given by :ref:`csiactobs` above. This ensures a maximum agreement between
349   -observations and binning and reduces the loss of data.
350 365  
351 366 Create exposure cube
352 367 ^^^^^^^^^^^^^^^^^^^^
353   -After binning the events into a three-dimensional cube, an exposure cube has to be computed.
354   -The exposure is defined as the effective area times the dead-time corrected observation time.
355   -Each observation from the input container gets stacked in the resulting cube. The exposure is stored
356   -in units of :math:`cm^2 s`. The exposure cube does not have to contain the same binning as the event cube
357   -but for simplicity, the event cube can be passed to adopt the binning parameters. Note, however, that the
358   -exposure cube is defined in true sky coordinates and energy while the counts cube is defined in reconstructed
359   -sky coordinates and energy. Consequently, the sky area and energy range covered by the exposure cube should be
360   -slightly larger than that of the counts cube to accommodate for spill over of events due to the point spread function
361   -and energy dispersion. By computing the exposure cube on the same grid as the counts cube, the spill over of events
362   -from sources at the edge of cube will not be handled correctly. In the example below, however, no source at the edge of the
363   -field of view is present. Therefore, for simplicity, the count cube is used as input cube to extract the binning.
  368 +After binning the events into a three-dimensional cube, an exposure cube has to
  369 +be computed. The exposure is defined as the effective area times the dead-time
  370 +corrected observation time. Each observation from the input container gets
  371 +stacked in the resulting cube. The exposure is stored in units of :math:`cm^2 s`.
  372 +The exposure cube does not have to contain the same binning as the event cube
  373 +but for simplicity, the event cube can be passed to adopt the binning
  374 +parameters. Note, however, that the exposure cube is defined in true sky
  375 +coordinates and energy while the counts cube is defined in reconstructed sky
  376 +coordinates and energy. Consequently, the sky area and energy range covered by
  377 +the exposure cube should be slightly larger than that of the counts cube to
  378 +accommodate for spill over of events due to the point spread function and energy
  379 +dispersion. By computing the exposure cube on the same grid as the counts cube,
  380 +the spill over of events from sources at the edge of cube will not be handled
  381 +correctly. In the example below, however, no source at the edge of the field of
  382 +view is present. Therefore, for simplicity, the count cube is used as input cube
  383 +to extract the binning.
364 384  
365 385 This task of computing the exposure cube is is performed by :ref:`ctexpcube`.
366 386  
... ... @@ -371,7 +391,8 @@ This task of computing the exposure cube is is performed by :ref:`ctexpcube`.
371 391 Input counts cube file to extract exposure cube definition [NONE] cntcube.fits
372 392 Output exposure cube file [expcube.fits]
373 393  
374   -Alternatively, the exposure cube can be created with different binning than the event cube:
  394 +Alternatively, the exposure cube can be created with different binning than the
  395 +counts cube:
375 396  
376 397 .. code-block:: bash
377 398  
... ... @@ -390,15 +411,18 @@ Alternatively, the exposure cube can be created with different binning than the
390 411 Number of energy bins [20] 30
391 412 Output exposure cube file [expcube.fits]
392 413  
393   -Create PSF cube
394   -^^^^^^^^^^^^^^^
395   -As a next step for the binned analysis, a cube containing the point spread function (PSF) must be computed.
396   -Since the PSF cannot be stored by one single parameter, the PSF cube computed by :ref:`ctpsfcube` has a fourth dimension.
397   -In each bin of the cube, the PSF is stored as a function of offset from source. The granularity of the
398   -PSF histogram is determined by the hidden parameter ``anumbins`` (default: 200). Therefore, when passing
399   -the event cube to adopt the sky binning for the PSF cube, the resulting FITS file can become quite large due to
400   -the fourth dimension. Usually in IACT analysis, the PSF doesn't change too dramatically across the field of view.
401   -Therefore the user can think about reducing the spatial binning of the PSF cube:
  414 +Create point spread function cube
  415 +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  416 +As a next step for the stacked analysis, a cube containing the point spread
  417 +function (PSF) must be computed. Since the PSF cannot be stored by one single
  418 +parameter, the PSF cube computed by :ref:`ctpsfcube` has a fourth dimension.
  419 +In each bin of the cube, the PSF is stored as a function of offset from source.
  420 +The granularity of the PSF histogram is determined by the hidden parameter
  421 +``anumbins`` (default: 200). Therefore, when passing the event cube to adopt
  422 +the sky binning for the PSF cube, the resulting FITS file can become quite large
  423 +due to the fourth dimension. Usually in IACT analysis, the PSF doesn't change
  424 +too dramatically across the field of view. Therefore the user can think about
  425 +reducing the spatial binning of the PSF cube:
402 426  
403 427 .. code-block:: bash
404 428  
... ... @@ -417,8 +441,8 @@ Therefore the user can think about reducing the spatial binning of the PSF cube:
417 441 Number of energy bins [20]
418 442 Output PSF cube file [psfcube.fits]
419 443  
420   -Depending on the required PSF precision, one could reduce the number of offset bins via the hidden parameter
421   -``anumbins``:
  444 +Depending on the required PSF precision, one could reduce the number of offset
  445 +bins via the hidden parameter ``anumbins``:
422 446  
423 447 .. code-block:: bash
424 448  
... ... @@ -426,13 +450,16 @@ Depending on the required PSF precision, one could reduce the number of offset b
426 450  
427 451 Create energy dispersion cube (optional)
428 452 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
429   -In case energy dispersion wants to be used in the analysis, the tool :ref:`ctedispcube` computes the energy
430   -migration response for the given observations. Analogous to the PSF cube, the Edisp cube is stored in
431   -a four-dimensional map. In each bin of the cube, the migration value ``E_reco/E_true`` is stored. The granularity
432   -of the migration histogram can be steered via the hidden parameter ``migrabins`` (default: 100). In addition, the
433   -maximum migration value can be set via the hidden parameter ``migramax`` (default: 2.0). Similar to the PSF cube,
434   -the edispcube FITS file can become quite large. Therefore, since the energy dispersion shouldn't vary too much across
435   -the sky region, one could reduce the spatial binning:
  453 +In case energy dispersion should be considered used in the analysis, the tool
  454 +:ref:`ctedispcube` computes the energy migration response for the given
  455 +observations. Analoguous to the PSF cube, the energy dispersion cube is stored
  456 +in a four-dimensional map. In each bin of the cube, the migration value
  457 +``E_reco/E_true`` is stored. The granularity of the migration histogram can be
  458 +steered via the hidden parameter ``migrabins`` (default: 100). In addition, the
  459 +maximum migration value can be set via the hidden parameter ``migramax``
  460 +(default: 2.0). Similar to the PSF cube, the energy dispersion cube FITS file
  461 +can become quite large. Therefore, since the energy dispersion shouldn't vary
  462 +too much across the sky region, one could reduce the spatial binning:
436 463  
437 464 .. code-block:: bash
438 465  
... ... @@ -453,9 +480,11 @@ the sky region, one could reduce the spatial binning:
453 480  
454 481 Create background cube
455 482 ^^^^^^^^^^^^^^^^^^^^^^
456   -Last but not least, for a binned IACT analysis a cube containing the background rate in sky coordinates and
457   -reconstructed energy has to be computed. This task is performed by :ref:`ctbkgcube`. The binning here can also differ
458   -from the event cube. For simplicity, however, the example below uses the event cube to adopt the binning.
  483 +Last but not least, for a stacked IACT analysis a cube containing the background
  484 +rate in sky coordinates and reconstructed energy has to be computed. This task
  485 +is performed by :ref:`ctbkgcube`. The binning here can also differ from the counts
  486 +cube. For simplicity, however, the example below uses the counts cube to adopt
  487 +the binning.
459 488  
460 489 .. code-block:: bash
461 490  
... ... @@ -466,11 +495,14 @@ from the event cube. For simplicity, however, the example below uses the event c
466 495 Output background cube file [bkgcube.fits]
467 496 Output model XML file [NONE] binned_models.xml
468 497  
469   -Note that this tool also requires the parameters of an input and output model. In the model XML file that came out of
470   -:ref:`csiactobs`, one background model per observation is included. This models get merged and averaged in the background
471   -sky cube. In the output model the background models per obseervation will be removed. Instead, a global background model
472   -for the newly created background cube is included. Sky models present in the input model XML file will also be included in the
473   -new XML file, which subsequently can be used for binned :ref:`ctlike`.
  498 +Note that this tool also requires the parameters of an input and output model.
  499 +In the model XML file that came out of :ref:`csiactobs`, one background model
  500 +per observation is included. This models get merged and averaged in the background
  501 +sky cube. In the output model the background models per obseervation will be
  502 +removed. Instead, a global background model for the newly created background
  503 +cube is included. Sky models present in the input model XML file will also be
  504 +included in the new XML file, which subsequently can be used for stacked
  505 +:ref:`ctlike`.
474 506  
475 507 Example for stacked model XML file
476 508 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
... ... @@ -500,12 +532,13 @@ The output model of :ref:`ctbkgcube` looks the following:
500 532 </source>
501 533 </source_library>
502 534  
503   -The background model with ``type=CTACubeBackground`` is used to scale the background cube stored in the FITS file
504   -created by :ref:`ctbkgcube`.
  535 +The background model with ``type=CTACubeBackground`` is used to scale the
  536 +background cube stored in the FITS file created by :ref:`ctbkgcube`.
505 537  
506 538 Run ctlike
507 539 ^^^^^^^^^^
508   -Having all the intermediate data products ready, a binned analysis can be conducted using :ref:`ctlike`.
  540 +Having all the intermediate data products ready, a stacked analysis can be
  541 +conducted using :ref:`ctlike`.
509 542  
510 543 .. code-block:: bash
511 544  
... ... @@ -517,12 +550,15 @@ Having all the intermediate data products ready, a binned analysis can be conduc
517 550 Input model XML file [binned_models.xml]
518 551 Output model XML file [binned_results.xml]
519 552  
520   -Note that when passing an event cube to :ref:`ctlike`, the tool behaves differently than in unbinned mode.
521   -It queries directly for the additional ingredients for the binned analysis. It is important to pass the background model
522   -generated by :ref:`ctbkgcube` here to ensure the proper modelling of the background in the fit.
  553 +Note that when passing an counts cube to :ref:`ctlike`, the tool behaves
  554 +differently than in unbinned mode. It queries directly for the additional
  555 +ingredients for the stacked analysis. It is important to pass the background
  556 +model generated by :ref:`ctbkgcube` here to ensure the proper modelling of
  557 +the background in the fit.
523 558  
524   -Running :ref:`ctlike` with energy dispersion, the hidden parameter ``edisp=yes`` needs to be specified. The tool
525   -will then additionally query for the energy dispersion cube described above:
  559 +To consider also the energy dispersion, you have to execute the :ref:`ctlike`
  560 +tool with the hidden parameter ``edisp=yes``. The tool will then also query for
  561 +the energy dispersion cube:
526 562  
527 563 .. code-block:: bash
528 564  
... ... @@ -534,6 +570,3 @@ will then additionally query for the energy dispersion cube described above:
534 570 Input background cube file (only needed for stacked analysis) [NONE] bkgcube.fits
535 571 Input model XML file [binned_models.xml]
536 572 Output model XML file [binned_results.xml]
537   -
538   -
539   -
... ...