Commit b90e3a83a949f18df11a76585d5f1f0f3e20c81c

Authored by Jürgen Knödlseder
1 parent 593f8844

Update 1DC tutorials

doc/source/users/tutorials/1dc/first_detect.rst
... ... @@ -3,15 +3,15 @@
3 3 Detecting candidate sources
4 4 ---------------------------
5 5  
6   -.. admonition:: You will learn ...
  6 + .. admonition:: What you will learn
7 7  
8   - ... how to **detect candidate sources** in a sky map.
  8 + You will learn how to **detect candidate sources** in a sky map.
9 9  
10   - This will provide you with an initial
11   - :ref:`model definition XML file <glossary_moddef>`
12   - that can be directly used for maximum likelihood fitting. In subsequent
13   - steps you will iteratively improve this model to obtain a reliable
14   - description of the observed gamma-ray sky.
  10 + This will provide you with an initial
  11 + :ref:`model definition file <glossary_moddef>`
  12 + in XML format that can be directly used for maximum likelihood fitting.
  13 + In subsequent steps you will iteratively improve this model to obtain a
  14 + reliable description of the observed gamma-ray sky.
15 15  
16 16 As next step you need to identify the location of candidate sources in the
17 17 sky map.
... ...
doc/source/users/tutorials/1dc/first_fitting.rst
... ... @@ -3,22 +3,20 @@
3 3 Fitting the model components to the counts cube
4 4 -----------------------------------------------
5 5  
6   -.. admonition:: You will learn ...
7   -
8   - ... how to **fit a parametric model** to the counts cube using an
9   - maximum liklihood algorithm.
10   -
11   - You will also learn how to display the fit results in form of
12   - `ds9 <http://ds9.si.edu>`_
13   - region files, butterfly diagrams and spectral points.
14   -
15   - Please note that display tools are **not** part of ctools, yet some
16   - scripts for result display that use the ``matplotlib`` Python module can be
17   - found in the
18   - ``$CTOOLS/share/examples/python``
19   - folder. For example you may use ``show_butterfly.py`` to display a butterfly
20   - diagram or ``show_spectrum.py`` to display spectral points. Do not hesitate to
21   - copy and adjust these scripts as needed, they are examples.
  6 + .. admonition:: What you will learn
  7 +
  8 + You will learn how to **fit a parametric model** to the counts cube using
  9 + a maximum likelihood algorithm.
  10 +
  11 + You will also learn how to display the fit results in form of
  12 + `ds9 <http://ds9.si.edu>`_
  13 + region files, butterfly diagrams and spectral points.
  14 +
  15 + Please note that display tools are **not** part of ctools, yet some
  16 + scripts for result display that use the ``matplotlib`` Python module can be
  17 + found in the
  18 + ``$CTOOLS/share/examples/python``
  19 + folder (see :ref:`how to display results<1dc_howto_display>`).
22 20  
23 21 Now you are ready to fit the model to the counts cube and to determine its
24 22 maximum likelihood parameters.
... ...
doc/source/users/tutorials/1dc/first_improving.rst
... ... @@ -3,10 +3,10 @@
3 3 Iteratively improving the model
4 4 -------------------------------
5 5  
6   -.. admonition:: You will learn ...
  6 + .. admonition:: What you will learn
7 7  
8   - ... how to **iteratively improve** your source model by inspecting the
9   - fit residuals and by adjusting the model components as needed.
  8 + You will learn how to **iteratively improve** your source model by
  9 + inspecting the fit residuals and by adjusting the model components as needed.
10 10  
11 11 After doing the model fit you should investigate the residuals to verify that
12 12 the model components properly describe the observed event distribution.
... ...
doc/source/users/tutorials/1dc/first_select_events.rst
... ... @@ -3,14 +3,15 @@
3 3 Selecting the relevant events
4 4 -----------------------------
5 5  
6   -.. admonition:: You will learn ...
  6 + .. admonition:: What you will learn
7 7  
8   - ... how to **select a subset of events** from the selected observations for
9   - your analysis.
  8 + You will learn how to **select a subset of events** from the selected
  9 + observations for your analysis.
10 10  
11   - The event selection is useful to restrict for example the energy range of
12   - the events or the time interval covered, but also to select only events
13   - within a given radial acceptance region (also called region of interest).
  11 + The event selection is necessary if you want to restrict for example the
  12 + energy range of the events or the time interval that should be covered,
  13 + but also if you want to select only events within a given radial
  14 + acceptance region (also called region of interest).
14 15  
15 16 As next step, you have to select the relevant events from the selected
16 17 observations. You do this with the :ref:`ctselect` tool by typing:
... ...
doc/source/users/tutorials/1dc/first_select_obs.rst
... ... @@ -3,13 +3,13 @@
3 3 Selecting the relevant observations
4 4 -----------------------------------
5 5  
6   -.. admonition:: You will learn ...
  6 + .. admonition:: What you will learn
7 7  
8   - ... how to **select a subset of observations** from the Data Challenge data
9   - for your analysis.
  8 + You will learn how to **select a subset of observations** from the Data
  9 + Challenge data for your analysis.
10 10  
11   - We recommended to analyse the data region by region since the analysis of
12   - the Data Challenge data in a single shot will be very very time consuming.
  11 + We recommended to analyse the data region by region since the analysis of
  12 + the Data Challenge data in a single shot will be very very time consuming.
13 13  
14 14 Let's assume that you want to analyse the central region of our Galaxy using
15 15 the data obtained during the Galactic Plane Survey.
... ...
doc/source/users/tutorials/1dc/first_skymap.rst
... ... @@ -3,15 +3,15 @@
3 3 Generating a sky map from the events
4 4 ------------------------------------
5 5  
6   -.. admonition:: You will learn ...
  6 + .. admonition:: What you will learn
7 7  
8   - ... how to **generate a sky map** from the selected events.
  8 + You will learn how to **generate a sky map** from the selected events.
9 9  
10   - A background model based on the background template included in the
11   - :ref:`instrument response functions <glossary_irf>`
12   - may be subtracted from the sky map to display only celestial excess events,
13   - but be aware that for the moment the background subtraction is computationally
14   - intensive.
  10 + A background model based on the background template included in the
  11 + :ref:`instrument response functions <glossary_irf>`
  12 + may be subtracted from the sky map to display only celestial excess events,
  13 + but be aware that for the moment the background subtraction is
  14 + computationally intensive.
