Commit 39991280aa6aed4432dfc232d9720a49e23b032b
1 parent
070a0973
On/Off analysis in quickstart and reshuffling of material with 1DC tutorial
Showing
4 changed files
with
304 additions
and
133 deletions
doc/source/users/tutorials/1dc/classical_analysis.rst
| ... | ... | @@ -56,7 +56,7 @@ region. You can do this using the :ref:`ctskymap` tool. |
| 56 | 56 | Output skymap file [skymap.fits] |
| 57 | 57 | |
| 58 | 58 | In the spirit of the classical analysis we have chosen to derive the background |
| 59 | -using the RING method (e.g., Berge et al. 2007 A&A 466 1219B), in which for each | |
| 59 | +using the RING method, in which for each | |
| 60 | 60 | point in the map (trial source position) the background is derived from a ring |
| 61 | 61 | centered at the same position. The RING method is fast and robust against linear |
| 62 | 62 | gradients of the background rates, but requires a model (from the :ref:`instrument response functions <glossary_irf>` |
| ... | ... | @@ -133,22 +133,7 @@ Below you can see the new significance map with the source/exclusion region. |
| 133 | 133 | |
| 134 | 134 | For a classical spectral analysis we need to derive count spectra for the source |
| 135 | 135 | region and for background regions. This is accomplished by the :ref:`csphagen` |
| 136 | -script. This script saves the source (On) and background (Off) count spectra | |
| 137 | -in `OGIP format <https://heasarc.gsfc.nasa.gov/docs/heasarc/ofwg/docs/spectra/ogip_92_007/node5.html>`_, | |
| 138 | -along with the relevant information from the :ref:`instrument response functions <glossary_irf>` | |
| 139 | -refashioned according to this format conventions. | |
| 140 | - | |
| 141 | -:ref:`csphagen` calculates the background counts using the REFLECTED algorithm | |
| 142 | -(e.g., Berge et al. 2007 A&A 466 1219B), in which, for each individual | |
| 143 | -observation the background regions have the same shape as the source region, and | |
| 144 | -are rotated around the center of the camera keeping the same offset. As many | |
| 145 | -reflected regions as possible are used, excluding the area of the camera near | |
| 146 | -the source position. Since the background rates are expected to be approximately | |
| 147 | -radially symmetric in camera coordinates, this method minimizes the impact of | |
| 148 | -the background rate modeling from Monte Carlo. An optional exclusion map (in | |
| 149 | -FITS WCS format) can be provided as input through the ``inexclusion`` hidden | |
| 150 | -parameter if other regions of significant gamma-ray emission ought to be | |
| 151 | -excluded from the background computation. | |
| 136 | +script. | |
| 152 | 137 | |
| 153 | 138 | .. code-block:: bash |
| 154 | 139 | |
| ... | ... | @@ -183,33 +168,9 @@ looks like. |
| 183 | 168 | </observation> |
| 184 | 169 | </observation_list> |
| 185 | 170 | |
| 186 | -The observation entails four FITS files. ``onoff_stacked_pha_on.fits`` and | |
| 187 | -``onoff_stacked_pha_off.fits`` contain the On and Off spectra, respectively. | |
| 188 | -These are stored in the SPECTRUM extension of the FITS file, along with ancillary | |
| 189 | -information, notably the scaling factor to be applied to the background spectrum, | |
| 190 | -BACKSCAL. The third extension, EBOUNDS, contains the boundaries of the energy | |
| 191 | -bins, as defined by the binning parameters in input to csphagen. The file | |
| 192 | -``onoff_stacked_arf.fits`` contains the spectral response of the instrument | |
| 193 | -extracted fromt the :ref:`instrument response functions <glossary_irf>`, | |
| 194 | -including effective area for gamma-ray detection and background rates, in the | |
| 195 | -SPECRESP extension. The file ``onoff_stacked_rmf.fits`` contains the remaining | |
| 196 | -part of the instrument response, i.e., an energy redistribution matrix (MATRIX), | |
| 197 | -as well as another instance of the EBOUNDS table. Note that we are performing a | |
| 198 | -1D analysis: the effect of the PSF is already folded into the effective area | |
| 199 | -computation. | |
| 200 | - | |
| 201 | -.. note:: | |
| 202 | - | |
| 203 | - The parameters specified control the energy binning of the count spectra in | |
| 204 | - *reconstructed* energy. For the computation of the instrument response we | |
| 205 | - need a fine binning in *true* energy, which is controlled by the hidden | |
| 206 | - parameters ``etruemin``, ``etruemax``, and ``etruebins``. | |
| 207 | - | |
| 208 | 171 | .. note:: |
| 209 | 172 | |
| 210 | - The first part of the FITS files names (and a full path to the desired | |
| 211 | - location) can be set using the hidden ``prefix`` parameter of | |
| 212 | - :ref:`csphagen`. If you decide not to stack multiple observations the string | |
| 173 | + If you decide not to stack multiple observations the string | |
| 213 | 174 | ``stacked`` with be replaced in the file names by the observation id for |
| 214 | 175 | each of the original observations. |
| 215 | 176 | |
| ... | ... | @@ -226,12 +187,6 @@ the On and Off regions for a few observations (extracted using the |
| 226 | 187 | |
| 227 | 188 | *Sky map of the event counts in a larger region around Cas A (not background subtracted). The green crosses show the pointing directions, the magenta circles the Off regions, and the white circle the On region.* |
| 228 | 189 | |
| 229 | -.. note:: | |
| 230 | - | |
| 231 | - If you wish to limit the number of observations considered to those pointed | |
| 232 | - closer to the source, you can do this either at the observation selection | |
| 233 | - level (see :ref:`csobsselect`), or directly in :ref:`csphagen` via the | |
| 234 | - hidden ``maxoffset`` parameter. | |
| 235 | 190 | |
| 236 | 191 | Next we need a model to be fit to the observations. It must contain a model for the |
| 237 | 192 | source, and, optionally, a model for the background. Here is what such a |
| ... | ... | @@ -300,32 +255,9 @@ The output file ``CasA_results.xml`` contains the best fit parameter values. |
| 300 | 255 | Check the :ref:`ctlike` log file (by default ``ctlike.log``) to learn |
| 301 | 256 | about the fit convergence and investigate any issues. |
| 302 | 257 | |
| 303 | -:ref:`ctlike` has a hidden parameter called ``statistic`` that sets the | |
| 304 | -statistic used for the fit. | |
| 305 | - | |
| 306 | -- The DEFAULT for OnOff osbervations is CSTAT, i.e., Poisson signal and Poisson | |
| 307 | - background. A spectral model for the signal and a spectral model for the | |
| 308 | - background are jointly fit to the On and Off spectra. | |
| 309 | -- WSTAT is a special case of CSTAT, Poisson signal with Poisson background, in | |
| 310 | - which you do not need to have a spectral model for the background and | |
| 311 | - free parameters associated with it. The number of background counts in each | |
| 312 | - energy bin is treated as a nuisance parameter, derived from the On and Off | |
| 313 | - counts by profiling the likelihood function. In this case the only assumption | |
| 314 | - is that the background rate spectrum is the same in the On and Off regions. | |
| 315 | - | |
| 316 | -.. warning:: | |
| 317 | - Beware that the profiling may yield unphysical results (negative background | |
| 318 | - counts) if the number of events in the Off spectra are zero. In this case a | |
| 319 | - null number of expected background events must be enforced, | |
| 320 | - which can result in a bias on the source's parameters. You can address this | |
| 321 | - issue by stacking multiple observations, using a coarser energy binning, or | |
| 322 | - using CSTAT instead (if you have a spectral model for the background that is | |
| 323 | - good enough). See the `XSPEC manual Appendix B <https://heasarc.gsfc.nasa.gov/xanadu/xspec/manual/XSappendixStatistics.html>`_ | |
| 324 | - for more information. | |
| 325 | - | |
| 326 | -- You can also use CHI2, a classical chi square, i.e., a Gaussian signal and | |
| 327 | - Gaussian background. As for CSTAT, a spectral model for the signal and a | |
| 328 | - spectral model for the background are jointly fit to the On and Off spectra. | |
| 258 | +The hidden parameter ``statistic`` in :ref:`ctlike` can be used to | |
| 259 | +set the fit statistic and in particular how the background is treated | |
| 260 | +in the fit. | |
| 329 | 261 | |
| 330 | 262 | The :ref:`ctbutterfly` tool and :ref:`csspec` script can now be used to extract |
| 331 | 263 | the best-fit source spectrum. |
| ... | ... | @@ -360,4 +292,4 @@ matplotlib). |
| 360 | 292 | :width: 400px |
| 361 | 293 | :align: center |
| 362 | 294 | |
| 363 | - *Spectral Energy Distribution of the source: the best-fit function over the whole energy range and its uncertainty range, along with the spectral points in energy bins.* | |
| 364 | 295 | \ No newline at end of file |
| 296 | + *Spectral Energy Distribution of the source: the best-fit function over the whole energy range and its uncertainty range, along with the spectral points in energy bins.* | ... | ... |
doc/source/users/tutorials/quickstart/onoff.png
0 โ 100644
40 KB
doc/source/users/tutorials/quickstart/onoff.rst
| ... | ... | @@ -6,7 +6,7 @@ Doing an On/Off analysis |
| 6 | 6 | .. admonition:: What you will learn |
| 7 | 7 | |
| 8 | 8 | You will learn how to **adjust a parametrised spectral model to |
| 9 | - the events deriving the bacground from the data**. | |
| 9 | + the events deriving the background from the data**. | |
| 10 | 10 | |
| 11 | 11 | Gamma-ray events are rare compared to the background events, |
| 12 | 12 | hence small imperfections of the background model can have a |
| ... | ... | @@ -17,3 +17,242 @@ Doing an On/Off analysis |
| 17 | 17 | (background) regions. An On/Off analysis is recommended if you |
| 18 | 18 | want to assure minimal dependency on the Monte Carlo background model. |
| 19 | 19 | |
| 20 | +Last, we consider the classical technique for IACT spectral analysis, | |
| 21 | +in which 1D spectra for On and Off regions are used jointly to | |
| 22 | +determine the source parameters. | |
| 23 | + | |
| 24 | +The script :ref:`csphagen` is used to derive a set of On/Off | |
| 25 | +observations from the event lists. This script saves the source (On) and background (Off) count spectra | |
| 26 | +in `OGIP format <https://heasarc.gsfc.nasa.gov/docs/heasarc/ofwg/docs/spectra/ogip_92_007/node5.html>`_, | |
| 27 | +along with the relevant information from the :ref:`instrument response functions <glossary_irf>` | |
| 28 | +refashioned according to this format conventions. | |
| 29 | + | |
| 30 | +:ref:`csphagen` calculates the background counts using the REFLECTED algorithm, in which, for each individual | |
| 31 | +observation the background regions have the same shape as the source region, and | |
| 32 | +are rotated around the center of the camera keeping the same offset. As many | |
| 33 | +reflected regions as possible are used, excluding the area of the camera near | |
| 34 | +the source position. Since the background rates are expected to be approximately | |
| 35 | +radially symmetric in camera coordinates, this method minimizes the impact of | |
| 36 | +the background rate modeling from Monte Carlo. An optional exclusion map (in | |
| 37 | +FITS WCS format) can be provided as input through the ``inexclusion`` hidden | |
| 38 | +parameter if other regions of significant gamma-ray emission ought to be | |
| 39 | +excluded from the background computation. | |
| 40 | + | |
| 41 | +.. code-block:: bash | |
| 42 | + | |
| 43 | + $ csphagen | |
| 44 | + Input event list or observation definition XML file [obs.xml] events_edisp.fits | |
| 45 | + Calibration database [prod2] | |
| 46 | + Instrument response function [South_0.5h] | |
| 47 | + Binning algorithm (LIN|LOG|FILE) [LOG] | |
| 48 | + Lower energy limit (TeV) [0.1] | |
| 49 | + Upper energy limit (TeV) [100.0] | |
| 50 | + Number of energy bins [120] 30 | |
| 51 | + Coordinate system (CEL - celestial, GAL - galactic) (CEL|GAL) [CEL] | |
| 52 | + Right Ascension of source region centre (deg) (0-360) [83.63] | |
| 53 | + Declination of source region centre (deg) (-90-90) [22.01] | |
| 54 | + Radius of source region circle (deg) (0-180) [0.2] | |
| 55 | + Stack multiple observations into single PHA, ARF and RMF files? [no] | |
| 56 | + Output observation definition XML file [onoff_obs.xml] | |
| 57 | + | |
| 58 | +.. note:: | |
| 59 | + | |
| 60 | + - We have used the events simulated accounting for energy | |
| 61 | + dispersion, since energy dispersion is always used in On/Off analysis. | |
| 62 | + | |
| 63 | + - If you wish to limit the number of observations considered to | |
| 64 | + those pointed closer to the source, you can do this either at the | |
| 65 | + observation selection level (see :ref:`csobsselect`), or directly | |
| 66 | + in :ref:`csphagen` via the hidden ``maxoffset`` parameter. | |
| 67 | + | |
| 68 | + - The parameters specified control the energy binning of the count | |
| 69 | + spectra in *reconstructed* energy. For the computation of the | |
| 70 | + instrument response we need a fine binning in *true* energy, | |
| 71 | + which is controlled by the hidden parameters ``etruemin``, | |
| 72 | + ``etruemax``, and ``etruebins``. | |
| 73 | + | |
| 74 | +This has produced in output several files. The xml observations file | |
| 75 | +contains a single On/Off observation. | |
| 76 | + | |
| 77 | +.. code-block:: bash | |
| 78 | + | |
| 79 | + <?xml version="1.0" encoding="UTF-8" standalone="no"?> | |
| 80 | + <observation_list title="observation list"> | |
| 81 | + <observation name="" id="" instrument="CTAOnOff" statistic="cstat"> | |
| 82 | + <parameter name="Pha_on" file="onoff_pha_on.fits" /> | |
| 83 | + <parameter name="Pha_off" file="onoff_pha_off.fits" /> | |
| 84 | + <parameter name="Arf" file="onoff_arf.fits" /> | |
| 85 | + <parameter name="Rmf" file="onoff_rmf.fits" /> | |
| 86 | + </observation> | |
| 87 | + </observation_list> | |
| 88 | + | |
| 89 | +The observation entails four FITS files. ``onoff_pha_on.fits`` and | |
| 90 | +``onoff_pha_off.fits`` contain the On and Off spectra, respectively. | |
| 91 | +These are stored in the SPECTRUM extension of the FITS file, along with ancillary | |
| 92 | +information, notably the scaling factor to be applied to the background spectrum, | |
| 93 | +BACKSCAL. The third extension, EBOUNDS, contains the boundaries of the energy | |
| 94 | +bins, as defined by the binning parameters in input to csphagen. The file | |
| 95 | +``onoff_arf.fits`` contains the spectral response of the instrument | |
| 96 | +extracted fromt the :ref:`instrument response functions <glossary_irf>`, | |
| 97 | +including effective area for gamma-ray detection and background rates, in the | |
| 98 | +SPECRESP extension. The file ``onoff_rmf.fits`` contains the remaining | |
| 99 | +part of the instrument response, i.e., an energy redistribution matrix (MATRIX), | |
| 100 | +as well as another instance of the EBOUNDS table. Note that we are performing a | |
| 101 | +1D analysis: the effect of the PSF is already folded into the effective area | |
| 102 | +computation. | |
| 103 | + | |
| 104 | +.. note:: | |
| 105 | + | |
| 106 | + The first part of the FITS files names (and a full path to the desired | |
| 107 | + location) can be set using the hidden ``prefix`` parameter of | |
| 108 | + :ref:`csphagen`. | |
| 109 | + | |
| 110 | +There are also come ancillary `ds9 <http://ds9.si.edu>`_ region files, that show | |
| 111 | +the On region and the Off regions, ``onoff_on.reg`` and | |
| 112 | +``onoff_off.reg``, respectively. Below there is | |
| 113 | +a skymap where you can see the pointing direction along with the position of | |
| 114 | +the On and Off regions. | |
| 115 | + | |
| 116 | +.. figure:: onoff.png | |
| 117 | + :width: 400px | |
| 118 | + :align: center | |
| 119 | + | |
| 120 | + *Sky map of the events. The cross shows the pointing directions, | |
| 121 | + the green circles the Off regions, and the white circle the On | |
| 122 | + region.* | |
| 123 | + | |
| 124 | +The model to be fit to the observations needs to specify for the | |
| 125 | +background component that we are dealing with a ``CTAOnOff`` analysis. | |
| 126 | + | |
| 127 | +.. code-block:: bash | |
| 128 | + | |
| 129 | + <?xml version="1.0" standalone="no"?> | |
| 130 | + <source_library title="source library"> | |
| 131 | + <source name="Crab" type="PointSource"> | |
| 132 | + <spectrum type="PowerLaw"> | |
| 133 | + <parameter name="Prefactor" scale="1e-16" value="5.7" min="1e-07" max="1000.0" free="1"/> | |
| 134 | + <parameter name="Index" scale="-1" value="2.48" min="0.0" max="+5.0" free="1"/> | |
| 135 | + <parameter name="PivotEnergy" scale="1e6" value="0.3" min="0.01" max="1000.0" free="0"/> | |
| 136 | + </spectrum> | |
| 137 | + <spatialModel type="PointSource"> | |
| 138 | + <parameter name="RA" scale="1.0" value="83.6331" min="-360" max="360" free="0"/> | |
| 139 | + <parameter name="DEC" scale="1.0" value="22.0145" min="-90" max="90" free="0"/> | |
| 140 | + </spatialModel> | |
| 141 | + </source> | |
| 142 | + <source name="CTABackgroundModel" type="CTAIrfBackground" instrument="CTAOnOff"> | |
| 143 | + <spectrum type="PowerLaw"> | |
| 144 | + <parameter name="Prefactor" scale="1.0" value="1.0" min="1e-3" max="1e+3" free="1"/> | |
| 145 | + <parameter name="Index" scale="1.0" value="0.0" min="-5.0" max="+5.0" free="1"/> | |
| 146 | + <parameter name="PivotEnergy" scale="1e6" value="1.0" min="0.01" max="1000.0" free="0"/> | |
| 147 | + </spectrum> | |
| 148 | + </source> | |
| 149 | + </source_library> | |
| 150 | + | |
| 151 | +At this point we can run an On/Off analysis just by passing the On/Off | |
| 152 | +observation container to :ref:`ctlike`. | |
| 153 | + | |
| 154 | +.. code-block:: bash | |
| 155 | + Input event list, counts cube or observation definition XML file [selected_events.fits] onoff_obs.xml | |
| 156 | + Input model definition XML file [$CTOOLS/share/models/crab.xml] crab_onoff.xml | |
| 157 | + Output model definition XML file [crab_results.xml] | |
| 158 | + | |
| 159 | +Below you see the corresponding output from the ``ctlike.log`` | |
| 160 | +file.The fitted parameters are still the same within statistical | |
| 161 | +uncertainties as the ones found in binned/unbinned mode. This may not | |
| 162 | +always be the case, especially if the background is not well known a priori. | |
| 163 | + | |
| 164 | +.. code-block:: bash | |
| 165 | + | |
| 166 | + 2017-11-28T17:26:56: +=================================+ | |
| 167 | + 2017-11-28T17:26:56: | Maximum likelihood optimisation | | |
| 168 | + 2017-11-28T17:26:56: +=================================+ | |
| 169 | + 2017-11-28T17:26:56: >Iteration 0: -logL=-48350.908, Lambda=1.0e-03 | |
| 170 | + 2017-11-28T17:26:56: >Iteration 1: -logL=-48352.759, Lambda=1.0e-03, delta=1.852, step=1.0e+00, max(|grad|)=2.829489 [Index:7] | |
| 171 | + 2017-11-28T17:26:56: >Iteration 2: -logL=-48352.760, Lambda=1.0e-04, delta=0.000, step=1.0e+00, max(|grad|)=0.002408 [Index:3] | |
| 172 | + 2017-11-28T17:26:56: | |
| 173 | + 2017-11-28T17:26:56: +=========================================+ | |
| 174 | + 2017-11-28T17:26:56: | Maximum likelihood optimisation results | | |
| 175 | + 2017-11-28T17:26:56: +=========================================+ | |
| 176 | + 2017-11-28T17:26:56: === GOptimizerLM === | |
| 177 | + 2017-11-28T17:26:56: Optimized function value ..: -48352.760 | |
| 178 | + 2017-11-28T17:26:56: Absolute precision ........: 0.005 | |
| 179 | + 2017-11-28T17:26:56: Acceptable value decrease .: 2 | |
| 180 | + 2017-11-28T17:26:56: Optimization status .......: converged | |
| 181 | + 2017-11-28T17:26:56: Number of parameters ......: 10 | |
| 182 | + 2017-11-28T17:26:56: Number of free parameters .: 4 | |
| 183 | + 2017-11-28T17:26:56: Number of iterations ......: 2 | |
| 184 | + 2017-11-28T17:26:56: Lambda ....................: 1e-05 | |
| 185 | + 2017-11-28T17:26:56: Maximum log likelihood ....: 48352.760 | |
| 186 | + 2017-11-28T17:26:56: Observed events (Nobs) ...: 6656.000 | |
| 187 | + 2017-11-28T17:26:56: Predicted events (Npred) ..: 6655.663 (Nobs - Npred = 0.337440257160779) | |
| 188 | + 2017-11-28T17:26:56: === GModels === | |
| 189 | + 2017-11-28T17:26:56: Number of models ..........: 2 | |
| 190 | + 2017-11-28T17:26:56: Number of parameters ......: 10 | |
| 191 | + 2017-11-28T17:26:56: === GModelSky === | |
| 192 | + 2017-11-28T17:26:56: Name ......................: Crab | |
| 193 | + 2017-11-28T17:26:56: Instruments ...............: all | |
| 194 | + 2017-11-28T17:26:56: Instrument scale factors ..: unity | |
| 195 | + 2017-11-28T17:26:56: Observation identifiers ...: all | |
| 196 | + 2017-11-28T17:26:56: Model type ................: PointSource | |
| 197 | + 2017-11-28T17:26:56: Model components ..........: "PointSource" * "PowerLaw" * "Constant" | |
| 198 | + 2017-11-28T17:26:56: Number of parameters ......: 6 | |
| 199 | + 2017-11-28T17:26:56: Number of spatial par's ...: 2 | |
| 200 | + 2017-11-28T17:26:56: RA .......................: 83.6331 [-360,360] deg (fixed,scale=1) | |
| 201 | + 2017-11-28T17:26:56: DEC ......................: 22.0145 [-90,90] deg (fixed,scale=1) | |
| 202 | + 2017-11-28T17:26:56: Number of spectral par's ..: 3 | |
| 203 | + 2017-11-28T17:26:56: Prefactor ................: 5.69533666063277e-16 +/- 7.77619410705106e-18 [1e-23,1e-13] ph/cm2/s/MeV (free,scale=1e-16,gradient) | |
| 204 | + 2017-11-28T17:26:56: Index ....................: -2.47347083803876 +/- 0.0114544870463654 [-0,-5] (free,scale=-1,gradient) | |
| 205 | + 2017-11-28T17:26:56: PivotEnergy ..............: 300000 [10000,1000000000] MeV (fixed,scale=1000000,gradient) | |
| 206 | + 2017-11-28T17:26:56: Number of temporal par's ..: 1 | |
| 207 | + 2017-11-28T17:26:56: Normalization ............: 1 (relative value) (fixed,scale=1,gradient) | |
| 208 | + 2017-11-28T17:26:56: === GCTAModelIrfBackground === | |
| 209 | + 2017-11-28T17:26:56: Name ......................: CTABackgroundModel | |
| 210 | + 2017-11-28T17:26:56: Instruments ...............: CTAOnOff | |
| 211 | + 2017-11-28T17:26:56: Instrument scale factors ..: unity | |
| 212 | + 2017-11-28T17:26:56: Observation identifiers ...: all | |
| 213 | + 2017-11-28T17:26:56: Model type ................: "PowerLaw" * "Constant" | |
| 214 | + 2017-11-28T17:26:56: Number of parameters ......: 4 | |
| 215 | + 2017-11-28T17:26:56: Number of spectral par's ..: 3 | |
| 216 | + 2017-11-28T17:26:56: Prefactor ................: 1.00017594707712 +/- 0.0373732914079376 [0.001,1000] ph/cm2/s/MeV (free,scale=1,gradient) | |
| 217 | + 2017-11-28T17:26:56: Index ....................: 0.0190520959815092 +/- 0.0220805114253248 [-5,5] (free,scale=1,gradient) | |
| 218 | + 2017-11-28T17:26:56: PivotEnergy ..............: 1000000 [10000,1000000000] MeV (fixed,scale=1000000,gradient) | |
| 219 | + 2017-11-28T17:26:56: Number of temporal par's ..: 1 | |
| 220 | + 2017-11-28T17:26:56: Normalization ............: 1 (relative value) (fixed,scale=1,gradient) | |
| 221 | + | |
| 222 | +:ref:`ctlike` has a hidden parameter called ``statistic`` that sets the | |
| 223 | +statistic used for the fit. | |
| 224 | + | |
| 225 | +- The DEFAULT for OnOff osbervations is CSTAT, i.e., Poisson signal and Poisson | |
| 226 | + background. A spectral model for the signal and a spectral model for the | |
| 227 | + background are jointly fit to the On and Off spectra. | |
| 228 | +- WSTAT is a special case of CSTAT, Poisson signal with Poisson background, in | |
| 229 | + which you do not need to have a spectral model for the background and | |
| 230 | + free parameters associated with it. The number of background counts in each | |
| 231 | + energy bin is treated as a nuisance parameter, derived from the On and Off | |
| 232 | + counts by profiling the likelihood function. In this case the only assumption | |
| 233 | + is that the background rate spectrum is the same in the On and Off regions. | |
| 234 | + | |
| 235 | +.. warning:: | |
| 236 | + Beware that the profiling may yield unphysical results (negative background | |
| 237 | + counts) if the number of events in the Off spectra are zero. In this case a | |
| 238 | + null number of expected background events must be enforced, | |
| 239 | + which can result in a bias on the source's parameters. You can address this | |
| 240 | + issue by stacking multiple observations, using a coarser energy binning, or | |
| 241 | + using CSTAT instead (if you have a spectral model for the background that is | |
| 242 | + good enough). See the `XSPEC manual Appendix B <https://heasarc.gsfc.nasa.gov/xanadu/xspec/manual/XSappendixStatistics.html>`_ | |
| 243 | + for more information. | |
| 244 | + | |
| 245 | +- You can also use CHI2, a classical chi square, i.e., a Gaussian signal and | |
| 246 | + Gaussian background. As for CSTAT, a spectral model for the signal and a | |
| 247 | + spectral model for the background are jointly fit to the On and Off | |
| 248 | + spectra. | |
| 249 | + | |
| 250 | +.. note:: | |
| 251 | + | |
| 252 | + Many scripts can also be used in On/Off mode, including | |
| 253 | + :ref:`ctbutterfly` and :ref:`csspec` that were used earlier. It is | |
| 254 | + sufficient to replace the input counts cube/event list with an | |
| 255 | + On/Off observation container to activate On/Off mode for these | |
| 256 | + tools. | |
| 257 | + | |
| 258 | + | ... | ... |
doc/source/users/tutorials/quickstart/unbinned.rst
| ... | ... | @@ -56,64 +56,64 @@ the same events for both analyses. |
| 56 | 56 | |
| 57 | 57 | .. code-block:: none |
| 58 | 58 | |
| 59 | - 2017-11-28T16:26:57: +=================================+ | |
| 60 | - 2017-11-28T16:26:57: | Maximum likelihood optimisation | | |
| 61 | - 2017-11-28T16:26:57: +=================================+ | |
| 62 | - 2017-11-28T16:26:57: >Iteration 0: -logL=134457.962, Lambda=1.0e-03 | |
| 63 | - 2017-11-28T16:26:57: >Iteration 1: -logL=134437.621, Lambda=1.0e-03, delta=20.342, step=1.0e+00, max(|grad|)=43.475634 [Index:7] | |
| 64 | - 2017-11-28T16:26:57: >Iteration 2: -logL=134437.595, Lambda=1.0e-04, delta=0.026, step=1.0e+00, max(|grad|)=0.121800 [Index:7] | |
| 65 | - 2017-11-28T16:26:57: >Iteration 3: -logL=134437.595, Lambda=1.0e-05, delta=0.000, step=1.0e+00, max(|grad|)=0.001202 [Index:7] | |
| 66 | - 2017-11-28T16:26:57: | |
| 67 | - 2017-11-28T16:26:57: +=========================================+ | |
| 68 | - 2017-11-28T16:26:57: | Maximum likelihood optimisation results | | |
| 69 | - 2017-11-28T16:26:57: +=========================================+ | |
| 70 | - 2017-11-28T16:26:57: === GOptimizerLM === | |
| 71 | - 2017-11-28T16:26:57: Optimized function value ..: 134437.595 | |
| 72 | - 2017-11-28T16:26:57: Absolute precision ........: 0.005 | |
| 73 | - 2017-11-28T16:26:57: Acceptable value decrease .: 2 | |
| 74 | - 2017-11-28T16:26:57: Optimization status .......: converged | |
| 75 | - 2017-11-28T16:26:57: Number of parameters ......: 10 | |
| 76 | - 2017-11-28T16:26:57: Number of free parameters .: 4 | |
| 77 | - 2017-11-28T16:26:57: Number of iterations ......: 3 | |
| 78 | - 2017-11-28T16:26:57: Lambda ....................: 1e-06 | |
| 79 | - 2017-11-28T16:26:57: Maximum log likelihood ....: -134437.595 | |
| 80 | - 2017-11-28T16:26:57: Observed events (Nobs) ...: 20877.000 | |
| 81 | - 2017-11-28T16:26:57: Predicted events (Npred) ..: 20877.000 (Nobs - Npred = -1.41397322295234e-07) | |
| 82 | - 2017-11-28T16:26:57: === GModels === | |
| 83 | - 2017-11-28T16:26:57: Number of models ..........: 2 | |
| 84 | - 2017-11-28T16:26:57: Number of parameters ......: 10 | |
| 85 | - 2017-11-28T16:26:57: === GModelSky === | |
| 86 | - 2017-11-28T16:26:57: Name ......................: Crab | |
| 87 | - 2017-11-28T16:26:57: Instruments ...............: all | |
| 88 | - 2017-11-28T16:26:57: Instrument scale factors ..: unity | |
| 89 | - 2017-11-28T16:26:57: Observation identifiers ...: all | |
| 90 | - 2017-11-28T16:26:57: Model type ................: PointSource | |
| 91 | - 2017-11-28T16:26:57: Model components ..........: "PointSource" * "PowerLaw" * "Constant" | |
| 92 | - 2017-11-28T16:26:57: Number of parameters ......: 6 | |
| 93 | - 2017-11-28T16:26:57: Number of spatial par's ...: 2 | |
| 94 | - 2017-11-28T16:26:57: RA .......................: 83.6331 [-360,360] deg (fixed,scale=1) | |
| 95 | - 2017-11-28T16:26:57: DEC ......................: 22.0145 [-90,90] deg (fixed,scale=1) | |
| 96 | - 2017-11-28T16:26:57: Number of spectral par's ..: 3 | |
| 97 | - 2017-11-28T16:26:57: Prefactor ................: 5.85495471291474e-16 +/- 1.08121595582131e-17 [1e-23,1e-13] ph/cm2/s/MeV (free,scale=1e-16,gradient) | |
| 98 | - 2017-11-28T16:26:57: Index ....................: -2.48742680094013 +/- 0.0155955916697299 [-0,-5] (free,scale=-1,gradient) | |
| 99 | - 2017-11-28T16:26:57: PivotEnergy ..............: 300000 [10000,1000000000] MeV (fixed,scale=1000000,gradient) | |
| 100 | - 2017-11-28T16:26:57: Number of temporal par's ..: 1 | |
| 101 | - 2017-11-28T16:26:57: Normalization ............: 1 (relative value) (fixed,scale=1,gradient) | |
| 102 | - 2017-11-28T16:26:57: === GCTAModelIrfBackground === | |
| 103 | - 2017-11-28T16:26:57: Name ......................: CTABackgroundModel | |
| 104 | - 2017-11-28T16:26:57: Instruments ...............: CTA | |
| 105 | - 2017-11-28T16:26:57: Instrument scale factors ..: unity | |
| 106 | - 2017-11-28T16:26:57: Observation identifiers ...: all | |
| 107 | - 2017-11-28T16:26:57: Model type ................: "PowerLaw" * "Constant" | |
| 108 | - 2017-11-28T16:26:57: Number of parameters ......: 4 | |
| 109 | - 2017-11-28T16:26:57: Number of spectral par's ..: 3 | |
| 110 | - 2017-11-28T16:26:57: Prefactor ................: 0.966210894921824 +/- 0.0131220642906203 [0.001,1000] ph/cm2/s/MeV (free,scale=1,gradient) | |
| 111 | - 2017-11-28T16:26:57: Index ....................: 0.00879946195443994 +/- 0.00825144420159423 [-5,5] (free,scale=1,gradient) | |
| 112 | - 2017-11-28T16:26:57: PivotEnergy ..............: 1000000 [10000,1000000000] MeV (fixed,scale=1000000,gradient) | |
| 113 | - 2017-11-28T16:26:57: Number of temporal par's ..: 1 | |
| 114 | - 2017-11-28T16:26:57: Normalization ............: 1 (relative value) (fixed,scale=1,gradient) | |
| 59 | + 2017-11-28T16:26:57: +=================================+ | |
| 60 | + 2017-11-28T16:26:57: | Maximum likelihood optimisation | | |
| 61 | + 2017-11-28T16:26:57: +=================================+ | |
| 62 | + 2017-11-28T16:26:57: >Iteration 0: -logL=134457.962, Lambda=1.0e-03 | |
| 63 | + 2017-11-28T16:26:57: >Iteration 1: -logL=134437.621, Lambda=1.0e-03, delta=20.342, step=1.0e+00, max(|grad|)=43.475634 [Index:7] | |
| 64 | + 2017-11-28T16:26:57: >Iteration 2: -logL=134437.595, Lambda=1.0e-04, delta=0.026, step=1.0e+00, max(|grad|)=0.121800 [Index:7] | |
| 65 | + 2017-11-28T16:26:57: >Iteration 3: -logL=134437.595, Lambda=1.0e-05, delta=0.000, step=1.0e+00, max(|grad|)=0.001202 [Index:7] | |
| 66 | + 2017-11-28T16:26:57: | |
| 67 | + 2017-11-28T16:26:57: +=========================================+ | |
| 68 | + 2017-11-28T16:26:57: | Maximum likelihood optimisation results | | |
| 69 | + 2017-11-28T16:26:57: +=========================================+ | |
| 70 | + 2017-11-28T16:26:57: === GOptimizerLM === | |
| 71 | + 2017-11-28T16:26:57: Optimized function value ..: 134437.595 | |
| 72 | + 2017-11-28T16:26:57: Absolute precision ........: 0.005 | |
| 73 | + 2017-11-28T16:26:57: Acceptable value decrease .: 2 | |
| 74 | + 2017-11-28T16:26:57: Optimization status .......: converged | |
| 75 | + 2017-11-28T16:26:57: Number of parameters ......: 10 | |
| 76 | + 2017-11-28T16:26:57: Number of free parameters .: 4 | |
| 77 | + 2017-11-28T16:26:57: Number of iterations ......: 3 | |
| 78 | + 2017-11-28T16:26:57: Lambda ....................: 1e-06 | |
| 79 | + 2017-11-28T16:26:57: Maximum log likelihood ....: -134437.595 | |
| 80 | + 2017-11-28T16:26:57: Observed events (Nobs) ...: 20877.000 | |
| 81 | + 2017-11-28T16:26:57: Predicted events (Npred) ..: 20877.000 (Nobs - Npred = -1.41397322295234e-07) | |
| 82 | + 2017-11-28T16:26:57: === GModels === | |
| 83 | + 2017-11-28T16:26:57: Number of models ..........: 2 | |
| 84 | + 2017-11-28T16:26:57: Number of parameters ......: 10 | |
| 85 | + 2017-11-28T16:26:57: === GModelSky === | |
| 86 | + 2017-11-28T16:26:57: Name ......................: Crab | |
| 87 | + 2017-11-28T16:26:57: Instruments ...............: all | |
| 88 | + 2017-11-28T16:26:57: Instrument scale factors ..: unity | |
| 89 | + 2017-11-28T16:26:57: Observation identifiers ...: all | |
| 90 | + 2017-11-28T16:26:57: Model type ................: PointSource | |
| 91 | + 2017-11-28T16:26:57: Model components ..........: "PointSource" * "PowerLaw" * "Constant" | |
| 92 | + 2017-11-28T16:26:57: Number of parameters ......: 6 | |
| 93 | + 2017-11-28T16:26:57: Number of spatial par's ...: 2 | |
| 94 | + 2017-11-28T16:26:57: RA .......................: 83.6331 [-360,360] deg (fixed,scale=1) | |
| 95 | + 2017-11-28T16:26:57: DEC ......................: 22.0145 [-90,90] deg (fixed,scale=1) | |
| 96 | + 2017-11-28T16:26:57: Number of spectral par's ..: 3 | |
| 97 | + 2017-11-28T16:26:57: Prefactor ................: 5.85495471291474e-16 +/- 1.08121595582131e-17 [1e-23,1e-13] ph/cm2/s/MeV (free,scale=1e-16,gradient) | |
| 98 | + 2017-11-28T16:26:57: Index ....................: -2.48742680094013 +/- 0.0155955916697299 [-0,-5] (free,scale=-1,gradient) | |
| 99 | + 2017-11-28T16:26:57: PivotEnergy ..............: 300000 [10000,1000000000] MeV (fixed,scale=1000000,gradient) | |
| 100 | + 2017-11-28T16:26:57: Number of temporal par's ..: 1 | |
| 101 | + 2017-11-28T16:26:57: Normalization ............: 1 (relative value) (fixed,scale=1,gradient) | |
| 102 | + 2017-11-28T16:26:57: === GCTAModelIrfBackground === | |
| 103 | + 2017-11-28T16:26:57: Name ......................: CTABackgroundModel | |
| 104 | + 2017-11-28T16:26:57: Instruments ...............: CTA | |
| 105 | + 2017-11-28T16:26:57: Instrument scale factors ..: unity | |
| 106 | + 2017-11-28T16:26:57: Observation identifiers ...: all | |
| 107 | + 2017-11-28T16:26:57: Model type ................: "PowerLaw" * "Constant" | |
| 108 | + 2017-11-28T16:26:57: Number of parameters ......: 4 | |
| 109 | + 2017-11-28T16:26:57: Number of spectral par's ..: 3 | |
| 110 | + 2017-11-28T16:26:57: Prefactor ................: 0.966210894921824 +/- 0.0131220642906203 [0.001,1000] ph/cm2/s/MeV (free,scale=1,gradient) | |
| 111 | + 2017-11-28T16:26:57: Index ....................: 0.00879946195443994 +/- 0.00825144420159423 [-5,5] (free,scale=1,gradient) | |
| 112 | + 2017-11-28T16:26:57: PivotEnergy ..............: 1000000 [10000,1000000000] MeV (fixed,scale=1000000,gradient) | |
| 113 | + 2017-11-28T16:26:57: Number of temporal par's ..: 1 | |
| 114 | + 2017-11-28T16:26:57: Normalization ............: 1 (relative value) (fixed,scale=1,gradient) | |
| 115 | 115 | |
| 116 | - .. note:: | |
| 116 | +.. note:: | |
| 117 | 117 | |
| 118 | 118 | Many tools or scripts can also be used in unbinned mode, including |
| 119 | 119 | :ref:`csresmap`, :ref:`ctbutterfly` and :ref:`csspec` that were used | ... | ... |