Commit 1c97acc16130d40cbc355f4ca45cee9157b9faee
1 parent
fd516957
Add Fermi-LAT tutorials
Showing
19 changed files
with
801 additions
and
3 deletions
doc/source/users/tutorials/howto/fermi/howto_fermi_butterfly.png
0 → 100644
40.5 KB
doc/source/users/tutorials/howto/fermi/howto_fermi_butterfly.rst
0 → 100644
| 1 | +.. _howto_fermi_butterfly: | ||
| 2 | + | ||
| 3 | +Generate a butterfly diagram for a model component | ||
| 4 | +-------------------------------------------------- | ||
| 5 | + | ||
| 6 | + .. admonition:: What you will learn | ||
| 7 | + | ||
| 8 | + You will learn how to use :ref:`ctbutterfly` to create a butterfly diagram | ||
| 9 | + for a model component from Fermi-LAT data. | ||
| 10 | + | ||
| 11 | +A butterfly diagram shows the envelope of all spectral models that are | ||
| 12 | +statistically compatible with the data. You can create such a butterfly | ||
| 13 | +diagram for the Vela pulsar using the :ref:`ctbutterfly` tool by providing | ||
| 14 | +the | ||
| 15 | +:ref:`model definition file <glossary_moddef>` | ||
| 16 | +output file from :ref:`ctlike` as input: | ||
| 17 | + | ||
| 18 | +.. code-block:: bash | ||
| 19 | + | ||
| 20 | + $ ctbutterfly | ||
| 21 | + Input event list, counts cube or observation definition XML file [events.fits] obs.xml | ||
| 22 | + Source of interest [Crab] Vela | ||
| 23 | + Input model definition XML file [$CTOOLS/share/models/crab.xml] vela_results.xml | ||
| 24 | + Start value for first energy bin in TeV [0.1] 0.0001 | ||
| 25 | + Stop value for last energy bin in TeV [100.0] 0.1 | ||
| 26 | + Output ASCII file [butterfly.txt] | ||
| 27 | + | ||
| 28 | +:ref:`ctbutterfly` produces the ASCII file ``butterfly.txt`` that contains | ||
| 29 | +the envelope of the butterfly diagram. The figure below gives a graphical | ||
| 30 | +representation of the envelope. | ||
| 31 | + | ||
| 32 | +.. figure:: howto_fermi_butterfly.png | ||
| 33 | + :width: 600px | ||
| 34 | + :align: center | ||
| 35 | + | ||
| 36 | + *Butterfly diagram of the fitted Vela pulsar spectrum* | ||
| 37 | +.. | ||
| 38 | + | ||
| 39 | + .. note:: | ||
| 40 | + | ||
| 41 | + The figure was created using the ``show_butterfly.py`` script that is | ||
| 42 | + located in the ctools example folder. The example script requires the | ||
| 43 | + `matplotlib <http://matplotlib.org>`_ Python module for display. | ||
| 44 | + You may reproduce the plot by typing | ||
| 45 | + | ||
| 46 | + .. code-block:: bash | ||
| 47 | + | ||
| 48 | + $ $CTOOLS/share/examples/python/show_butterfly.py butterfly.txt |
doc/source/users/tutorials/howto/fermi/howto_fermi_data.jpg
0 → 100644
272 KB
doc/source/users/tutorials/howto/fermi/howto_fermi_errors.rst
0 → 100644
| 1 | +.. _howto_fermi_errors: | ||
| 2 | + | ||
| 3 | +Determine asymmetric model parameter errors for a model component | ||
| 4 | +----------------------------------------------------------------- | ||
| 5 | + | ||
| 6 | + .. admonition:: What you will learn | ||
| 7 | + | ||
| 8 | + You will learn how to use :ref:`cterror` to derive asymmetric model | ||
| 9 | + parameter errors from Fermi-LAT data using a likelihood profile method. | ||
| 10 | + | ||
| 11 | +The :ref:`ctlike` tool computes errors for each fitted parameter value based | ||
| 12 | +on the covariance matrix of the fit. This assumes a Gaussian approximation | ||
| 13 | +of the uncertainties around the best fitting values. Uncertainties may however | ||
| 14 | +by asymmetric. | ||
| 15 | + | ||
| 16 | +To test the symmetry of the uncertainties you can use the :ref:`cterror` | ||
| 17 | +tool. :ref:`cterror` will make use of the likelihood profile to determine | ||
| 18 | +the confidence interval for each fitted parameter, allowing thus also for | ||
| 19 | +asymmetric errors. You use :ref:`cterror` as follows: | ||
| 20 | + | ||
| 21 | +.. code-block:: bash | ||
| 22 | + | ||
| 23 | + $ cterror | ||
| 24 | + Input event list, counts cube or observation definition XML file [events.fits] obs.xml | ||
| 25 | + Source of interest [Crab] Vela | ||
| 26 | + Input model definiton XML file [$CTOOLS/share/models/crab.xml] vela_results.xml | ||
| 27 | + Output model definiton XML file [results.xml] vela_errors.xml | ||
| 28 | + | ||
| 29 | +The confidence intervals can then be extracted from the ``cterror.log`` log file | ||
| 30 | +that was created by :ref:`cterror`. As you will see, the parameter errors | ||
| 31 | +are essentially symmetric and very close to the values determined using the | ||
| 32 | +covariance matrix. | ||
| 33 | + | ||
| 34 | +.. code-block:: bash | ||
| 35 | + | ||
| 36 | + 2017-08-26T14:16:00: +=======================================================+ | ||
| 37 | + 2017-08-26T14:16:00: | Compute error for source "Vela" parameter "Prefactor" | | ||
| 38 | + 2017-08-26T14:16:00: +=======================================================+ | ||
| 39 | + 2017-08-26T14:16:00: Confidence level ..........: 68 % | ||
| 40 | + 2017-08-26T14:16:00: Log-likelihood difference .: 0.494473 | ||
| 41 | + 2017-08-26T14:16:00: Initial factor range ......: [1e-07, 9.10916268820218] | ||
| 42 | + 2017-08-26T14:16:20: Lower parameter factor ....: 3.93549 | ||
| 43 | + 2017-08-26T14:16:20: Upper parameter factor ....: 4.89285 | ||
| 44 | + 2017-08-26T14:16:20: Error from curvature ......: 4.75365104151534e-10 ph/cm2/s/MeV | ||
| 45 | + 2017-08-26T14:16:20: Error from profile ........: 4.78682555317737e-10 ph/cm2/s/MeV | ||
| 46 | + 2017-08-26T14:16:20: Negative profile error ....: 4.20026137925122e-10 ph/cm2/s/MeV | ||
| 47 | + 2017-08-26T14:16:20: Positive profile error ....: 5.37338972710351e-10 ph/cm2/s/MeV | ||
| 48 | + 2017-08-26T14:16:20: | ||
| 49 | + 2017-08-26T14:16:20: +====================================================+ | ||
| 50 | + 2017-08-26T14:16:20: | Compute error for source "Vela" parameter "Index1" | | ||
| 51 | + 2017-08-26T14:16:20: +====================================================+ | ||
| 52 | + 2017-08-26T14:16:20: Confidence level ..........: 68 % | ||
| 53 | + 2017-08-26T14:16:20: Log-likelihood difference .: 0.494473 | ||
| 54 | + 2017-08-26T14:16:20: Initial factor range ......: [1.03221907174349, 1.65479046234989] | ||
| 55 | + 2017-08-26T14:16:42: Lower parameter factor ....: 1.31121 | ||
| 56 | + 2017-08-26T14:16:42: Upper parameter factor ....: 1.37307 | ||
| 57 | + 2017-08-26T14:16:42: Error from curvature ......: 0.03112856953032 | ||
| 58 | + 2017-08-26T14:16:42: Error from profile ........: 0.0309309760713872 | ||
| 59 | + 2017-08-26T14:16:42: Negative profile error ....: 0.0322989307870749 | ||
| 60 | + 2017-08-26T14:16:42: Positive profile error ....: 0.0295630213556994 | ||
| 61 | + 2017-08-26T14:16:42: | ||
| 62 | + 2017-08-26T14:16:42: +==========================================================+ | ||
| 63 | + 2017-08-26T14:16:42: | Compute error for source "Vela" parameter "CutoffEnergy" | | ||
| 64 | + 2017-08-26T14:16:42: +==========================================================+ | ||
| 65 | + 2017-08-26T14:16:42: Confidence level ..........: 68 % | ||
| 66 | + 2017-08-26T14:16:42: Log-likelihood difference .: 0.494473 | ||
| 67 | + 2017-08-26T14:16:42: Initial factor range ......: [0.001, 2.8071605417966] | ||
| 68 | + 2017-08-26T14:17:02: Lower parameter factor ....: 0.813181 | ||
| 69 | + 2017-08-26T14:17:02: Upper parameter factor ....: 1.17404 | ||
| 70 | + 2017-08-26T14:17:02: Error from curvature ......: 181.871842544747 MeV | ||
| 71 | + 2017-08-26T14:17:02: Error from profile ........: 180.431484426618 MeV | ||
| 72 | + 2017-08-26T14:17:02: Negative profile error ....: 175.261332662553 MeV | ||
| 73 | + 2017-08-26T14:17:02: Positive profile error ....: 185.601636190684 MeV | ||
| 74 | + 2017-08-26T14:17:02: | ||
| 75 | + 2017-08-26T14:17:02: +====================================================+ | ||
| 76 | + 2017-08-26T14:17:02: | Compute error for source "Vela" parameter "Index2" | | ||
| 77 | + 2017-08-26T14:17:02: +====================================================+ | ||
| 78 | + 2017-08-26T14:17:02: Confidence level ..........: 68 % | ||
| 79 | + 2017-08-26T14:17:02: Log-likelihood difference .: 0.494473 | ||
| 80 | + 2017-08-26T14:17:02: Initial factor range ......: [0.307804018748382, 0.866425033775455] | ||
| 81 | + 2017-08-26T14:17:24: Lower parameter factor ....: 0.559156 | ||
| 82 | + 2017-08-26T14:17:24: Upper parameter factor ....: 0.615141 | ||
| 83 | + 2017-08-26T14:17:24: Error from curvature ......: 0.0279310507513537 | ||
| 84 | + 2017-08-26T14:17:24: Error from profile ........: 0.0279924226890397 | ||
| 85 | + 2017-08-26T14:17:24: Negative profile error ....: 0.027958327168103 | ||
| 86 | + 2017-08-26T14:17:24: Positive profile error ....: 0.0280265182099764 |
doc/source/users/tutorials/howto/fermi/howto_fermi_fitting.rst
0 → 100644
| 1 | +.. _howto_fermi_fitting: | ||
| 2 | + | ||
| 3 | +Fit a model to the data | ||
| 4 | +----------------------- | ||
| 5 | + | ||
| 6 | + .. admonition:: What you will learn | ||
| 7 | + | ||
| 8 | + You will learn how to use :ref:`ctlike` to fit a parametric model to | ||
| 9 | + Fermi-LAT data. | ||
| 10 | + | ||
| 11 | +Start with creating an | ||
| 12 | +:ref:`observation definition file <glossary_obsdef>` | ||
| 13 | +that defines the names of the counts map file, the exposure map file, the | ||
| 14 | +live time cube file and the name of the instrument response function that | ||
| 15 | +should be used for the analysis: | ||
| 16 | + | ||
| 17 | +.. code-block:: xml | ||
| 18 | + | ||
| 19 | + <?xml version="1.0" standalone="no"?> | ||
| 20 | + <observation_list title="observation library"> | ||
| 21 | + <observation name="Vela" id="000001" instrument="LAT"> | ||
| 22 | + <parameter name="CountsMap" file="srcmaps.fits"/> | ||
| 23 | + <parameter name="ExposureMap" file="expmap.fits"/> | ||
| 24 | + <parameter name="LiveTimeCube" file="ltcube.fits"/> | ||
| 25 | + <parameter name="IRF" value="P8R2_SOURCE_V6"/> | ||
| 26 | + </observation> | ||
| 27 | + </observation_list> | ||
| 28 | + | ||
| 29 | +This will be your input file to all tools. | ||
| 30 | +Then you also need a | ||
| 31 | +:ref:`model definition file <glossary_moddef>` | ||
| 32 | +that describes the source and background model that you want to fit. In the | ||
| 33 | +example below, a point source with a super exponentially cut-off power law is | ||
| 34 | +fit at the position of the Vela pulsar on top of a Galactic diffuse and an | ||
| 35 | +extragalactic isotropic source component. | ||
| 36 | + | ||
| 37 | +.. code-block:: xml | ||
| 38 | + | ||
| 39 | + <?xml version="1.0" standalone="no"?> | ||
| 40 | + <source_library title="source library"> | ||
| 41 | + <source type="PointSource" name="Vela"> | ||
| 42 | + <spectrum type="SuperExponentialCutoffPowerLaw"> | ||
| 43 | + <parameter name="Prefactor" scale="1e-9" value="1.0" min="1e-07" max="1000.0" free="1"/> | ||
| 44 | + <parameter name="Index1" scale="-1" value="2.0" min="0.0" max="+5.0" free="1"/> | ||
| 45 | + <parameter name="CutoffEnergy" scale="1e3" value="1.0" min="1e-3" max="1e+3" free="1"/> | ||
| 46 | + <parameter name="PivotEnergy" scale="1e3" value="1.0" min="0.01" max="1000.0" free="0"/> | ||
| 47 | + <parameter name="Index2" scale="1.0" value="0.5" min="0.1" max="5.0" free="1"/> | ||
| 48 | + </spectrum> | ||
| 49 | + <spatialModel type="PointSource"> | ||
| 50 | + <parameter name="RA" scale="1.0" value="128.84" min="-360" max="360" free="0"/> | ||
| 51 | + <parameter name="DEC" scale="1.0" value="-45.18" min="-90" max="90" free="0"/> | ||
| 52 | + </spatialModel> | ||
| 53 | + </source> | ||
| 54 | + <source type="DiffuseSource" name="Galactic_diffuse"> | ||
| 55 | + <spectrum type="Constant"> | ||
| 56 | + <parameter name="Normalization" scale="1.0" value="1.0" min="0.1" max="1000.0" free="1"/> | ||
| 57 | + </spectrum> | ||
| 58 | + <spatialModel type="DiffuseMapCube" file="gll_iem_v06.fits"> | ||
| 59 | + <parameter name="Normalization" scale="1.0" value="1.0" min="0.1" max="10.0" free="0"/> | ||
| 60 | + </spatialModel> | ||
| 61 | + </source> | ||
| 62 | + <source type="DiffuseSource" name="Extragalactic_diffuse"> | ||
| 63 | + <spectrum type="FileFunction" file="iso_P8R2_SOURCE_V6_v06.txt"> | ||
| 64 | + <parameter name="Normalization" scale="1.0" value="1.0" min="0.0" max="1000.0" free="0"/> | ||
| 65 | + </spectrum> | ||
| 66 | + <spatialModel type="DiffuseIsotropic"> | ||
| 67 | + <parameter name="Value" scale="1.0" value="1.0" min="0.0" max="10.0" free="0"/> | ||
| 68 | + </spatialModel> | ||
| 69 | + </source> | ||
| 70 | + </source_library> | ||
| 71 | +.. | ||
| 72 | + | ||
| 73 | + .. warning:: | ||
| 74 | + | ||
| 75 | + The names of the diffuse model components have to be identical to the | ||
| 76 | + names used when preparing the ``srcmaps.fits`` file using ``gtsrcmap``. | ||
| 77 | + | ||
| 78 | + **Positions of point sources can so far not be fitted for a Fermi-LAT | ||
| 79 | + analysis**, hence the corresponding parameters are fixed. | ||
| 80 | + | ||
| 81 | +Now you are ready to fit the model using the :ref:`ctlike` model tool. You do | ||
| 82 | +this as follows: | ||
| 83 | + | ||
| 84 | +.. code-block:: bash | ||
| 85 | + | ||
| 86 | + $ ctlike | ||
| 87 | + Input event list, counts cube or observation definition XML file [events.fits] obs.xml | ||
| 88 | + Input model definition XML file [$CTOOLS/share/models/crab.xml] models.xml | ||
| 89 | + Output model definition XML file [crab_results.xml] vela_results.xml | ||
| 90 | + | ||
| 91 | +:ref:`ctlike` creates on output the | ||
| 92 | +:ref:`model definition file <glossary_moddef>` | ||
| 93 | +``vela_results.xml`` where the parameter values were updated by their | ||
| 94 | +fitted values, and where the statistical uncertainties were added using the | ||
| 95 | +``error`` attribute. To investigate how the fit went you should inspect the | ||
| 96 | +log file ``ctlike.log`` that was also created by :ref:`ctlike`: | ||
| 97 | + | ||
| 98 | +.. code-block:: bash | ||
| 99 | + | ||
| 100 | + 2017-08-26T10:35:10: +=================================+ | ||
| 101 | + 2017-08-26T10:35:10: | Maximum likelihood optimisation | | ||
| 102 | + 2017-08-26T10:35:10: +=================================+ | ||
| 103 | + 2017-08-26T10:35:12: >Iteration 0: -logL=-177232.327, Lambda=1.0e-03 | ||
| 104 | + 2017-08-26T10:35:12: >Iteration 1: -logL=-198931.081, Lambda=1.0e-03, delta=21698.754, step=1.0e+00, max(|grad|)=-22713.401202 [CutoffEnergy:4] | ||
| 105 | + 2017-08-26T10:35:12: >Iteration 2: -logL=-200263.519, Lambda=1.0e-04, delta=1332.438, step=1.0e+00, max(|grad|)=-67648.133552 [CutoffEnergy:4] | ||
| 106 | + 2017-08-26T10:35:12: >Iteration 3: -logL=-212350.035, Lambda=1.0e-05, delta=12086.515, step=1.0e+00, max(|grad|)=23036.151920 [Index2:6] | ||
| 107 | + 2017-08-26T10:35:12: >Iteration 4: -logL=-213951.781, Lambda=1.0e-06, delta=1601.746, step=1.0e+00, max(|grad|)=-8297.648633 [CutoffEnergy:4] | ||
| 108 | + 2017-08-26T10:35:13: >Iteration 5: -logL=-215341.362, Lambda=1.0e-07, delta=1389.581, step=1.0e+00, max(|grad|)=2747.034517 [Index2:6] | ||
| 109 | + 2017-08-26T10:35:13: >Iteration 6: -logL=-215490.429, Lambda=1.0e-08, delta=149.067, step=1.0e+00, max(|grad|)=697.301361 [Index2:6] | ||
| 110 | + 2017-08-26T10:35:13: Iteration 7: -logL=-215490.429, Lambda=1.0e-09, delta=-14.065, step=1.0e+00, max(|grad|)=-1205.683279 [Index1:3] (stalled) | ||
| 111 | + 2017-08-26T10:35:13: Iteration 8: -logL=-215490.429, Lambda=1.0e-08, delta=-14.064, step=1.0e+00, max(|grad|)=-1205.659884 [Index1:3] (stalled) | ||
| 112 | + 2017-08-26T10:35:14: Iteration 9: -logL=-215490.429, Lambda=1.0e-07, delta=-14.055, step=1.0e+00, max(|grad|)=-1205.425967 [Index1:3] (stalled) | ||
| 113 | + 2017-08-26T10:35:14: Iteration 10: -logL=-215490.429, Lambda=1.0e-06, delta=-13.963, step=1.0e+00, max(|grad|)=-1203.090620 [Index1:3] (stalled) | ||
| 114 | + 2017-08-26T10:35:14: Iteration 11: -logL=-215490.429, Lambda=1.0e-05, delta=-13.066, step=1.0e+00, max(|grad|)=-1180.113526 [Index1:3] (stalled) | ||
| 115 | + 2017-08-26T10:35:14: Iteration 12: -logL=-215490.429, Lambda=1.0e-04, delta=-6.263, step=1.0e+00, max(|grad|)=-983.079153 [Index1:3] (stalled) | ||
| 116 | + 2017-08-26T10:35:14: >Iteration 13: -logL=-215496.367, Lambda=1.0e-03, delta=5.937, step=1.0e+00, max(|grad|)=-285.734284 [Index1:3] | ||
| 117 | + 2017-08-26T10:35:15: Iteration 14: -logL=-215496.367, Lambda=1.0e-04, delta=-8.812, step=1.0e+00, max(|grad|)=-731.894749 [Index1:3] (stalled) | ||
| 118 | + 2017-08-26T10:35:15: >Iteration 15: -logL=-215497.536, Lambda=1.0e-03, delta=1.169, step=1.0e+00, max(|grad|)=-153.668138 [Index1:3] | ||
| 119 | + 2017-08-26T10:35:15: Iteration 16: -logL=-215496.136, Lambda=1.0e-04, delta=-1.400, step=1.0e+00, max(|grad|)=-328.522942 [Index1:3] (stalled) | ||
| 120 | + 2017-08-26T10:35:15: >Iteration 17: -logL=-215498.376, Lambda=1.0e-03, delta=2.240, step=1.0e+00, max(|grad|)=3.257091 [Index2:6] | ||
| 121 | + 2017-08-26T10:35:16: >Iteration 18: -logL=-215498.383, Lambda=1.0e-04, delta=0.007, step=1.0e+00, max(|grad|)=-8.270351 [CutoffEnergy:4] | ||
| 122 | + 2017-08-26T10:35:16: >Iteration 19: -logL=-215498.384, Lambda=1.0e-05, delta=0.002, step=1.0e+00, max(|grad|)=0.637485 [Index2:6] | ||
| 123 | + 2017-08-26T10:35:16: | ||
| 124 | + 2017-08-26T10:35:16: +=========================================+ | ||
| 125 | + 2017-08-26T10:35:16: | Maximum likelihood optimisation results | | ||
| 126 | + 2017-08-26T10:35:16: +=========================================+ | ||
| 127 | + 2017-08-26T10:35:16: === GOptimizerLM === | ||
| 128 | + 2017-08-26T10:35:16: Optimized function value ..: -215498.384 | ||
| 129 | + 2017-08-26T10:35:16: Absolute precision ........: 0.005 | ||
| 130 | + 2017-08-26T10:35:16: Acceptable value decrease .: 2 | ||
| 131 | + 2017-08-26T10:35:16: Optimization status .......: converged | ||
| 132 | + 2017-08-26T10:35:16: Number of parameters ......: 14 | ||
| 133 | + 2017-08-26T10:35:16: Number of free parameters .: 5 | ||
| 134 | + 2017-08-26T10:35:16: Number of iterations ......: 19 | ||
| 135 | + 2017-08-26T10:35:16: Lambda ....................: 1e-06 | ||
| 136 | + 2017-08-26T10:35:16: Maximum log likelihood ....: 215498.384 | ||
| 137 | + 2017-08-26T10:35:16: Observed events (Nobs) ...: 202330.000 | ||
| 138 | + 2017-08-26T10:35:16: Predicted events (Npred) ..: 202318.082 (Nobs - Npred = 11.9178772509331) | ||
| 139 | + 2017-08-26T10:35:16: === GModels === | ||
| 140 | + 2017-08-26T10:35:16: Number of models ..........: 3 | ||
| 141 | + 2017-08-26T10:35:16: Number of parameters ......: 14 | ||
| 142 | + 2017-08-26T10:35:16: === GModelSky === | ||
| 143 | + 2017-08-26T10:35:16: Name ......................: Vela | ||
| 144 | + 2017-08-26T10:35:16: Instruments ...............: all | ||
| 145 | + 2017-08-26T10:35:16: Instrument scale factors ..: unity | ||
| 146 | + 2017-08-26T10:35:16: Observation identifiers ...: all | ||
| 147 | + 2017-08-26T10:35:16: Model type ................: PointSource | ||
| 148 | + 2017-08-26T10:35:16: Model components ..........: "PointSource" * "SuperExponentialCutoffPowerLaw" * "Constant" | ||
| 149 | + 2017-08-26T10:35:16: Number of parameters ......: 8 | ||
| 150 | + 2017-08-26T10:35:16: Number of spatial par's ...: 2 | ||
| 151 | + 2017-08-26T10:35:16: RA .......................: 128.84 [-360,360] deg (fixed,scale=1) | ||
| 152 | + 2017-08-26T10:35:16: DEC ......................: -45.18 [-90,90] deg (fixed,scale=1) | ||
| 153 | + 2017-08-26T10:35:16: Number of spectral par's ..: 5 | ||
| 154 | + 2017-08-26T10:35:16: Prefactor ................: 4.3553344038324e-09 +/- 4.75309654008435e-10 [1e-16,1e-06] ph/cm2/s/MeV (free,scale=1e-09,gradient) | ||
| 155 | + 2017-08-26T10:35:16: Index1 ...................: -1.3435116067011 +/- 0.0311270092486095 [-0,-5] (free,scale=-1,gradient) | ||
| 156 | + 2017-08-26T10:35:16: CutoffEnergy .............: 988.499237722443 +/- 181.86709257978 [1,1000000] MeV (free,scale=1000,gradient) | ||
| 157 | + 2017-08-26T10:35:16: PivotEnergy ..............: 1000 [10,1000000] MeV (fixed,scale=1000,gradient) | ||
| 158 | + 2017-08-26T10:35:16: Index2 ...................: 0.587129723482927 +/- 0.0279303486200403 [0.1,5] (free,scale=1,gradient) | ||
| 159 | + 2017-08-26T10:35:16: Number of temporal par's ..: 1 | ||
| 160 | + 2017-08-26T10:35:16: Normalization ............: 1 (relative value) (fixed,scale=1,gradient) | ||
| 161 | + 2017-08-26T10:35:16: === GModelSky === | ||
| 162 | + 2017-08-26T10:35:16: Name ......................: Galactic_diffuse | ||
| 163 | + 2017-08-26T10:35:16: Instruments ...............: all | ||
| 164 | + 2017-08-26T10:35:16: Instrument scale factors ..: unity | ||
| 165 | + 2017-08-26T10:35:16: Observation identifiers ...: all | ||
| 166 | + 2017-08-26T10:35:16: Model type ................: DiffuseSource | ||
| 167 | + 2017-08-26T10:35:16: Model components ..........: "DiffuseMapCube" * "Constant" * "Constant" | ||
| 168 | + 2017-08-26T10:35:16: Number of parameters ......: 3 | ||
| 169 | + 2017-08-26T10:35:16: Number of spatial par's ...: 1 | ||
| 170 | + 2017-08-26T10:35:16: Normalization ............: 1 [0.1,10] (fixed,scale=1,gradient) | ||
| 171 | + 2017-08-26T10:35:16: Number of spectral par's ..: 1 | ||
| 172 | + 2017-08-26T10:35:16: Normalization ............: 1.10915296009432 +/- 0.00503367301009883 [0.1,1000] (free,scale=1,gradient) | ||
| 173 | + 2017-08-26T10:35:16: Number of temporal par's ..: 1 | ||
| 174 | + 2017-08-26T10:35:16: Normalization ............: 1 (relative value) (fixed,scale=1,gradient) | ||
| 175 | + 2017-08-26T10:35:16: === GModelSky === | ||
| 176 | + 2017-08-26T10:35:16: Name ......................: Extragalactic_diffuse | ||
| 177 | + 2017-08-26T10:35:16: Instruments ...............: all | ||
| 178 | + 2017-08-26T10:35:16: Instrument scale factors ..: unity | ||
| 179 | + 2017-08-26T10:35:16: Observation identifiers ...: all | ||
| 180 | + 2017-08-26T10:35:16: Model type ................: DiffuseSource | ||
| 181 | + 2017-08-26T10:35:16: Model components ..........: "DiffuseIsotropic" * "FileFunction" * "Constant" | ||
| 182 | + 2017-08-26T10:35:16: Number of parameters ......: 3 | ||
| 183 | + 2017-08-26T10:35:16: Number of spatial par's ...: 1 | ||
| 184 | + 2017-08-26T10:35:16: Value ....................: 1 [0,10] (fixed,scale=1,gradient) | ||
| 185 | + 2017-08-26T10:35:16: Number of spectral par's ..: 1 | ||
| 186 | + 2017-08-26T10:35:16: Normalization ............: 1 [0,1000] (fixed,scale=1,gradient) | ||
| 187 | + 2017-08-26T10:35:16: Number of temporal par's ..: 1 | ||
| 188 | + 2017-08-26T10:35:16: Normalization ............: 1 (relative value) (fixed,scale=1,gradient) | ||
| 189 | + | ||
| 190 | + | ||
| 191 | +The fit converged after 19 iterations with spectral parameters that are | ||
| 192 | +reasonably close to those found in | ||
| 193 | +`Abdo et al. 2010, ApJ, 713, 154 <http://iopscience.iop.org/article/10.1088/0004-637X/713/1/154/pdf>`_ | ||
| 194 | +using the Fermi-LAT Science Tools. | ||
| 195 | + | ||
| 196 | + .. note:: | ||
| 197 | + | ||
| 198 | + The fit results can be compared to the corresponding output of gtlike | ||
| 199 | + when the tool is applied to the same test data. As you will see below, | ||
| 200 | + the fitted model parameters are basically identical. | ||
| 201 | + | ||
| 202 | + .. code-block:: bash | ||
| 203 | + | ||
| 204 | + Extragalactic_diffuse: | ||
| 205 | + Normalization: 1 | ||
| 206 | + Flux: 0.000149604 photons/cm^2/s | ||
| 207 | + | ||
| 208 | + Galactic_diffuse: | ||
| 209 | + Value: 1.11394 +/- 0.00508393 | ||
| 210 | + Flux: 0.00054415 +/- 2.48325e-06 photons/cm^2/s | ||
| 211 | + | ||
| 212 | + Vela: | ||
| 213 | + Prefactor: 4.3344 +/- 0.65258 | ||
| 214 | + Index1: 1.34634 +/- 0.0429336 | ||
| 215 | + Scale: 1 | ||
| 216 | + Cutoff: 1.00992 +/- 0.25512 | ||
| 217 | + Index2: 0.595018 +/- 0.0398585 | ||
| 218 | + TS value: 326648 | ||
| 219 | + Flux: 1.0758e-05 +/- 4.33949e-08 photons/cm^2/s | ||
| 220 | + | ||
| 221 | + WARNING: Fit may be bad in range [100, 149.23] (MeV) | ||
| 222 | + WARNING: Fit may be bad in range [182.299, 405.972] (MeV) | ||
| 223 | + WARNING: Fit may be bad in range [6690.96, 8173.66] (MeV) | ||
| 224 | + WARNING: Fit may be bad in range [14900.5, 18202.4] (MeV) | ||
| 225 | + WARNING: Fit may be bad in range [33182.8, 40536] (MeV) | ||
| 226 | + WARNING: Fit may be bad in range [49518.7, 60491.9] (MeV) | ||
| 227 | + | ||
| 228 | + Total number of observed counts: 202330 | ||
| 229 | + Total number of model events: 202327 | ||
| 230 | + | ||
| 231 | + -log(Likelihood): -215606.3555 | ||
| 232 | + | ||
| 233 | + Elapsed CPU time: 72.33 | ||
| 234 | + | ||
| 235 | + You may also compute the Test Statistic value using :ref:`ctlike` by | ||
| 236 | + adding the ``tscalc="1"`` attribute to the | ||
| 237 | + :ref:`model definition file <glossary_moddef>`: | ||
| 238 | + | ||
| 239 | + .. code-block:: xml | ||
| 240 | + | ||
| 241 | + <?xml version="1.0" standalone="no"?> | ||
| 242 | + <source_library title="source library"> | ||
| 243 | + <source type="PointSource" name="Vela" tscalc="1"> | ||
| 244 | + ... | ||
| 245 | + </source_library> | ||
| 246 | + | ||
| 247 | + This results in | ||
| 248 | + | ||
| 249 | + .. code-block:: bash | ||
| 250 | + | ||
| 251 | + 2017-08-26T13:05:12: === GModelSky === | ||
| 252 | + 2017-08-26T13:05:12: Name ......................: Vela | ||
| 253 | + 2017-08-26T13:05:12: Instruments ...............: all | ||
| 254 | + 2017-08-26T13:05:12: Test Statistic ............: 326326.556902542 | ||
| 255 | + | ||
| 256 | + which is also close to the value determined by gtlike. |
doc/source/users/tutorials/howto/fermi/howto_fermi_prepare.rst
0 → 100644
| 1 | +.. _howto_fermi_prepare: | ||
| 2 | + | ||
| 3 | +Prepare Fermi-LAT data | ||
| 4 | +---------------------- | ||
| 5 | + | ||
| 6 | + .. admonition:: What you will learn | ||
| 7 | + | ||
| 8 | + You will learn how to prepare Fermi-LAT data for an analysis with | ||
| 9 | + ctools. | ||
| 10 | + | ||
| 11 | + You will find more information about the Fermi-LAT software and data | ||
| 12 | + analysis at the | ||
| 13 | + `Fermi Science Support Center (FSSC) <https://fermi.gsfc.nasa.gov/ssc/>`_ | ||
| 14 | + web site. | ||
| 15 | + | ||
| 16 | + | ||
| 17 | +Prerequisits | ||
| 18 | +~~~~~~~~~~~~ | ||
| 19 | + | ||
| 20 | +The following sections assume that you have properly installed the Fermi-LAT | ||
| 21 | +Science Tools. The Fermi-LAT Science Tools can be downloaded from the | ||
| 22 | +`Fermi Science Support Center (FSSC) <https://fermi.gsfc.nasa.gov/ssc/>`_. | ||
| 23 | + | ||
| 24 | + | ||
| 25 | +Get data from the Fermi-LAT data server | ||
| 26 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| 27 | + | ||
| 28 | +Start with requesting the data you are interested in from the | ||
| 29 | +`Fermi-LAT Data server <https://fermi.gsfc.nasa.gov/cgi-bin/ssc/LAT/LATDataQuery.cgi>`_. | ||
| 30 | +As example the figure below shows a request for data around the Vela pulsar. | ||
| 31 | + | ||
| 32 | +.. figure:: howto_fermi_query.jpg | ||
| 33 | + :width: 600px | ||
| 34 | + :align: center | ||
| 35 | + | ||
| 36 | + *Fermi-LAT data server interface* | ||
| 37 | + | ||
| 38 | +After submitting the request you will get information of how to retrieve the | ||
| 39 | +data: | ||
| 40 | + | ||
| 41 | +.. figure:: howto_fermi_data.jpg | ||
| 42 | + :width: 600px | ||
| 43 | + :align: center | ||
| 44 | + | ||
| 45 | + *Fermi-LAT data retrieval information* | ||
| 46 | + | ||
| 47 | +Now you download the data using the ``wget`` tool. At the same time of | ||
| 48 | +downloading the data you should also download the input files for the diffuse | ||
| 49 | +galactic and extragalactic model components. In the current example the | ||
| 50 | +following files were downloaded: | ||
| 51 | + | ||
| 52 | +.. code-block:: bash | ||
| 53 | + | ||
| 54 | + $ wget http://fermi.gsfc.nasa.gov/FTP/fermi/data/lat/queries/L1708251631252315B1AD08_SC00.fits | ||
| 55 | + $ wget http://fermi.gsfc.nasa.gov/FTP/fermi/data/lat/queries/L1708251631252315B1AD08_PH00.fits | ||
| 56 | + $ wget http://fermi.gsfc.nasa.gov/FTP/fermi/data/lat/queries/L1708251631252315B1AD08_PH01.fits | ||
| 57 | + $ wget https://fermi.gsfc.nasa.gov/ssc/data/analysis/software/aux/gll_iem_v06.fits | ||
| 58 | + $ wget https://fermi.gsfc.nasa.gov/ssc/data/analysis/software/aux/iso_P8R2_SOURCE_V6_v06.txt | ||
| 59 | +.. | ||
| 60 | + | ||
| 61 | + .. warning:: | ||
| 62 | + | ||
| 63 | + In the current example data within a radius of only 10 degrees around the | ||
| 64 | + source of interest were selected. This was mainly for getting a small | ||
| 65 | + data set. The | ||
| 66 | + `Fermi Science Support Center (FSSC) <https://fermi.gsfc.nasa.gov/ssc/>`_ | ||
| 67 | + recommends to use larger regions for the Fermi-LAT data analysis. | ||
| 68 | + | ||
| 69 | + | ||
| 70 | +Data preparation | ||
| 71 | +~~~~~~~~~~~~~~~~ | ||
| 72 | + | ||
| 73 | +First you need to combine the event lists into a single file. At the same | ||
| 74 | +time you will select the region of interest for the analysis. You do this | ||
| 75 | +using the ``gtselect`` tool: | ||
| 76 | + | ||
| 77 | +.. code-block:: bash | ||
| 78 | + | ||
| 79 | + $ ls *_PH* > events.txt | ||
| 80 | + $ gtselect evclass=128 evtype=3 | ||
| 81 | + Input FT1 file[] @events.txt | ||
| 82 | + Output FT1 file[] events_fermi.fits | ||
| 83 | + RA for new search center (degrees) (0:360) [INDEF] 128.84 | ||
| 84 | + Dec for new search center (degrees) (-90:90) [INDEF] -45.18 | ||
| 85 | + radius of new search region (degrees) (0:180) [INDEF] 10.0 | ||
| 86 | + start time (MET in s) (0:) [INDEF] | ||
| 87 | + end time (MET in s) (0:) [INDEF] | ||
| 88 | + lower energy limit (MeV) (0:) [30] 100.0 | ||
| 89 | + upper energy limit (MeV) (0:) [300000] 300000.0 | ||
| 90 | + maximum zenith angle value (degrees) (0:180) [180] 90.0 | ||
| 91 | + | ||
| 92 | +Now you have to select from all events those which fall into periods where | ||
| 93 | +data quality is good, the telescope is configured for science, and the rocking | ||
| 94 | +angle is not too large. You do this using the ``gtmktime`` tool that defines | ||
| 95 | +the Good Time Intervals for your analysis: | ||
| 96 | + | ||
| 97 | +.. code-block:: bash | ||
| 98 | + | ||
| 99 | + $ gtmktime | ||
| 100 | + Spacecraft data file[] L1708251631252315B1AD08_SC00.fits | ||
| 101 | + Filter expression[DATA_QUAL>0 && LAT_CONFIG==1 && ABS(ROCK_ANGLE)<52] | ||
| 102 | + Apply ROI-based zenith angle cut[yes] no | ||
| 103 | + Event data file[] events_fermi.fits | ||
| 104 | + Output event file name[] events_fermi_gti.fits | ||
| 105 | + | ||
| 106 | +The events are now ready to be binned into a counts cube using the | ||
| 107 | +``gtbin`` tool: | ||
| 108 | + | ||
| 109 | +.. code-block:: bash | ||
| 110 | + | ||
| 111 | + $ gtbin | ||
| 112 | + This is gtbin version ScienceTools-10-01-01 | ||
| 113 | + Type of output file (CCUBE|CMAP|LC|PHA1|PHA2|HEALPIX) [PHA2] CCUBE | ||
| 114 | + Event data file name[] events_fermi_gti.fits | ||
| 115 | + Output file name[] cntmap.fits | ||
| 116 | + Spacecraft data file name[NONE] L1708251631252315B1AD08_SC00.fits | ||
| 117 | + Size of the X axis in pixels[] 60 | ||
| 118 | + Size of the Y axis in pixels[] 60 | ||
| 119 | + Image scale (in degrees/pixel)[] 0.2 | ||
| 120 | + Coordinate system (CEL - celestial, GAL -galactic) (CEL|GAL) [CEL] | ||
| 121 | + First coordinate of image center in degrees (RA or galactic l)[] 128.84 | ||
| 122 | + Second coordinate of image center in degrees (DEC or galactic b)[] -45.18 | ||
| 123 | + Rotation angle of image axis, in degrees[0.] | ||
| 124 | + Projection method e.g. AIT|ARC|CAR|GLS|MER|NCP|SIN|STG|TAN:[AIT] TAN | ||
| 125 | + Algorithm for defining energy bins (FILE|LIN|LOG) [LOG] | ||
| 126 | + Start value for first energy bin in MeV[30] 100.0 | ||
| 127 | + Stop value for last energy bin in MeV[200000] 300000.0 | ||
| 128 | + Number of logarithmically uniform energy bins[] 40 | ||
| 129 | + | ||
| 130 | +As next step you need to compute a livetime cube which is a computational | ||
| 131 | +intensive task. You do this using the ``gtltcube`` tool: | ||
| 132 | + | ||
| 133 | +.. code-block:: bash | ||
| 134 | + | ||
| 135 | + $ gtltcube zmax=90 | ||
| 136 | + Event data file[] events_fermi_gti.fits | ||
| 137 | + Spacecraft data file[] L1708251631252315B1AD08_SC00.fits | ||
| 138 | + Output file[expCube.fits] ltcube.fits | ||
| 139 | + Step size in cos(theta) (0.:1.) [0.025] | ||
| 140 | + Pixel size (degrees)[1] | ||
| 141 | + Working on file L1708251631252315B1AD08_SC00.fits | ||
| 142 | + .....................! | ||
| 143 | + | ||
| 144 | +The little dots indicate the progress while the tool is computing. Once | ||
| 145 | +finished you need to compute the binned exposure map using the ``gtexpcube2`` | ||
| 146 | +tool: | ||
| 147 | + | ||
| 148 | +.. code-block:: bash | ||
| 149 | + | ||
| 150 | + $ gtexpcube2 | ||
| 151 | + Livetime cube file[] ltcube.fits | ||
| 152 | + Counts map file[] none | ||
| 153 | + Output file name[] expmap.fits | ||
| 154 | + Response functions to use[CALDB] P8R2_SOURCE_V6 | ||
| 155 | + Size of the X axis in pixels[INDEF] 200 | ||
| 156 | + Size of the Y axis in pixels[INDEF] 200 | ||
| 157 | + Image scale (in degrees/pixel)[INDEF] 0.2 | ||
| 158 | + Coordinate system (CEL - celestial, GAL -galactic) (CEL|GAL) [GAL] CEL | ||
| 159 | + First coordinate of image center in degrees (RA or galactic l)[INDEF] 128.84 | ||
| 160 | + Second coordinate of image center in degrees (DEC or galactic b)[INDEF] -45.18 | ||
| 161 | + Rotation angle of image axis, in degrees[0] | ||
| 162 | + Projection method e.g. AIT|ARC|CAR|GLS|MER|NCP|SIN|STG|TAN[CAR] TAN | ||
| 163 | + Start energy (MeV) of first bin[INDEF] 100.0 | ||
| 164 | + Stop energy (MeV) of last bin[INDEF] 300000.0 | ||
| 165 | + Number of logarithmically-spaced energy bins[INDEF] 40 | ||
| 166 | + Computing binned exposure map....................! | ||
| 167 | + | ||
| 168 | + | ||
| 169 | +Generate source maps | ||
| 170 | +~~~~~~~~~~~~~~~~~~~~ | ||
| 171 | + | ||
| 172 | +Now you are ready to produce source maps for all diffuse model components. | ||
| 173 | +Start with putting the diffuse model components into a | ||
| 174 | +:ref:`model definition XML file <glossary_moddef>`: | ||
| 175 | + | ||
| 176 | +.. code-block:: xml | ||
| 177 | + | ||
| 178 | + <?xml version="1.0" standalone="no"?> | ||
| 179 | + <source_library title="source library"> | ||
| 180 | + <source type="DiffuseSource" name="Galactic_diffuse" instrument="LAT"> | ||
| 181 | + <spectrum type="ConstantValue"> | ||
| 182 | + <parameter name="Value" scale="1.0" value="1.0" min="0.1" max="1000.0" free="1"/> | ||
| 183 | + </spectrum> | ||
| 184 | + <spatialModel type="MapCubeFunction" file="gll_iem_v06.fits"> | ||
| 185 | + <parameter name="Normalization" scale="1.0" value="1.0" min="0.1" max="10.0" free="0"/> | ||
| 186 | + </spatialModel> | ||
| 187 | + </source> | ||
| 188 | + <source type="DiffuseSource" name="Extragalactic_diffuse" instrument="LAT"> | ||
| 189 | + <spectrum type="FileFunction" file="iso_P8R2_SOURCE_V6_v06.txt"> | ||
| 190 | + <parameter name="Normalization" scale="1.0" value="1.0" min="0.0" max="1000.0" free="1"/> | ||
| 191 | + </spectrum> | ||
| 192 | + <spatialModel type="ConstantValue"> | ||
| 193 | + <parameter name="Value" scale="1.0" value="1.0" min="0.0" max="10.0" free="0"/> | ||
| 194 | + </spatialModel> | ||
| 195 | + </source> | ||
| 196 | + </source_library> | ||
| 197 | +.. | ||
| 198 | + | ||
| 199 | + .. warning:: | ||
| 200 | + | ||
| 201 | + While ctools also implements the syntax used for Fermi-LAT Science Tools | ||
| 202 | + :ref:`model definition files <glossary_moddef>`, | ||
| 203 | + the Fermi-LAT Science Tools naming conventions are not very homogenous, | ||
| 204 | + hence we usually advocate to use the more coherent ctools syntax. For the | ||
| 205 | + Fermi-LAT Science Tools you have to use however the Fermi-LAT syntax. | ||
| 206 | + | ||
| 207 | +Now you can generate the source maps using ``gtsrcmaps``: | ||
| 208 | + | ||
| 209 | +.. code-block:: bash | ||
| 210 | + | ||
| 211 | + $ gtsrcmaps ptsrc=no | ||
| 212 | + Exposure hypercube file[] ltcube.fits | ||
| 213 | + Counts map file[] cntmap.fits | ||
| 214 | + Source model file[] diffuse.xml | ||
| 215 | + Binned exposure map[none] expmap.fits | ||
| 216 | + Source maps output file[] srcmaps.fits | ||
| 217 | + Response functions[CALDB] P8R2_SOURCE_V6 | ||
| 218 | + Generating SourceMap for Extragalactic_diffuse....................! | ||
| 219 | + Generating SourceMap for Galactic_diffuse....................! | ||
| 220 | + | ||
| 221 | +And you are done with the preparation of the Fermi-LAT data. You now have | ||
| 222 | +the following files in your working directory: | ||
| 223 | + | ||
| 224 | +* ``srcmaps.fits`` - Counts cube including source maps | ||
| 225 | +* ``ltcube.fits`` - Livetime cube | ||
| 226 | +* ``expmap.fits`` - Exposure map |
doc/source/users/tutorials/howto/fermi/howto_fermi_query.jpg
0 → 100644
255 KB
doc/source/users/tutorials/howto/fermi/howto_fermi_spectrum.png
0 → 100644
26.5 KB
doc/source/users/tutorials/howto/fermi/howto_fermi_spectrum.rst
0 → 100644
| 1 | +.. _howto_fermi_spectrum: | ||
| 2 | + | ||
| 3 | +Generate a spectral energy distribution for a source | ||
| 4 | +---------------------------------------------------- | ||
| 5 | + | ||
| 6 | + .. admonition:: What you will learn | ||
| 7 | + | ||
| 8 | + You will learn how to use :ref:`ctlike` to derive the spectral energy | ||
| 9 | + density of a source from Fermi-LAT data. | ||
| 10 | + | ||
| 11 | +So far the :ref:`csspec` script does not work for Fermi-LAT data, but you | ||
| 12 | +will learn here a method that you can use to derive the spectrum of any | ||
| 13 | +source using Fermi-LAT data. For this you first need a little Python code | ||
| 14 | +to transform the spectral component of the Vela source in the | ||
| 15 | +:ref:`model definition file <glossary_moddef>` | ||
| 16 | +from a super exponentially cut-off power law into a node function. | ||
| 17 | +You do this as follows: | ||
| 18 | + | ||
| 19 | +.. code-block:: python | ||
| 20 | + | ||
| 21 | + >>> import gammalib | ||
| 22 | + >>> models = gammalib.GModels('vela_results.xml') | ||
| 23 | + >>> energies = gammalib.GEnergies(10, gammalib.GEnergy(100.0, 'MeV'), gammalib.GEnergy(100.0, 'GeV')) | ||
| 24 | + >>> nodes = gammalib.GModelSpectralNodes() | ||
| 25 | + >>> for energy in energies: | ||
| 26 | + >>> nodes.append(energy, models['Vela'].spectral().eval(energy)) | ||
| 27 | + >>> for par in nodes: | ||
| 28 | + >>> if 'Energy' in par.name(): | ||
| 29 | + >>> par.fix() | ||
| 30 | + >>> if 'Intensity' in par.name(): | ||
| 31 | + >>> par.min(1.0e-30) | ||
| 32 | + >>> models['Vela'].spectral(nodes) | ||
| 33 | + >>> models.save('model_nodes.xml') | ||
| 34 | + | ||
| 35 | +This will create a | ||
| 36 | +:ref:`model definition file <glossary_moddef>` | ||
| 37 | +with the following structure: | ||
| 38 | + | ||
| 39 | +.. code-block:: xml | ||
| 40 | + | ||
| 41 | + <?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
| 42 | + <source_library title="source library"> | ||
| 43 | + <source name="Vela" type="PointSource"> | ||
| 44 | + <spectrum type="NodeFunction"> | ||
| 45 | + <node> | ||
| 46 | + <parameter name="Energy" value="100" scale="1" free="0" /> | ||
| 47 | + <parameter name="Intensity" value="7.40280399439422e-08" error="0" scale="1" min="1e-30" free="1" /> | ||
| 48 | + </node> | ||
| 49 | + <node> | ||
| 50 | + <parameter name="Energy" value="215.443469003188" scale="1" free="0" /> | ||
| 51 | + <parameter name="Intensity" value="2.27587615163047e-08" error="0" scale="1" min="1e-30" free="1" /> | ||
| 52 | + </node> | ||
| 53 | + ... | ||
| 54 | + </source_library> | ||
| 55 | + | ||
| 56 | +Instead of the super exponentially cut-off power law the model now contains | ||
| 57 | +a node function with ten intensity nodes between 100 MeV and 100 GeV, and the | ||
| 58 | +:ref:`ctlike` tool will now adjust the intensities of each of the nodes which | ||
| 59 | +will result in a spectrum. To do this type now: | ||
| 60 | + | ||
| 61 | +.. code-block:: bash | ||
| 62 | + | ||
| 63 | + $ ctlike debug=yes | ||
| 64 | + Input event list, counts cube or observation definition XML file [obs.xml] | ||
| 65 | + Input model definition XML file [models.xml] model_nodes.xml | ||
| 66 | + Output model definition XML file [vela_results.xml] vela_nodes_results.xml | ||
| 67 | + | ||
| 68 | +This will produce the | ||
| 69 | +:ref:`model definition file <glossary_moddef>` | ||
| 70 | +``vela_nodes_results.xml`` with the intensities of the fitted source at | ||
| 71 | +each energy. The results are displayed graphically below. | ||
| 72 | + | ||
| 73 | +.. figure:: howto_fermi_spectrum.png | ||
| 74 | + :width: 600px | ||
| 75 | + :align: center | ||
| 76 | + | ||
| 77 | + *Spectrum of the Vela pulsar derived using a node function* | ||
| 78 | +.. | ||
| 79 | + | ||
| 80 | + .. note:: | ||
| 81 | + | ||
| 82 | + The ``NodeFunction`` spectral models implements a piece-wise power law | ||
| 83 | + that is defined by the intensity values at each node. |
doc/source/users/tutorials/howto/fermi/howto_fermi_ulimit.rst
0 → 100644
| 1 | +.. _howto_fermi_ulimit: | ||
| 2 | + | ||
| 3 | +Derive upper flux limits for a source | ||
| 4 | +------------------------------------- | ||
| 5 | + | ||
| 6 | + .. admonition:: What you will learn | ||
| 7 | + | ||
| 8 | + You will learn how to use :ref:`ctulimit` to determine upper flux limits | ||
| 9 | + from Fermi-LAT data using a likelihood profile method. | ||
| 10 | + | ||
| 11 | +Suppose there is another potential source in the field of view but you cannot | ||
| 12 | +see this source in a counts map, hence you want to derive an upper flux limit | ||
| 13 | +for the source. To do this you first have to add an additional source to the | ||
| 14 | +:ref:`model definition file <glossary_moddef>`. An example for a source at | ||
| 15 | +:math:`\alpha=122^\circ` and :math:`\delta=-42^\circ` is shown below: | ||
| 16 | + | ||
| 17 | +.. code-block:: xml | ||
| 18 | + | ||
| 19 | + <?xml version="1.0" standalone="no"?> | ||
| 20 | + <source_library title="source library"> | ||
| 21 | + <source type="PointSource" name="Test"> | ||
| 22 | + <spectrum type="PowerLaw"> | ||
| 23 | + <parameter name="PhotonFlux" scale="1e-12" value="1.0" min="1e-07" max="1000.0" free="1"/> | ||
| 24 | + <parameter name="Index" scale="1.0" value="-2.0" min="-5.0" max="+5.0" free="0"/> | ||
| 25 | + <parameter name="LowerLimit" scale="1.0" value="100.0" min="10.0" max="1000000.0" free="0"/> | ||
| 26 | + <parameter name="UpperLimit" scale="1.0" value="100000.0" min="10.0" max="1000000.0" free="0"/> | ||
| 27 | + </spectrum> | ||
| 28 | + <spatialModel type="PointSource"> | ||
| 29 | + <parameter name="RA" scale="1.0" value="122.00" min="-360" max="360" free="0"/> | ||
| 30 | + <parameter name="DEC" scale="1.0" value="-42.00" min="-90" max="90" free="0"/> | ||
| 31 | + </spatialModel> | ||
| 32 | + </source> | ||
| 33 | + <source type="PointSource" name="Vela"> | ||
| 34 | + ... | ||
| 35 | + </source_library> | ||
| 36 | + | ||
| 37 | +Now you can run the :ref:`ctulimit` tool. Since the tool is normally tuned | ||
| 38 | +for Cherenkov Telescope data analysis, energies are by default given in TeV. | ||
| 39 | +To specify a reference energy of the differential flux limit of 1 GeV you | ||
| 40 | +need to provide the hidden parameter ``eref=0.001``. You can also set the | ||
| 41 | +flux interval for the intergal flux computation to 100 MeV - 100 GeV by | ||
| 42 | +specifying ``emin=0.0001 emax=0.1`` (all values are given in TeV): | ||
| 43 | + | ||
| 44 | +.. code-block:: bash | ||
| 45 | + | ||
| 46 | + $ ctulimit eref=0.001 emin=0.0001 emax=0.1 | ||
| 47 | + Input event list, counts cube or observation definition XML file [obs.xml] | ||
| 48 | + Source of interest [Test] | ||
| 49 | + Input model definition XML file [model_lat_ulimit.xml] | ||
| 50 | + | ||
| 51 | +The results of the upper limit computation can then be extracted from the | ||
| 52 | +``ctulimit.log`` file that is created by :ref:`ctulimit`: | ||
| 53 | + | ||
| 54 | +.. code-block:: bash | ||
| 55 | + | ||
| 56 | + 2017-08-26T14:37:48: +=====================+ | ||
| 57 | + 2017-08-26T14:37:48: | Upper limit results | | ||
| 58 | + 2017-08-26T14:37:48: +=====================+ | ||
| 59 | + 2017-08-26T14:37:48: Differential flux limit ...: 1.00100099727198e-13 ph/cm2/s/MeV at 0.001 TeV | ||
| 60 | + 2017-08-26T14:37:48: Integral flux limit .......: 9.9999999627471e-10 ph/cm2/s within [0.0001-0.1] TeV | ||
| 61 | + 2017-08-26T14:37:48: Energy flux limit .........: 1.10785216561628e-12 erg/cm2/s within [0.0001-0.1] TeV |
doc/source/users/tutorials/howto/fermi/index.rst
0 → 100644
| 1 | +.. _howto_fermi: | ||
| 2 | + | ||
| 3 | +Analysing Fermi-LAT data | ||
| 4 | +------------------------ | ||
| 5 | + | ||
| 6 | + .. admonition:: What you will learn | ||
| 7 | + | ||
| 8 | + You will learn how to analyse data from the LAT telescope about NASA's | ||
| 9 | + `Fermi <https://fermi.gsfc.nasa.gov/ssc/>`_ satellite with ctools. | ||
| 10 | + | ||
| 11 | +You can use ctools to analyse data from the LAT telescope about NASA's | ||
| 12 | +`Fermi <https://fermi.gsfc.nasa.gov/ssc/>`_ satellite. | ||
| 13 | +To do this you need to be familar with the Fermi-LAT Science Tools that you | ||
| 14 | +will use to prepare the Fermi-LAT data for the analysis. You can download the | ||
| 15 | +Fermi-LAT Science Tools from the | ||
| 16 | +`Fermi Science Support Center (FSSC) <https://fermi.gsfc.nasa.gov/ssc/>`_ | ||
| 17 | +which provides also more detailed information about how to prepare the data. | ||
| 18 | +What you need for a given observation are the following files: | ||
| 19 | + | ||
| 20 | +* ``srcmaps.fits`` - source maps file that include a counts cube and maps of the | ||
| 21 | + diffuse model components | ||
| 22 | +* ``ltcube.fits`` - livetime cube file that corresponds to the Good Time Intervals | ||
| 23 | + of the data | ||
| 24 | +* ``expmap.fits`` - exposure map file | ||
| 25 | + | ||
| 26 | +To demonstrate how the Fermi-LAT analysis works with ctools, here is a short | ||
| 27 | +tutorial that is based on a simple analysis of the Vela pulsar. | ||
| 28 | + | ||
| 29 | +.. toctree:: | ||
| 30 | + :maxdepth: 1 | ||
| 31 | + | ||
| 32 | + howto_fermi_prepare | ||
| 33 | + howto_fermi_fitting | ||
| 34 | + howto_fermi_butterfly | ||
| 35 | + howto_fermi_spectrum | ||
| 36 | + howto_fermi_ulimit | ||
| 37 | + howto_fermi_errors |
doc/source/users/tutorials/iact_analysis/analysis.rst renamed to doc/source/users/tutorials/howto/iact/analysis.rst
doc/source/users/tutorials/iact_analysis/copy.rst renamed to doc/source/users/tutorials/howto/iact/copy.rst
doc/source/users/tutorials/iact_analysis/high_level.rst renamed to doc/source/users/tutorials/howto/iact/high_level.rst
doc/source/users/tutorials/iact_analysis/index.rst renamed to doc/source/users/tutorials/howto/iact/index.rst
doc/source/users/tutorials/iact_analysis/simulation.rst renamed to doc/source/users/tutorials/howto/iact/simulation.rst
doc/source/users/tutorials/iact_analysis/tips.rst renamed to doc/source/users/tutorials/howto/iact/tips.rst
doc/source/users/tutorials/howto/index.rst
| @@ -21,4 +21,6 @@ These examples can be easily adapted to any data you have at your disposal. | @@ -21,4 +21,6 @@ These examples can be easily adapted to any data you have at your disposal. | ||
| 21 | howto_lightcurve | 21 | howto_lightcurve |
| 22 | howto_phasecurve | 22 | howto_phasecurve |
| 23 | howto_exclude | 23 | howto_exclude |
| 24 | - howto_vo | ||
| 25 | \ No newline at end of file | 24 | \ No newline at end of file |
| 25 | + howto_vo | ||
| 26 | + How to analyse Fermi-LAT data with ctools? <fermi/index> | ||
| 27 | + How to analyse H.E.S.S. data with ctools? <iact/index> | ||
| 26 | \ No newline at end of file | 28 | \ No newline at end of file |
doc/source/users/tutorials/index.rst