15 15  
16 16 After having selected the observations and the events you can begin your
17 17 analysis.
... ...
doc/source/users/tutorials/1dc/first_stacked.rst
... ... @@ -3,18 +3,18 @@
3 3 Stacking the data
4 4 -----------------
5 5  
6   -.. admonition:: You will learn ...
7   -
8   - ... how to **prepare the data for analysis** by stacking all events into
9   - a counts cube and by computing the effective
10   - :ref:`instrument response function <glossary_irf>`
11   - for this counts cube.
12   -
13   - Please note that for the moment we do not consider the energy dispersion
14   - since for many cases the effect of the energy dispersion is negligible,
15   - and taking energy dispersion into account is computationally intensive. If
16   - you want to learn how to take the energy dispersion into account please
17   - read :ref:`this section<1dc_howto_edisp>`.
  6 + .. admonition:: What you will learn
  7 +
  8 + You will learn how to **prepare the data for analysis** by stacking all
  9 + events into a counts cube and by computing the effective
  10 + :ref:`instrument response function <glossary_irf>`
  11 + for this counts cube.
  12 +
  13 + Please note that for the moment we do not consider the energy dispersion
  14 + since for many cases the effect of the energy dispersion is negligible,
  15 + and taking energy dispersion into account is computationally intensive. If
  16 + you want to learn how to take the energy dispersion into account please
  17 + read :ref:`this section<1dc_howto_edisp>`.
18 18  
19 19 To analyse the selected observations, we recommend to stack the events into
20 20 a counts cube. You do this using the :ref:`ctbin` tool:
... ...
doc/source/users/tutorials/1dc/first_unbinned.rst
... ... @@ -3,15 +3,15 @@
3 3 Fitting the model components directly to the events
4 4 ---------------------------------------------------
5 5  
6   -.. admonition:: You will learn ...
  6 + .. admonition:: What you will learn
7 7  
8   - ... how to analyse the event data using an **unbinned maximum
9   - likelihood analysis**.
  8 + You will learn how to analyse the event data using an **unbinned maximum
  9 + likelihood analysis**.
10 10  
11   - Use an unbinned maximum likelihood analysis if you have doubts about the
12   - impact of the selected binning on your analysis and if the number of
13   - observations is not too large (typically a few tens of 30 minute
14   - observations). Or if you simply to not worry about computation time.
  11 + Use an unbinned maximum likelihood analysis if you have doubts about the
  12 + impact of the selected binning on your analysis and if the number of
  13 + observations is not too large (typically a few tens of 30 minute
  14 + observations). Or if you simply to not worry about computation time.
15 15  
16 16 Instead of binning the events into a counts cube and computing the effective
17 17 :ref:`instrument response functions <glossary_irf>`
... ...
doc/source/users/tutorials/1dc/howto.rst
... ... @@ -7,7 +7,7 @@ The following sections explain how you can address some specific analysis
7 7 issues.
8 8  
9 9 .. toctree::
10   - :maxdepth: 2
  10 + :maxdepth: 1
11 11  
12 12 howto_display
13 13 howto_ts
... ...
doc/source/users/tutorials/1dc/howto_display.rst
... ... @@ -3,10 +3,13 @@
3 3 How to display the results?
4 4 ---------------------------
5 5  
6   -.. admonition:: You will learn ...
  6 + .. admonition:: What you will learn
7 7  
8   - ... how to **display results** using some example scripts written in
9   - Python and requiring the ``matplotlib`` module.
  8 + You will learn how to **display results** using some example scripts
  9 + written in Python.
  10 +
  11 + Please not that these scripts need the ``matplotlib`` Python module
  12 + installed.
10 13  
11 14 The ctools package does not contain any tools or scripts for graphical
12 15 display of results since results are generally written into standard FITS
... ... @@ -29,10 +32,15 @@ Python module. You can find these scripts in the
29 32 +------------------------+-----------------------------+
30 33 | ``show_pointings.py`` | Display pointing directions |
31 34 +------------------------+-----------------------------+
  35 + | ``show_phases.py`` | Display event phases |
  36 + +------------------------+-----------------------------+
32 37 | ``show_spectrum.py`` | Display a spectrum |
33 38 +------------------------+-----------------------------+
34 39  
35   -Below some usage examples and the expected output:
  40 +Below some usage examples and the expected output.
  41 +
  42 +show_butterfly.py
  43 +^^^^^^^^^^^^^^^^^
36 44  
37 45 .. code-block:: bash
38 46  
... ... @@ -44,6 +52,10 @@ Below some usage examples and the expected output:
44 52  
45 53 *Butterfly diagram displayed with show_butterfly.py*
46 54  
  55 +
  56 +show_lightcurve.py
  57 +^^^^^^^^^^^^^^^^^^
  58 +
47 59 .. code-block:: bash
48 60  
49 61 $ $CTOOLS/share/examples/python/show_lightcurve.py lightcurve.fits
... ... @@ -54,6 +66,10 @@ Below some usage examples and the expected output:
54 66  
55 67 *Light curve displayed with show_lightcurve.py*
56 68  
  69 +
  70 +show_obs.py
  71 +^^^^^^^^^^^
  72 +
57 73 .. code-block:: bash
58 74  
59 75 $ $CTOOLS/share/examples/python/show_obs.py obs_selected.xml
... ... @@ -64,6 +80,10 @@ Below some usage examples and the expected output:
64 80  
65 81 *Observation summary displayed with show_obs.py*
66 82  
  83 +
  84 +show_pointings.py
  85 +^^^^^^^^^^^^^^^^^
  86 +
67 87 .. code-block:: bash
68 88  
69 89 $ $CTOOLS/share/examples/python/show_pointings.py obs_selected.xml
... ... @@ -74,6 +94,24 @@ Below some usage examples and the expected output:
74 94  
75 95 *Observation summary displayed with show_pointings.py (zoomed in)*
76 96  
  97 +
  98 +show_phases.py
  99 +^^^^^^^^^^^^^^
  100 +
  101 +.. code-block:: bash
  102 +
  103 + $ $CTOOLS/share/examples/python/show_phases.py -n 50 events_phased.fits
  104 +
  105 +.. figure:: howto_display_phases.png
  106 + :width: 600px
  107 + :align: center
  108 +
  109 + *Event phases displayed with show_phases.py*
  110 +
  111 +
  112 +show_spectrum.py
  113 +^^^^^^^^^^^^^^^^
  114 +
