From f7d1a4b47b1af0a2cc3ce3ee32501d314c33a141 Mon Sep 17 00:00:00 2001 From: Luigi Tibaldo Date: Tue, 28 Nov 2017 17:12:08 +0100 Subject: [PATCH] redoing quickstart with off-axis observation to add On/Off --- doc/source/users/tutorials/quickstart/butterfly.rst | 10 +++++----- doc/source/users/tutorials/quickstart/cntmap-map.jpg | Bin 23229 -> 0 bytes doc/source/users/tutorials/quickstart/fitting.rst | 180 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------------------------------------------------------- doc/source/users/tutorials/quickstart/index.rst | 1 + doc/source/users/tutorials/quickstart/onoff.rst | 19 +++++++++++++++++++ doc/source/users/tutorials/quickstart/residuals.jpg | Bin 374622 -> 0 bytes doc/source/users/tutorials/quickstart/selecting.rst | 75 +++++++++++++++++++++++++++++++++++++++------------------------------------ doc/source/users/tutorials/quickstart/simulating.rst | 80 +++++++++++++++++++++++++++++++++++++++++++------------------------------------- doc/source/users/tutorials/quickstart/skymap.jpg | Bin 188275 -> 0 bytes doc/source/users/tutorials/quickstart/skymap.rst | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- doc/source/users/tutorials/quickstart/skymap_ring.jpg | Bin 0 -> 4928 bytes doc/source/users/tutorials/quickstart/skymap_subtracted.jpg | Bin 130836 -> 0 bytes doc/source/users/tutorials/quickstart/unbinned.rst | 6 +----- examples/show_butterfly.py | 2 +- 14 files changed, 263 insertions(+), 174 deletions(-) create mode 100644 doc/source/users/tutorials/quickstart/onoff.rst create mode 100644 doc/source/users/tutorials/quickstart/skymap_ring.jpg diff --git a/doc/source/users/tutorials/quickstart/butterfly.rst b/doc/source/users/tutorials/quickstart/butterfly.rst index 51b1ad0..3a5a50a 100644 --- a/doc/source/users/tutorials/quickstart/butterfly.rst +++ b/doc/source/users/tutorials/quickstart/butterfly.rst @@ -37,12 +37,12 @@ default is set to 100. Below an excerpt of the first lines of the ``butterfly.txt`` file: .. code-block:: none + + 103514.216667934 8.08876441182872e-15 7.86364405017512e-15 8.31388477348232e-15 + 110917.48152624 6.81370736945431e-15 6.62965024227895e-15 6.99776449662967e-15 + 118850.222743702 5.73964152654309e-15 5.58918876927557e-15 5.89009428381061e-15 + 127350.308101666 4.83488401643174e-15 4.71191629605204e-15 4.95785173681143e-15 - 103514.216667934 7.65729960995773e-15 7.45677281959723e-15 7.85782640031824e-15 - 110917.48152624 6.46256412586182e-15 6.2982352355303e-15 6.62689301619334e-15 - 118850.222743702 5.45423807455102e-15 5.3195999976704e-15 5.58887615143164e-15 - 127350.308101666 4.6032367949486e-15 4.49293900723421e-15 4.71353458266298e-15 - 136458.313658893 3.88501358040058e-15 3.7946590323386e-15 3.97536812846257e-15 ... A graphical display of the results is shown below: diff --git a/doc/source/users/tutorials/quickstart/cntmap-map.jpg b/doc/source/users/tutorials/quickstart/cntmap-map.jpg index b22de89..adc8934 100644 Binary files a/doc/source/users/tutorials/quickstart/cntmap-map.jpg and b/doc/source/users/tutorials/quickstart/cntmap-map.jpg differ diff --git a/doc/source/users/tutorials/quickstart/fitting.rst b/doc/source/users/tutorials/quickstart/fitting.rst index af296af..4db4aea 100644 --- a/doc/source/users/tutorials/quickstart/fitting.rst +++ b/doc/source/users/tutorials/quickstart/fitting.rst @@ -24,12 +24,16 @@ typing: Output model definition XML file [crab_results.xml] The data are fitted in *binned* mode, which means that the events -have been binned into a counts cube and the fit computes the log-likelihood +have been binned into a 3D counts cube and the fit computes the log-likelihood function by summing over all 200 x 200 x 20 bins of the counts cube. There is an alternative method, the so called *unbinned* mode, where the events are not binned into a counts cube and the log-likelihood is computed directly by summing over all events. -:ref:`We will explore the unbinned mode later `. +:ref:`We will explore the unbinned mode later `. Yet a +third alternative method (*On/Off* mode) consists in binning the events only in energy +integrating over arrival direction within a Source (On) and one or +more Background (Off) regions to minimise the dependency on the IRF +background model. :ref:`We will explore the On/Off mode later ` The :ref:`ctlike` tool produced a :ref:`model definition XML output file ` @@ -45,27 +49,27 @@ that was produced by the run: .. code-block:: xml - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + In this example, the ``Prefactor`` and ``Index`` of the spectral model for the Crab nebula as well as the ``Prefactor`` and ``Index`` of the background spectral @@ -98,62 +102,63 @@ Below the last lines of the log file that was produced by this run: .. code-block:: none - 2017-08-08T20:24:06: +=================================+ - 2017-08-08T20:24:06: | Maximum likelihood optimisation | - 2017-08-08T20:24:06: +=================================+ - 2017-08-08T20:24:07: >Iteration 0: -logL=56488.484, Lambda=1.0e-03 - 2017-08-08T20:24:07: >Iteration 1: -logL=56431.025, Lambda=1.0e-03, delta=57.459, step=1.0e+00, max(|grad|)=128.772103 [Index:7] - 2017-08-08T20:24:08: >Iteration 2: -logL=56430.794, Lambda=1.0e-04, delta=0.232, step=1.0e+00, max(|grad|)=0.505741 [Index:7] - 2017-08-08T20:24:09: >Iteration 3: -logL=56430.794, Lambda=1.0e-05, delta=0.000, step=1.0e+00, max(|grad|)=0.017423 [Index:3] - 2017-08-08T20:24:09: - 2017-08-08T20:24:09: +=========================================+ - 2017-08-08T20:24:09: | Maximum likelihood optimisation results | - 2017-08-08T20:24:09: +=========================================+ - 2017-08-08T20:24:09: === GOptimizerLM === - 2017-08-08T20:24:09: Optimized function value ..: 56430.794 - 2017-08-08T20:24:09: Absolute precision ........: 0.005 - 2017-08-08T20:24:09: Acceptable value decrease .: 2 - 2017-08-08T20:24:09: Optimization status .......: converged - 2017-08-08T20:24:09: Number of parameters ......: 10 - 2017-08-08T20:24:09: Number of free parameters .: 4 - 2017-08-08T20:24:09: Number of iterations ......: 3 - 2017-08-08T20:24:09: Lambda ....................: 1e-06 - 2017-08-08T20:24:09: Maximum log likelihood ....: -56430.794 - 2017-08-08T20:24:09: Observed events (Nobs) ...: 18827.000 - 2017-08-08T20:24:09: Predicted events (Npred) ..: 18827.000 (Nobs - Npred = 1.92705083463807e-05) - 2017-08-08T20:24:09: === GModels === - 2017-08-08T20:24:09: Number of models ..........: 2 - 2017-08-08T20:24:09: Number of parameters ......: 10 - 2017-08-08T20:24:09: === GModelSky === - 2017-08-08T20:24:09: Name ......................: Crab - 2017-08-08T20:24:09: Instruments ...............: all - 2017-08-08T20:24:09: Instrument scale factors ..: unity - 2017-08-08T20:24:09: Observation identifiers ...: all - 2017-08-08T20:24:09: Model type ................: PointSource - 2017-08-08T20:24:09: Model components ..........: "PointSource" * "PowerLaw" * "Constant" - 2017-08-08T20:24:09: Number of parameters ......: 6 - 2017-08-08T20:24:09: Number of spatial par's ...: 2 - 2017-08-08T20:24:09: RA .......................: 83.6331 [-360,360] deg (fixed,scale=1) - 2017-08-08T20:24:09: DEC ......................: 22.0145 [-90,90] deg (fixed,scale=1) - 2017-08-08T20:24:09: Number of spectral par's ..: 3 - 2017-08-08T20:24:09: Prefactor ................: 5.61368377731832e-16 +/- 9.82975197293023e-18 [1e-23,1e-13] ph/cm2/s/MeV (free,scale=1e-16,gradient) - 2017-08-08T20:24:09: Index ....................: -2.45569249143075 +/- 0.0145471260625612 [-0,-5] (free,scale=-1,gradient) - 2017-08-08T20:24:09: PivotEnergy ..............: 300000 [10000,1000000000] MeV (fixed,scale=1000000,gradient) - 2017-08-08T20:24:09: Number of temporal par's ..: 1 - 2017-08-08T20:24:09: Normalization ............: 1 (relative value) (fixed,scale=1,gradient) - 2017-08-08T20:24:09: === GCTAModelCubeBackground === - 2017-08-08T20:24:09: Name ......................: BackgroundModel - 2017-08-08T20:24:09: Instruments ...............: CTA, HESS, MAGIC, VERITAS - 2017-08-08T20:24:09: Instrument scale factors ..: unity - 2017-08-08T20:24:09: Observation identifiers ...: all - 2017-08-08T20:24:09: Model type ................: "PowerLaw" * "Constant" - 2017-08-08T20:24:09: Number of parameters ......: 4 - 2017-08-08T20:24:09: Number of spectral par's ..: 3 - 2017-08-08T20:24:09: Prefactor ................: 0.945994938701748 +/- 0.0148673466828289 [0.01,100] ph/cm2/s/MeV (free,scale=1,gradient) - 2017-08-08T20:24:09: Index ....................: 0.0198073832868029 +/- 0.00948925246912034 [-5,5] (free,scale=1,gradient) - 2017-08-08T20:24:09: PivotEnergy ..............: 1000000 MeV (fixed,scale=1000000,gradient) - 2017-08-08T20:24:09: Number of temporal par's ..: 1 - 2017-08-08T20:24:09: Normalization ............: 1 (relative value) (fixed,scale=1,gradient) + 2017-11-28T15:36:34: +=================================+ + 2017-11-28T15:36:34: | Maximum likelihood optimisation | + 2017-11-28T15:36:34: +=================================+ + 2017-11-28T15:36:34: >Iteration 0: -logL=52917.614, Lambda=1.0e-03 + 2017-11-28T15:36:35: >Iteration 1: -logL=52916.284, Lambda=1.0e-03, delta=1.330, step=1.0e+00, m + ax(|grad|)=-2.668420 [Prefactor:6] + 2017-11-28T15:36:35: >Iteration 2: -logL=52916.283, Lambda=1.0e-04, delta=0.001, step=1.0e+00, m + ax(|grad|)=-0.037269 [Index:7] + 2017-11-28T15:36:36: + 2017-11-28T15:36:36: +=========================================+ + 2017-11-28T15:36:36: | Maximum likelihood optimisation results | + 2017-11-28T15:36:36: +=========================================+ + 2017-11-28T15:36:36: === GOptimizerLM === + 2017-11-28T15:36:36: Optimized function value ..: 52916.283 + 2017-11-28T15:36:36: Absolute precision ........: 0.005 + 2017-11-28T15:36:36: Acceptable value decrease .: 2 + 2017-11-28T15:36:36: Optimization status .......: converged + 2017-11-28T15:36:36: Number of parameters ......: 10 + 2017-11-28T15:36:36: Number of free parameters .: 4 + 2017-11-28T15:36:36: Number of iterations ......: 2 + 2017-11-28T15:36:36: Lambda ....................: 1e-05 + 2017-11-28T15:36:36: Maximum log likelihood ....: -52916.283 + 2017-11-28T15:36:36: Observed events (Nobs) ...: 17279.000 + 2017-11-28T15:36:36: Predicted events (Npred) ..: 17278.995 (Nobs - Npred = 0.00451555556355743) + 2017-11-28T15:36:36: === GModels === + 2017-11-28T15:36:36: Number of models ..........: 2 + 2017-11-28T15:36:36: Number of parameters ......: 10 + 2017-11-28T15:36:36: === GModelSky === + 2017-11-28T15:36:36: Name ......................: Crab + 2017-11-28T15:36:36: Instruments ...............: all + 2017-11-28T15:36:36: Instrument scale factors ..: unity + 2017-11-28T15:36:36: Observation identifiers ...: all + 2017-11-28T15:36:36: Model type ................: PointSource + 2017-11-28T15:36:36: Model components ..........: "PointSource" * "PowerLaw" * "Constant" + 2017-11-28T15:36:36: Number of parameters ......: 6 + 2017-11-28T15:36:36: Number of spatial par's ...: 2 + 2017-11-28T15:36:36: RA .......................: 83.6331 [-360,360] deg (fixed,scale=1) + 2017-11-28T15:36:36: DEC ......................: 22.0145 [-90,90] deg (fixed,scale=1) + 2017-11-28T15:36:36: Number of spectral par's ..: 3 + 2017-11-28T15:36:36: Prefactor ................: 5.75838848465398e-16 +/- 1.06769545262219e-17 [1e-23,1e-13] ph/cm2/s/MeV (free,scale=1e-16,gradient) + 2017-11-28T15:36:36: Index ....................: -2.48329029246896 +/- 0.0156629819926589 [-0,-5] (free,scale=-1,gradient) + 2017-11-28T15:36:36: PivotEnergy ..............: 300000 [10000,1000000000] MeV (fixed,scale=1000000,gradient) + 2017-11-28T15:36:36: Number of temporal par's ..: 1 + 2017-11-28T15:36:36: Normalization ............: 1 (relative value) (fixed,scale=1,gradient) + 2017-11-28T15:36:36: === GCTAModelCubeBackground === + 2017-11-28T15:36:36: Name ......................: BackgroundModel + 2017-11-28T15:36:36: Instruments ...............: CTA, HESS, MAGIC, VERITAS + 2017-11-28T15:36:36: Instrument scale factors ..: unity + 2017-11-28T15:36:36: Observation identifiers ...: all + 2017-11-28T15:36:36: Model type ................: "PowerLaw" * "Constant" + 2017-11-28T15:36:36: Number of parameters ......: 4 + 2017-11-28T15:36:36: Number of spectral par's ..: 3 + 2017-11-28T15:36:36: Prefactor ................: 1.01452697987952 +/- 0.0164053949309481 [0.01,100] ph/cm2/s/MeV (free,scale=1,gradient) + 2017-11-28T15:36:36: Index ....................: 0.0139985850735283 +/- 0.00978611932246665 [-5,5] (free,scale=1,gradient) + 2017-11-28T15:36:36: PivotEnergy ..............: 1000000 MeV (fixed,scale=1000000,gradient) + 2017-11-28T15:36:36: Number of temporal par's ..: 1 + 2017-11-28T15:36:36: Normalization ............: 1 (relative value) (fixed,scale=1,gradient) The maximum likelihood optimizer required 3 iterations to converge. This is pretty fast, but recall that you used the same model file for the simulation @@ -182,10 +187,11 @@ are not too far from the best fitting values). significance for sources in the XML model. This is done by computing the Test Statistic value which is defined as twice the log-likelihood difference between fitting a source at a given position on top of a - (background) model or fitting no source. Roughly speaken, the square + (background) model or fitting no source. As a rule of thumb, the square root of the Test Statistic value gives the source detection significance - in Gaussian sigmas, although the exact relation depends somewhat on - the formulation of the statistical problem. + in Gaussian sigmas, although the actual conversion depends somewhat on + the formulation of the statistical problem and the number of + degrees of freedom associated with the source. To instruct :ref:`ctlike` to compute the Test Statistic value for a given source you need to add the attribute ``tscalc="1"`` to the XML @@ -200,14 +206,14 @@ are not too far from the best fitting values). .. code-block:: none - 2017-08-08T20:34:29: === GModelSky === - 2017-08-08T20:34:29: Name ......................: Crab - 2017-08-08T20:34:29: Instruments ...............: all - 2017-08-08T20:34:29: Test Statistic ............: 21873.9558591403 + 2017-11-28T15:47:53: Name ......................: Crab + 2017-11-28T15:47:53: Instruments ...............: all + 2017-11-28T15:47:53: Test Statistic ............: 19478.9230755261 + The Test Statistic value will also be added as new attribute ``ts`` to the XML result file: .. code-block:: xml - + diff --git a/doc/source/users/tutorials/quickstart/index.rst b/doc/source/users/tutorials/quickstart/index.rst index 8890947..c62cab1 100644 --- a/doc/source/users/tutorials/quickstart/index.rst +++ b/doc/source/users/tutorials/quickstart/index.rst @@ -21,5 +21,6 @@ examples should take about an hour, so grab some coffee before you start. butterfly spectrum unbinned + onoff energy_dispersion ctools-from-python diff --git a/doc/source/users/tutorials/quickstart/onoff.rst b/doc/source/users/tutorials/quickstart/onoff.rst new file mode 100644 index 0000000..2652e53 --- /dev/null +++ b/doc/source/users/tutorials/quickstart/onoff.rst @@ -0,0 +1,19 @@ +.. _start_onoff: + +Doing an On/Off analysis +-------------------------- + + .. admonition:: What you will learn + + You will learn how to **adjust a parametrised spectral model to + the events deriving the bacground from the data**. + + Gamma-ray events are rare compared to the background events, + hence small imperfections of the background model can have a + large impact on the estimated source parameters. + + In classical IACT analyses the background has been normally + derived from the data, by defining On (source) and Off + (background) regions. An On/Off analysis is recommended if you + want to assure minimal dependency on the Monte Carlo background model. + diff --git a/doc/source/users/tutorials/quickstart/residuals.jpg b/doc/source/users/tutorials/quickstart/residuals.jpg index 21c81ce..d1bd26c 100644 Binary files a/doc/source/users/tutorials/quickstart/residuals.jpg and b/doc/source/users/tutorials/quickstart/residuals.jpg differ diff --git a/doc/source/users/tutorials/quickstart/selecting.rst b/doc/source/users/tutorials/quickstart/selecting.rst index 40f5c24..bffc9b8 100644 --- a/doc/source/users/tutorials/quickstart/selecting.rst +++ b/doc/source/users/tutorials/quickstart/selecting.rst @@ -35,43 +35,46 @@ event selection: .. code-block:: none - 2017-08-08T19:48:43: +===================+ - 2017-08-08T19:48:43: | Input observation | - 2017-08-08T19:48:43: +===================+ - 2017-08-08T19:48:43: === GObservations === - 2017-08-08T19:48:43: Number of observations ....: 1 - 2017-08-08T19:48:43: Number of models ..........: 0 - 2017-08-08T19:48:43: Number of observed events .: 202766 - 2017-08-08T19:48:43: Number of predicted events : 0 - 2017-08-08T19:48:43: - 2017-08-08T19:48:43: +=================+ - 2017-08-08T19:48:43: | Event selection | - 2017-08-08T19:48:43: +=================+ - 2017-08-08T19:48:43: === CTA observation === - 2017-08-08T19:48:43: Input filename ............: events.fits - 2017-08-08T19:48:43: Event extension name ......: EVENTS - 2017-08-08T19:48:43: GTI extension name ........: GTI - 2017-08-08T19:48:43: === Event selection === - 2017-08-08T19:48:43: Time range (MJD) ..........: 58849.0077451852 - 58849.0285785185 days - 2017-08-08T19:48:43: Time range (UTC) ..........: 2020-01-01T00:10:00 - 2020-01-01T00:40:00 - 2017-08-08T19:48:43: Time range (MET) ..........: 631109469.184 - 631111269.184 seconds - 2017-08-08T19:48:43: Selected energy range .....: 0.1 - 100 TeV - 2017-08-08T19:48:43: Requested RoI .............: Centre(RA,DEC)=(83.63, 22.01) deg, Radius=3 deg - 2017-08-08T19:48:43: RoI of data ...............: Centre(RA,DEC)=(83.63, 22.01) deg, Radius=5 deg - 2017-08-08T19:48:43: Selected RoI ..............: Centre(RA,DEC)=(83.63, 22.01) deg, Radius=3 deg - 2017-08-08T19:48:43: cfitsio selection .........: TIME >= 631109469.18399978 && TIME <= 631111269.18400002 && ENERGY >= 0.10000000 && ENERGY <= 100.00000000 && ANGSEP(83.630000,22.010000,RA,DEC) <= 3.000000 - 2017-08-08T19:48:43: FITS filename .............: /var/tmp/tmp.0.FLddl1[EVENTS][TIME >= 631109469.18399978 && TIME <= 631111269.18400002 && ENERGY >= 0.10000000 && ENERGY <= 100.00000000 && ANGSEP(83.630000,22.010000,RA,DEC) <= 3.000000] - 2017-08-08T19:48:43: - 2017-08-08T19:48:43: +====================+ - 2017-08-08T19:48:43: | Output observation | - 2017-08-08T19:48:43: +====================+ - 2017-08-08T19:48:43: === GObservations === - 2017-08-08T19:48:43: Number of observations ....: 1 - 2017-08-08T19:48:43: Number of models ..........: 0 - 2017-08-08T19:48:43: Number of observed events .: 21991 - 2017-08-08T19:48:43: Number of predicted events : 0 + 2017-11-28T14:21:57: +===================+ + 2017-11-28T14:21:57: | Input observation | + 2017-11-28T14:21:57: +===================+ + 2017-11-28T14:21:57: === GObservations === + 2017-11-28T14:21:57: Number of observations ....: 1 + 2017-11-28T14:21:57: Number of models ..........: 0 + 2017-11-28T14:21:57: Number of observed events .: 200833 + 2017-11-28T14:21:57: Number of predicted events : 0 + 2017-11-28T14:21:57: + 2017-11-28T14:21:57: +=================+ + 2017-11-28T14:21:57: | Event selection | + 2017-11-28T14:21:57: +=================+ + 2017-11-28T14:21:57: === CTA observation === + 2017-11-28T14:21:57: Input filename ............: events.fits + 2017-11-28T14:21:57: Event extension name ......: EVENTS + 2017-11-28T14:21:57: GTI extension name ........: GTI + 2017-11-28T14:21:58: === Event selection === + 2017-11-28T14:21:58: Time range (MJD) ..........: 58849.0077451852 - 58849.0285785185 days + 2017-11-28T14:21:58: Time range (UTC) ..........: 2020-01-01T00:10:00 - 2020-01-01T00:40:00 + 2017-11-28T14:21:58: Time range (MET) ..........: 631109469.184 - 631111269.184 seconds + 2017-11-28T14:21:58: Selected energy range .....: 0.1 - 100 TeV + 2017-11-28T14:21:58: Requested RoI .............: Centre(RA,DEC)=(83.63, 22.01) deg, Radius=3 deg + 2017-11-28T14:21:58: RoI of data ...............: Centre(RA,DEC)=(83.5, 22.8) deg, Radius=5 deg + 2017-11-28T14:21:58: Selected RoI ..............: Centre(RA,DEC)=(83.63, 22.01) deg, Radius=3 deg + 2017-11-28T14:21:58: cfitsio selection .........: TIME >= 631109469.18399978 && TIME <= 631111269.18400002 && ENERGY >= 0.10000000 && ENERGY <= 100.00000000 && ANGSEP(83.630000,22.010000,RA,DEC) <= 3.000000 + 2017-11-28T14:21:58: FITS filename .............: /var/tmp/tmp.0.Nc6oWk[EVENTS][TIME >= 631109469.18399978 && TIME <= 631111269.18400002 && ENERGY >= 0.10000000 && ENERGY <= 100.00000000 && ANGSEP(83.630000,22.010000,RA,DEC) <= 3.000000] + 2017-11-28T14:21:58: + 2017-11-28T14:21:58: +====================+ + 2017-11-28T14:21:58: | Output observation | + 2017-11-28T14:21:58: +====================+ + 2017-11-28T14:21:58: === GObservations === + 2017-11-28T14:21:58: Number of observations ....: 1 + 2017-11-28T14:21:58: Number of models ..........: 0 + 2017-11-28T14:21:58: Number of observed events .: 20877 + 2017-11-28T14:21:58: Number of predicted events : 0 + 2017-11-28T14:21:58: + 2017-11-28T14:21:58: +=================+ -From the 202766 events in the input event list 21991 events were selected. + +From the 200833 events in the input event list 20877 events were selected. .. note:: diff --git a/doc/source/users/tutorials/quickstart/simulating.rst b/doc/source/users/tutorials/quickstart/simulating.rst index caab571..0207e62 100644 --- a/doc/source/users/tutorials/quickstart/simulating.rst +++ b/doc/source/users/tutorials/quickstart/simulating.rst @@ -24,18 +24,18 @@ characteristics of the simulation: .. code-block:: bash - $ ctobssim - RA of pointing (degrees) (0-360) [83.63] - Dec of pointing (degrees) (-90-90) [22.01] - Radius of FOV (degrees) (0-180) [5.0] - Start time (UTC string, JD, MJD or MET in seconds) [2020-01-01T00:00:00] - Stop time (UTC string, JD, MJD or MET in seconds) [2020-01-01T00:30:00] 2020-01-01T01:00:00 - Lower energy limit (TeV) [0.03] - Upper energy limit (TeV) [200.0] - Calibration database [prod2] - Instrument response function [South_0.5h] - Input model XML file [$CTOOLS/share/models/crab.xml] - Output event data file or observation definition XML file [events.fits] + $ ctobssim + RA of pointing (degrees) (0-360) [83.63] 83.5 + Dec of pointing (degrees) (-90-90) [22.01] 22.8 + Radius of FOV (degrees) (0-180) [5.0] + Start time (UTC string, JD, MJD or MET in seconds) [2020-01-01T00:00:00] + Stop time (UTC string, JD, MJD or MET in seconds) [2020-01-01T01:00:00] 2020-01-01T01:00:00 + Lower energy limit (TeV) [0.03] + Upper energy limit (TeV) [200.] + Calibration database [prod2] + Instrument response function [South_0.5h] + Input model definition XML file [$CTOOLS/share/models/crab.xml] + Output event data file or observation definition XML file [events.fits] Each line represents a query for one parameter value. The line starts with a short description of the parameter, followed by @@ -160,6 +160,12 @@ where the parameters in the XML definition have the following mappings: convention that can not be modified. So make sure you always use MeV as energy unit in an XML file. + .. note:: + As customary for IACT observations, the pointing direction + was slightly offset from the source of interest, i.e., + the Crab. This makes it possible to better handle systematics due + to the instrumental background. + The instrumental background of CTA is modelled using the background information provided in the :ref:`instrument response function ` @@ -205,33 +211,33 @@ from this file are shown here: .. code-block:: none - 2017-08-08T19:28:54: === CTA observation === - 2017-08-08T19:28:54: Simulation cone ...........: RA=83.63 deg, Dec=22.01 deg, radius=5.5 deg - 2017-08-08T19:28:54: Time interval .............: 6.31109e+08 - 6.31112e+08 s - 2017-08-08T19:28:54: Photon energy range .......: 30 GeV - 72.3622611060088 GeV - 2017-08-08T19:28:54: Event energy range ........: 30 GeV - 72.3622611060088 GeV - 2017-08-08T19:28:54: Simulation area ..........: 1.97769e+09 cm2 - 2017-08-08T19:28:54: Use model ................: Crab - 2017-08-08T19:28:54: Normalization ............: 1 [Crab] - 2017-08-08T19:28:54: Flux .....................: 2.5413e-09 [Crab] photons/cm2/s - 2017-08-08T19:28:54: Normalized flux ..........: 2.5413e-09 [Crab] photons/cm2/s - 2017-08-08T19:28:54: Photon rate ..............: 5.0259 photons/s [Crab] - 2017-08-08T19:28:54: MC source photons ........: 18186 [Crab] - 2017-08-08T19:28:54: MC source events .........: 4175 [Crab] - 2017-08-08T19:28:54: MC source events .........: 4175 (all source models) - 2017-08-08T19:28:54: Photon energy range .......: 72.3622611060088 GeV - 174.543227745807 GeV - ... - 2017-08-08T19:28:54: MC source photons .........: 47371 [Crab] - 2017-08-08T19:28:54: MC source events ..........: 13227 [Crab] - 2017-08-08T19:29:02: MC events outside ROI .....: 0 - 2017-08-08T19:29:02: MC background events ......: 189539 - 2017-08-08T19:29:02: MC identifier 1 ...........: Crab - 2017-08-08T19:29:02: MC identifier 2 ...........: CTABackgroundModel - 2017-08-08T19:29:02: MC events .................: 202766 (all models) + 2017-11-28T14:13:40: === CTA observation === + 2017-11-28T14:13:40: Simulation cone ...........: RA=83.5 deg, Dec=22.8 deg, radius=5.5 deg + 2017-11-28T14:13:40: Time interval .............: 6.31109e+08 - 6.31112e+08 s + 2017-11-28T14:13:40: Photon energy range .......: 30 GeV - 72.3622611060088 GeV + 2017-11-28T14:13:40: Event energy range ........: 30 GeV - 72.3622611060088 GeV + 2017-11-28T14:13:40: Simulation area ..........: 1.97769e+09 cm2 + 2017-11-28T14:13:40: Use model ................: Crab + 2017-11-28T14:13:40: Normalization ............: 1 [Crab] + 2017-11-28T14:13:40: Flux .....................: 2.5413e-09 [Crab] photons/cm2/s + 2017-11-28T14:13:40: Normalized flux ..........: 2.5413e-09 [Crab] photons/cm2/s + 2017-11-28T14:13:40: Photon rate ..............: 5.0259 photons/s [Crab] + 2017-11-28T14:13:40: MC source photons ........: 18186 [Crab] + 2017-11-28T14:13:40: MC source events .........: 3544 [Crab] + 2017-11-28T14:13:40: MC source events .........: 3544 (all source models) + 2017-11-28T14:13:40: Photon energy range .......: 72.3622611060088 GeV - 174.543227745807 GeV + ... + 2017-11-28T14:13:40: MC source photons .........: 47219 [Crab] + 2017-11-28T14:13:40: MC source events ..........: 11356 [Crab] + 2017-11-28T14:13:49: MC events outside ROI .....: 0 + 2017-11-28T14:13:49: MC background events ......: 189477 + 2017-11-28T14:13:49: MC identifier 1 ...........: Crab + 2017-11-28T14:13:49: MC identifier 2 ...........: CTABackgroundModel + 2017-11-28T14:13:49: MC events .................: 200833 (all models) Each line starts with the UTC time at which the line has been written. In -this run, 47371 Crab photons have been thrown. 13227 of these photons have been -registered by CTA as events. In the same time interval, 189539 background +this run, 47219 Crab photons have been thrown. 11356 of these photons have been +registered by CTA as events. In the same time interval, 189477 background events have been registred by CTA. .. note:: diff --git a/doc/source/users/tutorials/quickstart/skymap.jpg b/doc/source/users/tutorials/quickstart/skymap.jpg index d65a80c..d33e285 100644 Binary files a/doc/source/users/tutorials/quickstart/skymap.jpg and b/doc/source/users/tutorials/quickstart/skymap.jpg differ diff --git a/doc/source/users/tutorials/quickstart/skymap.rst b/doc/source/users/tutorials/quickstart/skymap.rst index 0323ced..834e60a 100644 --- a/doc/source/users/tutorials/quickstart/skymap.rst +++ b/doc/source/users/tutorials/quickstart/skymap.rst @@ -24,7 +24,7 @@ this with the :ref:`ctskymap` tool as follows: Size of the Y axis in pixels [200] Lower energy limit (TeV) [0.1] Upper energy limit (TeV) [100.0] - Background subtraction method (NONE|IRF) [NONE] + Background subtraction method (NONE|IRF|RING) [NONE] Output skymap file [skymap.fits] The tool produces the file ``skymap.fits`` which contains a sky map of the @@ -67,7 +67,7 @@ example: Size of the Y axis in pixels [200] Lower energy limit (TeV) [0.1] Upper energy limit (TeV) [100.0] - Background subtraction method (NONE|IRF) [NONE] IRF + Background subtraction method (NONE|IRF|RING) [NONE] IRF Calibration database [prod2] Instrument response function [South_0.5h] Output skymap file [skymap.fits] skymap_subtracted.fits @@ -80,5 +80,63 @@ kernel smoothing applied is shown below: :width: 400px :align: center - *Background subtracted sky map of the selected events* + *Sky map of the selected events with background subtraction from + the IRFs* +If a reliable model of the instrumental background is not available, +you can estimate it from the data by running the :ref:`ctskymap` tool with +the background subtraction method set to `RING``. For each position in +the map the number of background counts is estimated from a ring, +scaled accroding to the acceptance model in the :ref:`instrument +response functions `, and subtracted from a circular +region centred on the trial source region. You need to avoid regions +with significant gamma-ray emission when deriving the background +rates, by providing an exclusion region (`ds9 `_ +region file, or FITS map) through the hidden inexclusion parameter. + +.. code-block:: bash + + $ ctskymap inexclusion=exclusion.reg + Input event list or observation definition XML file [events.fits] selected_events.fits + First coordinate of image center in degrees (RA or galactic l) (0-360) [83.63] + Second coordinate of image center in degrees (DEC or galactic b) (-90-90) [22.01] + Projection method (AIT|AZP|CAR|GLS|MER|MOL|SFL|SIN|STG|TAN) [CAR] + Coordinate system (CEL - celestial, GAL - galactic) (CEL|GAL) [CEL] + Image scale (in degrees/pixel) [0.02] + Size of the X axis in pixels [200] + Size of the Y axis in pixels [200] + Lower energy limit (TeV) [0.1] + Upper energy limit (TeV) [100.0] + Background subtraction method (NONE|IRF|RING) [NONE] RING + Source region radius for estimating on-counts (degrees) [0.0] 0.2 + Inner ring radius (degrees) [0.6] + Outer ring radius (degrees) [0.8] + Calibration database [prod2] + Instrument response function [South_0.5h] + Output skymap file [skymap.fits] skymap_ring.fits + +The exclusion file used contained just a circle centered on the Crab +nebula. + +.. code-block:: bash + + $ less exclusion.reg + # Region file format: DS9 version 4.1 + global color=green dashlist=8 3 width=1 font="helvetica 10 + normal roman" select=1 highlite=1 dash=0 fixed=0 edit=1 move=1 + delete=1 include=1 source=1 + fk5 + circle(83.63,22.01,720.000") + +The resulting sky map, displayed using +`ds9 `_ in logarithmic color scale is shown below. + +.. figure:: skymap_ring.jpg + :width: 400px + :align: center + + *Sky map of the selected events with background subtraction from + the ring method* + +Note that the map thus obtained is smoothed to the scale of the source +region size. diff --git a/doc/source/users/tutorials/quickstart/skymap_ring.jpg b/doc/source/users/tutorials/quickstart/skymap_ring.jpg new file mode 100644 index 0000000..b46e1bc Binary files /dev/null and b/doc/source/users/tutorials/quickstart/skymap_ring.jpg differ diff --git a/doc/source/users/tutorials/quickstart/skymap_subtracted.jpg b/doc/source/users/tutorials/quickstart/skymap_subtracted.jpg index 155eab1..abe8c3b 100644 Binary files a/doc/source/users/tutorials/quickstart/skymap_subtracted.jpg and b/doc/source/users/tutorials/quickstart/skymap_subtracted.jpg differ diff --git a/doc/source/users/tutorials/quickstart/unbinned.rst b/doc/source/users/tutorials/quickstart/unbinned.rst index 258dcd3..b1066c5 100644 --- a/doc/source/users/tutorials/quickstart/unbinned.rst +++ b/doc/source/users/tutorials/quickstart/unbinned.rst @@ -16,11 +16,7 @@ Doing an unbinned analysis An unbinned analysis is generally preferred over a binned analysis for short observation times (a few tens of hours) or if you want to assure - that the analysis results are not biased by the selected binning. Also - the fitting of a light or phase curve is only be possible with an - unbinned maximum likelihood analysis - (see :ref:`light curve <1dc_howto_ligthcurve>` and - :ref:`phase curve <1dc_howto_phasecurve>` fitting). + that the analysis results are not biased by the selected binning. An alternative analysis technique consists of working directly on the event list without binning the events in a counts cube. diff --git a/examples/show_butterfly.py b/examples/show_butterfly.py index c00b677..ba20ff6 100755 --- a/examples/show_butterfly.py +++ b/examples/show_butterfly.py @@ -84,7 +84,7 @@ def plot_butterfly(filename, plotfile): plt.plot(line_x,line_y,color='black',ls='-') plt.fill(butterfly_x,butterfly_y,color='green',alpha=0.5) plt.xlabel('Energy (TeV)') - plt.ylabel(r'E $\times$ dN/dE (erg cm$^{-2}$ s$^{-1}$)') + plt.ylabel(r'E$^2$ $\times$ dN/dE (erg cm$^{-2}$ s$^{-1}$)') # Show spectrum or save it into file if len(plotfile) > 0: -- libgit2 0.21.4