77 115 .. code-block:: bash
78 116  
79 117 $ $CTOOLS/share/examples/python/show_spectrum.py spectrum_src001.fits
... ...
doc/source/users/tutorials/1dc/howto_display_phases.png 0 → 100644

18 KB

doc/source/users/tutorials/1dc/howto_edisp.rst
1 1 .. _1dc_howto_edisp:
2 2  
3   -How to take the energy dispersion into account
4   -----------------------------------------------
  3 +How to take the energy dispersion into account?
  4 +-----------------------------------------------
5 5  
6   -.. admonition:: You will learn ...
  6 + .. admonition:: What you will learn
7 7  
8   - ... how to **take into account the energy dispersion** in a maximum
9   - likelihood analysis.
  8 + You will learn how to **take the energy dispersion into account** when
  9 + fitting a model to the data using a maximum likelihood analysis.
10 10  
11   - Although the effect of the energy dispersion is often neglegible there
12   - may be cases where you want to consider energy dispersion in an analysis,
13   - for example if you are analysing the data down to very low energies.
14   - Energy dispersion is fully implemented in ctools but is computationally
15   - intensive. So be aware that the tools and scripts will take longer.
  11 + Although the effect of the energy dispersion is often neglegible there
  12 + may be cases where you want to consider energy dispersion in an analysis,
  13 + for example if you are analysing the data down to very low energies.
  14 + Energy dispersion is fully implemented in ctools but is computationally
  15 + intensive. So be aware that the tools and scripts will take longer.
16 16  
17 17 If you are doing a stacked analysis the first thing you need is an energy
18 18 dispersion cube. You generate this cube using the :ref:`ctedispcube` tool:
... ... @@ -34,7 +34,7 @@ dispersion cube. You generate this cube using the :ref:`ctedispcube` tool:
34 34 Number of energy bins [20] 30
35 35 Output energy dispersion cube file [edispcube.fits]
36 36  
37   -This produces a
  37 +This produces an
38 38 :ref:`energy dispersion cube <glossary_edispcube>`
39 39 FITS file that contains the weighted energy dispersion as function of
40 40 sky position and energy.
... ... @@ -53,9 +53,10 @@ during the fit:
53 53 Input event list, counts cube or observation definition XML file [events.fits] cntcube.fits
54 54 Input exposure cube file (only needed for stacked analysis) [NONE] expcube.fits
55 55 Input PSF cube file (only needed for stacked analysis) [NONE] psfcube.fits
  56 + Input energy dispersion cube file (only needed for stacked analysis) [NONE] edispcube.fits
56 57 Input background cube file (only needed for stacked analysis) [NONE] bkgcube.fits
57 58 Input model definition XML file [$CTOOLS/share/models/crab.xml] stacked_models.xml
58   - Output model definition XML file [crab_results.xml] stacked_results.xml
  59 + Output model definition XML file [crab_results.xml] stacked_results_edisp.xml
59 60  
60 61 If you are doing an unbinned analysis you do not need to generate an energy
61 62 dispersion cube and you can directly run :ref:`ctlike` with the ``edisp=yes``
... ...
doc/source/users/tutorials/1dc/howto_exclude.rst
1 1 .. _1dc_howto_exclude:
2 2  
3   -How to exclude pixels from a counts cube?
4   ------------------------------------------
  3 +How to exclude bins from a counts cube?
  4 +---------------------------------------
5 5  
6   -.. admonition:: You will learn ...
  6 + .. admonition:: What you will learn
7 7  
8   - ... how to **exclude pixels of a counts cube** from an analysis using
9   - the :ref:`ctcubemask` tool.
  8 + You will learn how to **exclude bins from a counts cube** to restrict an
  9 + analysis to a specific region of interest.
10 10  
11 11 You can exclude bins in an analysis from a counts cube by using the
12 12 :ref:`ctcubemask` tool.
... ... @@ -42,3 +42,38 @@ in the following image.
42 42 :align: center
43 43  
44 44 *Filtered counts cube*
  45 +
  46 +In the next step we exclude in addition a circular region of 0.3 degrees
  47 +around ``Src001`` from the counts cube. For this purpose you first have to
  48 +generate a
  49 +`ds9 region file <http://ds9.si.edu/doc/ref/region.html>`_ file:
  50 +
  51 +.. code-block:: bash
  52 +
  53 + $ nano exclude.reg
  54 + fk5
  55 + circle(266.42, -29.01, 0.3)
  56 +
  57 +and use this file as ``Input exclusion region file in ds9 format`` in
  58 +the :ref:`ctcubemask` run:
  59 +
  60 +.. code-block:: bash
  61 +
  62 + $ ctcubemask
  63 + Input counts cube or observation definition XML file [cntcube.fits]
  64 + Input exclusion region file in ds9 format [NONE] exclude.reg
  65 + RA for ROI centre (degrees) (0-360) [83.63] 266.42
  66 + Dec for ROI centre (degrees) (-90-90) [22.01] -29.01
  67 + Radius of ROI (degrees) (0-180) [3.0] 1.0
  68 + Lower energy limit (TeV) [0.1]
  69 + Upper energy limit (TeV) [100.0]
  70 + Output counts cube or observation definition XML file [cntcube_filtered.fits] cntcube_filtered_exclude.fits
  71 +
  72 +The resulting counts cube, summed over the energy axis, is shown
  73 +in the following image.
  74 +
  75 +.. figure:: howto_filtered_exclude.png
  76 + :width: 400px
  77 + :align: center
  78 +
  79 + *Filtered counts cube with exclusion region*
... ...
doc/source/users/tutorials/1dc/howto_extent.rst
... ... @@ -3,10 +3,10 @@
3 3 How to determine the extension of a source?
4 4 -------------------------------------------
5 5  
6   -.. admonition:: You will learn ...
  6 + .. admonition:: What you will learn
7 7  
8   - ... how you **determine the spatial extent of a source** by fitting an
9   - extended source model to the data.
  8 + You will learn how you **determine the spatial extent of a source** by
  9 + fitting an extended source model to the data.
10 10  
11 11 To determine the spatial extension of a source, an extended source model
12 12 has to be used in the
... ... @@ -15,7 +15,7 @@ of the source of interest.
15 15 In the example below, a ``RadialGaussian`` model is used for the source
16 16 ``Src001`` to model the spatial morphology of the source by an axisymmetric
17 17 Gaussian profile with the Gaussian width ``sigma`` as free parameter.
18   -Note that at the same time the source type has been set to
  18 +Note that at the same time the source type was set to
19 19 ``ExtendedSource``.
20 20  
21 21 .. code-block:: xml
... ... @@ -41,31 +41,31 @@ log file and will also be written into the output
41 41 :ref:`model definition file <glossary_moddef>`.
42 42  
43 43 For illustration, an excerpt of the :ref:`ctlike` log file is shown below.
44   -The Gaussian width of ``Src001`` has been fitted to 0.0218 +/- 0.0006 degrees.
  44 +The Gaussian width of ``Src001`` has been fitted to 0.049 +/- 0.001 degrees.
45 45  
46 46 .. code-block:: xml
47 47  
48   - 2017-03-04T17:44:06: === GModelSky ===
49   - 2017-03-04T17:44:06: Name ......................: Src001
50   - 2017-03-04T17:44:06: Instruments ...............: all
51   - 2017-03-04T17:44:06: Instrument scale factors ..: unity
52   - 2017-03-04T17:44:06: Observation identifiers ...: all
53   - 2017-03-04T17:44:06: Model type ................: ExtendedSource
54   - 2017-03-04T17:44:06: Model components ..........: "RadialGaussian" * "PowerLaw" * "Constant"
55   - 2017-03-04T17:44:06: Number of parameters ......: 7
56   - 2017-03-04T17:44:06: Number of spatial par's ...: 3
57   - 2017-03-04T17:44:06: RA .......................: 266.416716505268 +/- 0.000753191747203773 [-360,360] deg (free,scale=1)
58   - 2017-03-04T17:44:06: DEC ......................: -29.0044104159472 +/- 0.000655420291471696 [-90,90] deg (free,scale=1)
59   - 2017-03-04T17:44:06: Sigma ....................: 0.02183871432113 +/- 0.000636651479386333 [0.001,10] deg (free,scale=1)
60   - 2017-03-04T17:44:06: Number of spectral par's ..: 3
61   - 2017-03-04T17:44:06: Prefactor ................: 4.85894838349519e-17 +/- 7.40461052122477e-19 [0,infty[ ph/cm2/s/MeV (free,scale=5.7e-18,gradient)
62   - 2017-03-04T17:44:06: Index ....................: -2.29168205335762 +/- 0.00909936860902909 [10,-10] (free,scale=-2.48,gradient)
63   - 2017-03-04T17:44:06: PivotEnergy ..............: 300000 MeV (fixed,scale=300000,gradient)
64   - 2017-03-04T17:44:06: Number of temporal par's ..: 1
65   - 2017-03-04T17:44:06: Normalization ............: 1 (relative value) (fixed,scale=1,gradient)
  48 + 2017-06-03T16:09:45: === GModelSky ===
  49 + 2017-06-03T16:09:45: Name ......................: Src001
  50 + 2017-06-03T16:09:45: Instruments ...............: all
  51 + 2017-06-03T16:09:45: Instrument scale factors ..: unity
  52 + 2017-06-03T16:09:45: Observation identifiers ...: all
  53 + 2017-06-03T16:09:45: Model type ................: ExtendedSource
  54 + 2017-06-03T16:09:45: Model components ..........: "RadialGaussian" * "ExponentialCutoffPowerLaw" * "Constant"
  55 + 2017-06-03T16:09:45: Number of parameters ......: 8
  56 + 2017-06-03T16:09:45: Number of spatial par's ...: 3
  57 + 2017-06-03T16:09:45: RA .......................: 266.420293012532 +/- 0.00132113631921452 [-360,360] deg (free,scale=1)
  58 + 2017-06-03T16:09:45: DEC ......................: -29.0055014958646 +/- 0.00116849557635297 [-90,90] deg (free,scale=1)
  59 + 2017-06-03T16:09:45: Sigma ....................: 0.0488254879944832 +/- 0.000993438752316212 [0.001,10] deg (free,scale=1)
  60 + 2017-06-03T16:09:45: Number of spectral par's ..: 4
  61 + 2017-06-03T16:09:45: Prefactor ................: 3.2695646853429e-17 +/- 6.35060270585935e-19 [1e-25,1e-15] ph/cm2/s/MeV (free,scale=1e-18,gradient)
  62 + 2017-06-03T16:09:45: Index ....................: -2.25022445798271 +/- 0.0188890753731813 [-0,-5] (free,scale=-1,gradient)
  63 + 2017-06-03T16:09:45: CutoffEnergy .............: 28286052.9486927 +/- 6883002.00397237 [100000,10000000000] MeV (free,scale=10000000,gradient)
  64 + 2017-06-03T16:09:45: PivotEnergy ..............: 300000 [10000,1000000000] MeV (fixed,scale=1000000,gradient)
  65 + 2017-06-03T16:09:45: Number of temporal par's ..: 1
  66 + 2017-06-03T16:09:45: Normalization ............: 1 (relative value) (fixed,scale=1,gradient)
66 67  
67 68 .. warning::
68   - The errors returned by :ref:`ctlike` are purely statistical. In addition
69   - there are systematic uncertainties, such as for example the limits in the
70   - knowledge of the point spread function. It remains to be seen whether CTA
71   - will be able to reliably determine source extents as small as 0.02 degrees.
  69 + The parameter errors returned by :ref:`ctlike` are purely statistical. In
  70 + addition to the statistical errors there are systematic uncertainties, such
  71 + as for example the limits on the knowledge of the point spread function.
... ...
doc/source/users/tutorials/1dc/howto_filtered_exclude.png 0 → 100644

56.5 KB

doc/source/users/tutorials/1dc/howto_lightcurve.rst
... ... @@ -3,10 +3,10 @@
3 3 How to generate a light curve?
4 4 ------------------------------
5 5  
6   -.. admonition:: You will learn ...
  6 + .. admonition:: What you will learn
7 7  
8   - ... how to **generate a light curve** for a source using the
9   - :ref:`cslightcrv` script.
  8 + You will learn how to **generate a light curve** for a source to study
  9 + the temporal variation of the flux and spectrum.
10 10  
11 11 You can generate a light curve using the :ref:`cslightcrv` script which
12 12 takes on input an
... ... @@ -25,7 +25,7 @@ The following example illustrates how you can generate a light curve for
25 25 corresponding to the dates from 2021-01-21 (12:00:00) to 2021-01-22 (00:00:00)
26 26 (to convert dates to MJD and vice versa we suggest to use the
27 27 `xTime Date and Time Conversion Utility <https://heasarc.gsfc.nasa.gov/cgi-bin/Tools/xTime/xTime.pl>`_).
28   -The time interval is linearly divided into 100 time bins.
  28 +The time interval is linearly divided into 20 time bins.
29 29  
30 30 .. code-block:: bash
31 31  
... ...
doc/source/users/tutorials/1dc/howto_phasecurve.rst
1 1 .. _1dc_howto_phasecurve:
2 2  
3   -How to generate a phase curve of a pulsar or a gamma-ray binary?
4   -----------------------------------------------------------------
5   -
6   -So far there are no tools in ctools to generate phase curves of pulsars or
7   -gamma-ray binaries. A plugin for
8   -`tempo2 <http://www.atnf.csiro.au/research/pulsar/tempo2/>`_
9   -is under development by the ctools developers, and you may get in touch
10   -with Thierry Reposeur (reposeur@in2p3.fr) for information about this
11   -development.
12   -
13   -If you know the phase information of the pulsar or gamma-ray binary,
14   -you may specify a ``temporal`` model component of type ``PhaseCurve`` in the
  3 +How to generate a phase curve of a pulsar?
  4 +------------------------------------------
  5 +
  6 + .. admonition:: What you will learn
  7 +
  8 + You will learn how to **derive a phase curve for a pulsar**.
  9 +
  10 +To determine the phase curve of a pulsar you first need the ephemerides
  11 +of the pulsar of interest. In this example we suppose that you want to
  12 +analyse the Vela Pulsar which for an epoch of 54686.2 (MJD) has the
  13 +following ephemerides:
  14 +
  15 +* :math:`f = 11.19 \, {\rm s}^{-1}`
  16 +* :math:`\dot{f} = -1.55 \, 10^{-11} \, {\rm s}^{-2}`
  17 +* :math:`\ddot{f} = 6.46 \, 10^{-23} \, {\rm s}^{-3}`
  18 +
  19 +You need to enter these ephemerides into a
15 20 :ref:`model definition file <glossary_moddef>`
16   -for the source and fit the information using an unbinned analysis.
17   -An example of a
  21 +with the following structure (note that the spectral and spatial information
  22 +is irrelevant for this example):
  23 +
  24 +.. code-block:: xml
  25 +
  26 + <?xml version="1.0" encoding="UTF-8" standalone="no"?>
  27 + <source_library title="source library">
  28 + <source name="VelaPulsar" type="PointSource">
  29 + <spectrum type="PowerLaw">
  30 + <parameter name="Prefactor" scale="1e-14" value="19.4" min="1e-07" max="1000.0" free="1"/>
  31 + <parameter name="Index" scale="-1" value="4.45" min="0.0" max="+10.0" free="1"/>
  32 + <parameter name="PivotEnergy" scale="1e3" value="20.0" min="0.01" max="1000.0" free="0"/>
  33 + </spectrum>
  34 + <spatialModel type="PointSource">
  35 + <parameter name="RA" scale="1" value="128.838" min="-360" max="360" free="0"/>
  36 + <parameter name="DEC" scale="1" value="-45.178" min="-90" max="90" free="0"/>
  37 + </spatialModel>
  38 + <temporal type="PhaseCurve" file="$CTADATA/models/phasecurve_J0835-4510.fits">
  39 + <parameter name="Normalization" scale="1" value="1.0" min="0.0" max="1000.0" free="0"/>
  40 + <parameter name="MJD" scale="1" value="54686.2" min="0.0" max="100000.0" free="0"/>
  41 + <parameter name="Phase" scale="1" value="0.0" min="0.0" max="1.0" free="0"/>
  42 + <parameter name="F0" scale="1" value="11.19" min="0.0" max="1000.0" free="0"/>
  43 + <parameter name="F1" scale="1e-11" value="-1.55" min="-10.0" max="1000.0" free="0"/>
  44 + <parameter name="F2" scale="1e-23" value="6.46" min="0.0" max="1000.0" free="0"/>
  45 + </temporal>
  46 + </source>
  47 + </source_library>
  48 +
  49 +As next step you need to select all observations from the data with pointing
  50 +directions close to the Vela pulsar. In the example below, all observations
  51 +from the Galactic Plane Scan with pointing directions within 5 degrees of the
  52 +Vela pulsar are selected:
  53 +
  54 +.. code-block:: bash
  55 +
  56 + $ csobsselect
  57 + Input event list or observation definition XML file [obs.xml] $CTADATA/obs/obs_gps_baseline.xml
  58 + Pointing selection region shape (CIRCLE|BOX) [CIRCLE]
  59 + Coordinate system (CEL - celestial, GAL - galactic) (CEL|GAL) [CEL]
  60 + Galactic longitude of selection centre (deg) (0-360) [184.56] 128.838
  61 + Galactic latitude of selection centre (deg) (-90-90) [-5.79] -45.178
  62 + Radius of selection circle (deg) (0-180) [5.0]
  63 + Output observation definition XML file [outobs.xml] obs_vela.xml
  64 +
  65 +This results in a selection of 45 observations from the Galactic Plane Survey
  66 +that will be compiled in the ``obs_vela.xml``
  67 +:ref:`observation definition file <glossary_obsdef>`.
  68 +Now you can compute the phase for every event in your selection using the
  69 +ephemerides of the Vela pulsar. You do this with the :ref:`ctphase` tool
  70 +as follows:
  71 +
  72 +.. code-block:: bash
  73 +
  74 + $ ctphase
  75 + Input event list or observation definition XML file [events.fits] obs_vela.xml
  76 + Model definition XML file [$CTOOLS/share/models/crab.xml] models.xml
  77 + Source in model definition XML file to use for phase computation [Crab] VelaPulsar
  78 + Output event list or observation definition XML file [phased_events.fits] obs_vela_phased.xml
  79 +
  80 +This produces a new
  81 +:ref:`observation definition file <glossary_obsdef>`
  82 +``obs_vela_phased.xml`` that points to event files to which a ``PHASE``
  83 +column was added. The format of the file is dislayed below. Each event
  84 +has now an associated phase value that was computed from the trigger time of
  85 +the event.
  86 +
  87 +.. figure:: howto_phasecurve_events.png
  88 + :width: 700px
  89 + :align: center
  90 +
  91 + *Event list file with phase information for the Vela pulsar*
  92 +
  93 +To generate now a phase curve of the Vela pulsar you need to select all events
  94 +that are close to the source using the :ref:`ctselect` tool. To select for
  95 +example all events within 0.5 degrees of the Vela pulsar you need to type
  96 +the following:
  97 +
  98 +.. code-block:: bash
  99 +
  100 + $ ctselect
  101 + Input event list or observation definition XML file [events.fits] obs_vela_phased.xml
  102 + RA for ROI centre (degrees) (0-360) [83.63] 128.838
  103 + Dec for ROI centre (degrees) (-90-90) [22.01] -45.178
  104 + Radius of ROI (degrees) (0-180) [3.0] 0.5
  105 + Start time (CTA MET in seconds) [0.0]
  106 + End time (CTA MET in seconds) [0.0]
  107 + Lower energy limit (TeV) [0.1] 0.03
  108 + Upper energy limit (TeV) [100.0] 160.0
  109 + Output event list or observation definition XML file [selected_events.fits] obs_vela_phased_selected.xml
  110 +
  111 +The selected events as a function of phase are displayed below. There is no
  112 +obvious indication of a phase dependence of the event rate.
  113 +
  114 +.. figure:: howto_phasecurve_phases.png
  115 + :width: 600px
  116 + :align: center
  117 +
  118 + *Phase histogram for events selected within 0.5 degrees of the Vela pulsar*
  119 +
  120 +An alternative method to select events from the
  121 +:ref:`observation definition file <glossary_obsdef>`
  122 +is based on the computation of the probability that the event arises from a
  123 +specific model component. To perform such a computation you have to
  124 +
  125 +* add a background model component, and
  126 +* drop the temporal component from the Vela pulsar
  127 +
  128 +in the
  129 +:ref:`model definition file <glossary_moddef>`. The resulting
18 130 :ref:`model definition file <glossary_moddef>`
19   -including a ``PhaseCurve`` model component is shown below.
20   -For more information, please read the following
21   -:ref:`description of the temporal model components <sec_temporal_models>`.
  131 +should look as follows:
22 132  
23 133 .. code-block:: xml
24 134  
25   - <?xml version="1.0" standalone="no"?>
  135 + <?xml version="1.0" encoding="UTF-8" standalone="no"?>
26 136 <source_library title="source library">
27   - <source name="Crab" type="PointSource">
  137 + <source name="VelaPulsar" type="PointSource">
  138 + <spectrum type="PowerLaw">
  139 + <parameter name="Prefactor" scale="1e-14" value="19.4" min="1e-07" max="1000.0" free="1"/>
  140 + <parameter name="Index" scale="-1" value="4.45" min="0.0" max="+10.0" free="1"/>
  141 + <parameter name="PivotEnergy" scale="1e3" value="20.0" min="0.01" max="1000.0" free="0"/>
  142 + </spectrum>
28 143 <spatialModel type="PointSource">
29   - <parameter name="RA" scale="1" value="83.6331" min="-360" max="360" free="0"/>
30   - <parameter name="DEC" scale="1" value="22.0145" min="-90" max="90" free="0"/>
  144 + <parameter name="RA" scale="1" value="128.838" min="-360" max="360" free="0"/>
  145 + <parameter name="DEC" scale="1" value="-45.178" min="-90" max="90" free="0"/>
31 146 </spatialModel>
  147 + </source>
  148 + <source name="Background" type="CTAIrfBackground">
32 149 <spectrum type="PowerLaw">
33   - <parameter name="Prefactor" scale="1e-16" value="5.7" min="1e-07" max="1000.0" free="1"/>
34   - <parameter name="Index" scale="-1" value="2.48" min="0.0" max="+5.0" free="1"/>
35   - <parameter name="PivotEnergy" scale="1e6" value="0.3" min="0.01" max="1000.0" free="0"/>
  150 + <parameter name="Prefactor" value="1" error="0" scale="1" min="0" free="1" />
  151 + <parameter name="Index" value="0" error="0" scale="1" min="-10" max="10" free="1" />
  152 + <parameter name="PivotEnergy" value="1" scale="1000000" free="0" />
36 153 </spectrum>
37   - <temporal type="PhaseCurve" file="model_temporal_phasecurve.fits">
38   - <parameter name="Normalization" scale="1" value="1.0" min="0.0" max="1000.0" free="0"/>
39   - <parameter name="MJD" scale="1" value="51544.5" min="0.0" max="100000.0" free="0"/>
40   - <parameter name="Phase" scale="1" value="0.0" min="0.0" max="1.0" free="0"/>
41   - <parameter name="F0" scale="1" value="1.0" min="0.0" max="1000.0" free="0"/>
42   - <parameter name="F1" scale="1" value="0.1" min="0.0" max="1000.0" free="0"/>
43   - <parameter name="F2" scale="1" value="0.01" min="0.0" max="1000.0" free="0"/>
44   - </temporal>
45 154 </source>
46 155 </source_library>
47 156  
  157 +You can then run the :ref:`ctprob` tool that computes the probability that an
  158 +event arises either from the source or from the background component:
  159 +
  160 +.. code-block:: bash
  161 +
  162 + $ ctprob
  163 + Input event list or observation definition XML file [events.fits] obs_vela_phased.xml
  164 + Input model definition XML file [$CTOOLS/share/models/crab.xml] models_prob.xml
  165 + Output event list or observation definition XML file [prob_events.fits] obs_vela_phased_prob.xml
  166 +
  167 +This produces a new
  168 +:ref:`observation definition file <glossary_obsdef>`
  169 +``obs_vela_phased_prob.xml`` that points to event files to which the
  170 +``PROB_VelaPulsar`` and ``PROB_Background`` columns have been added.
  171 +The format of the file is dislayed below. Each event has now an associated
  172 +probability value for all model components.
  173 +
  174 +.. figure:: howto_phasecurve_prob.png
  175 + :width: 800px
  176 + :align: center
  177 +
  178 + *Event list file with phase and probability information for the Vela pulsar and probability information for the background model*
  179 +
  180 +You now can perform an event selection based on the probability that an event
  181 +originates from the Vela pulsar. In the following example we set the
  182 +probability threshold to >20% by adding the attribute
  183 +``expr="PROB_VelaPulsar>0.2"`` after the :ref:`ctselect` command:
  184 +
  185 +.. code-block:: bash
  186 +
  187 + $ ctselect expr="PROB_VelaPulsar>0.2"
  188 + Input event list or observation definition XML file [obs_vela_phased.xml] obs_vela_phased_prob.xml
  189 + RA for ROI centre (degrees) (0-360) [128.838]
  190 + Dec for ROI centre (degrees) (-90-90) [-45.178]
  191 + Radius of ROI (degrees) (0-180) [0.5] 5.0
  192 + Start time (CTA MET in seconds) [0.0]
  193 + End time (CTA MET in seconds) [0.0]
  194 + Lower energy limit (TeV) [0.03]
  195 + Upper energy limit (TeV) [160.0]
  196 + Output event list or observation definition XML file [obs_vela_phased_selected.xml] obs_vela_phased_prob_selected.xml
  197 +
  198 +The selected events as a function of phase are displayed below. Unfortunately
  199 +there is still no indication of a phase dependence of the event rate.
  200 +
  201 +.. figure:: howto_phasecurve_probphases.png
  202 + :width: 600px
  203 + :align: center
  204 +
  205 + *Phase histogram of events for events having a probability of >20% in originating from the Vela pulsar*
  206 +
  207 +Since every event in the event files of the Data Challenge is tagged with a
  208 +Monte Carlo identifier that specifies from which model component it was
  209 +simulated, you may check how many events from the Vela pulsar are actually
  210 +expected in the data. The correspondance between the model components and
  211 +the Monte Carlo identifiers is given in the header of the event files
  212 +(see :ref:`1dc_data_organisation`), and from there you will find out that
  213 +the Vela pulsar has the Monte Carlo identifier ``86``. You can then select only
  214 +the events with this identifier by adding the attribute ``expr="MC_ID==86"``
  215 +after the :ref:`ctselect` command:
  216 +
  217 +.. code-block:: bash
  218 +
  219 + $ ctselect expr="MC_ID==86"
  220 + Input event list or observation definition XML file [obs_vela_phased_prob.xml] obs_vela_phased.xml
  221 + RA for ROI centre (degrees) (0-360) [128.838]
  222 + Dec for ROI centre (degrees) (-90-90) [-45.178]
  223 + Radius of ROI (degrees) (0-180) [5.0]
  224 + Start time (CTA MET in seconds) [0.0]
  225 + End time (CTA MET in seconds) [0.0]
  226 + Lower energy limit (TeV) [0.03]
  227 + Upper energy limit (TeV) [160.0]
  228 +
  229 +The resulting phase histogram is shown below. It now becomes obvious that there
  230 +are too few events in the simulated data to allow for a significant detection
  231 +of the pulsar. The events from the Vela pulsar are in fact burried into the
  232 +background events.
  233 +
  234 +.. figure:: howto_phasecurve_mcid.png
  235 + :width: 700px
  236 + :align: center
  237 +
  238 + *Distribution of Vela pulsar events as function of event phase*
  239 +
  240 +.. note::
  241 + The plots were created using the ``show_phases.py`` script that is
  242 + located in the ctools example folder. The example script requires the
  243 + `matplotlib <http://matplotlib.org>`_ Python module for display.
  244 + You may reproduce the plots by typing
  245 +
  246 + .. code-block:: bash
  247 +
  248 + $ $CTOOLS/share/examples/python/show_phases.py obs_vela_phased_selected.xml
  249 + $ $CTOOLS/share/examples/python/show_phases.py obs_vela_phased_prob_selected.xml
  250 + $ $CTOOLS/share/examples/python/show_phases.py obs_vela_phased_mcid.xml
48 251  
49 252  
50 253  
... ...
doc/source/users/tutorials/1dc/howto_phasecurve_events.png 0 → 100644

129 KB

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

12.5 KB

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

16 KB

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

153 KB

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

14.2 KB

doc/source/users/tutorials/1dc/howto_ts.rst
... ... @@ -3,15 +3,15 @@
3 3 How to compute the signifiance of a source?
4 4 -------------------------------------------
5 5  
6   -.. admonition:: You will learn ...
  6 + .. admonition:: What you will learn
7 7  
8   - ... how to **compute the significance of a source detection** using the
9   - :ref:`ctlike` tool.
  8 + You will learn how to **compute the significance of a source detection**
  9 + using the :ref:`ctlike` tool.
10 10  
11 11 To compute the detection significance of a given source you need to add the
12 12 attribute ``tscalc="1"`` to the ``<source>`` tag in the
13 13 :ref:`model definition file <glossary_moddef>`
14   -and execute :ref:`ctlike` using this file.
  14 +and execute :ref:`ctlike` using the modified file.
15 15 The structure of the XML file with significance computation requested for
16 16 ``Src001`` is shown below.
17 17  
... ... @@ -43,7 +43,7 @@ freedom, where :math:`p` is the number of free parameters of ``Src001``.
43 43 For :math:`p=1`, the source significance is the square root of the Test
44 44 Statistic.
45 45  
46   -An excerpt of the :ref:`ctlike` log file is shown below where signifance
  46 +An excerpt of the :ref:`ctlike` log file is shown below where significance
47 47 computation was requested for ``Src001`` and ``Src002``. The computation was
48 48 done using a stacked analysis.
49 49  
... ...
doc/source/users/tutorials/1dc/howto_tsmap.rst
... ... @@ -3,10 +3,10 @@
3 3 How to generate a Test Statistic map?
4 4 -------------------------------------
5 5  
6   -.. admonition:: You will learn ...
  6 + .. admonition:: What you will learn
7 7  
8   - ... how to **generate a map of source detection significances** using the
9   - :ref:`cttsmap` tool.
  8 + You will learn how to **generate a map of source detection significances**
  9 + to localise a gamma-ray source.
10 10  
11 11 If you want to know how the Test Statistic changes with source position you
12 12 can create a Test Statistic map using the :ref:`cttsmap` tool. A Test
... ... @@ -56,12 +56,12 @@ The figure below shows the resulting Test Statistic map.
56 56  
57 57 The ``binmin`` and ``binmax`` parameters can be used to compute only a
58 58 subset of the bins in a map (see :ref:`cttsmap`). This functionality is
59   - used by the :ref:`cstsmapsplit` to generate a command sequence that is
  59 + used by the :ref:`cstsmapsplit` script to generate a command sequence that is
60 60 useful for parallelizing the Test Statistic map computation. The
61 61 :ref:`cstsmapmerge` script can then be used to recombine the different
62 62 partial maps into a single Test Statistic map.
63 63  
64   - To produce the same result that has been produced above by the single
  64 + To produce the same result that was produced above by the single
65 65 :ref:`cttsmap` run, now however split over ten :ref:`cttsmap` jobs that
66 66 can be executed in parallel, type
67 67  
... ... @@ -86,7 +86,7 @@ The figure below shows the resulting Test Statistic map.
86 86 Compute null hypothesis first? [yes]
87 87 ASCII file containing all commands [commands.dat] tsmap_commands.dat
88 88  
89   - The :ref:`cstsmapmerge` script creates the following ASCII file on output:
  89 + The :ref:`cstsmapsplit` script creates the following ASCII file on output:
90 90  
91 91 .. code-block:: bash
92 92  
... ... @@ -107,9 +107,9 @@ The figure below shows the resulting Test Statistic map.
107 107  
108 108 ./tsmap_commands.dat
109 109  
110   - This will execute ten :ref:`cttsmap` jobs and parallel that each creates
111   - ten pixels of the Test Statistic map. You combine the resulting ten Test
112   - Statistic maps into a single map by typing
  110 + This will execute 10 :ref:`cttsmap` jobs in parallel. Each of the jobs will
  111 + compute 10 pixels of the Test Statistic map. You combine the resulting 10
  112 + Test Statistic maps into a single map by typing
113 113  
114 114 .. code-block:: bash
115 115  
... ...
doc/source/users/tutorials/1dc/howto_ulimit.rst
... ... @@ -3,10 +3,10 @@
3 3 How to compute upper limits?
4 4 ----------------------------
5 5  
6   -.. admonition:: You will learn ...
  6 + .. admonition:: What you will learn
7 7  
8   - ... how to **determine the upper flux limit for a source** using the
9   - :ref:`ctulimit` tool.
  8 + You will learn how to **determine the upper flux limit for a source**
  9 + using the :ref:`ctulimit` tool.
10 10  
11 11 You determine upper limits for gamma-ray sources using the :ref:`ctulimit`
12 12 tool.
... ... @@ -34,7 +34,7 @@ for example
34 34 </spatialModel>
35 35 </source>
36 36  
37   -and then run the :ref:`ctulimit` as follows:
  37 +and then run the :ref:`ctulimit` tool as follows:
38 38  
39 39 .. code-block:: bash
40 40  
... ... @@ -51,12 +51,12 @@ extracted from the :ref:`ctulimit` log file:
51 51  
52 52 .. code-block:: bash
53 53  
54   - 2017-03-04T20:29:08: +=====================+
55   - 2017-03-04T20:29:08: | Upper limit results |
56   - 2017-03-04T20:29:08: +=====================+
57   - 2017-03-04T20:29:08: Differential flux limit ...: 1.01134913337855e-20 ph/cm2/s/MeV at 1 TeV
58   - 2017-03-04T20:29:08: Integral flux limit .......: 6.82594737233183e-15 ph/cm2/s within [1-100] TeV
59   - 2017-03-04T20:29:08: Energy flux limit .........: 3.00560602939917e-14 erg/cm2/s within [1-100] TeV
  54 + 2017-06-02T17:00:09: +=====================+
  55 + 2017-06-02T17:00:09: | Upper limit results |
  56 + 2017-06-02T17:00:09: +=====================+
  57 + 2017-06-02T17:00:09: Differential flux limit ...: 4.50187740703557e-20 ph/cm2/s/MeV at 1 TeV
  58 + 2017-06-02T17:00:09: Integral flux limit .......: 3.03847378149801e-14 ph/cm2/s within [1-100] TeV
  59 + 2017-06-02T17:00:09: Energy flux limit .........: 1.33790294880664e-13 erg/cm2/s within [1-100] TeV
60 60  
61 61 .. warning::
62 62 It is important to fix the spectral index of the test source in the
... ...
doc/source/users/tutorials/1dc/howto_vo.rst
... ... @@ -3,12 +3,12 @@
3 3 How to use Virtual Observatory tools with ctools?
4 4 -------------------------------------------------
5 5  
6   -.. admonition:: You will learn ...
  6 + .. admonition:: What you will learn
7 7  
8   - ... how to interaction with Virtual Observatory tools such as
9   - `Aladin <http://aladin.u-strasbg.fr>`_
10   - or
11   - `Topcat <http://www.star.bris.ac.uk/~mbt/topcat/>`_.
  8 + You will learn how to interact with the Virtual Observatory tools
  9 + `Aladin <http://aladin.u-strasbg.fr>`_ for image display and
  10 + `Topcat <http://www.star.bris.ac.uk/~mbt/topcat/>`_ for display of tables
  11 + such as event lists.
12 12  
13 13 Several ctools can interact with Virtual Observatory tools such as
14 14 `Aladin <http://aladin.u-strasbg.fr>`_
... ... @@ -117,9 +117,7 @@ energy (see below).
117 117 *Display of event list in 3-dimensional representation*
118 118  
119 119 Below the list of tools and scripts that interact with Virtual Observatory
120   -tools. Some tools or scripts publish tables instead of images, and the tables
121   -can for example by displayed and explored using
122   -`Topcat <http://www.star.bris.ac.uk/~mbt/topcat/>`_.
  120 +tools.
123 121  
124 122 +-------------------+--------+-------------------+
125 123 | Tool or script | Object | VO tool (example) |
... ... @@ -146,6 +144,10 @@ can for example by displayed and explored using
146 144 +-------------------+--------+-------------------+
147 145 | :ref:`ctobssim` | Table | Topcat |
148 146 +-------------------+--------+-------------------+
  147 + | :ref:`ctphase` | Table | Topcat |
  148 + +-------------------+--------+-------------------+
  149 + | :ref:`ctprob` | Table | Topcat |
  150 + +-------------------+--------+-------------------+
149 151 | :ref:`ctselect` | Table | Topcat |
150 152 +-------------------+--------+-------------------+
151 153 | :ref:`ctskymap` | Image | Aladin |
... ...