Commit 7b6802068413f46a2b0ab46f79db32375af2cb2d

Authored by Jürgen Knödlseder
2 parents 82ae545c c36b288f

Merge branch 'master' into devel

Showing 83 changed files with 1524 additions and 1444 deletions
ChangeLog
1   -2015-05-20 Juergen Knoedlseder <jurgen.knodlseder@irap.omp.eu>
  1 +2015-05-22 Juergen Knoedlseder <jurgen.knodlseder@irap.omp.eu>
2 2  
3   - * Version 1.0.0 released
  3 + * Version 0.9.0 released
4 4 ========================
5 5  
6   - Adapt to GammaLib 1.0.0 interface
  6 + Adapt to GammaLib 0.10.0 interface
7 7 Do not import automatically Python scripts
8 8 Support INDEF/NONE/UNDEF/UNDEFINED parameters in ctselect
9 9 Modify cssens parameter interface (#1426)
... ...
1   -New Features and Important Changes in ctools 1.0.0
  1 +New Features and Important Changes in ctools 0.9.0
2 2  
3 3 Author(s) : Juergen Knoedlseder
4 4  
5   -20 May 2015
  5 +22 May 2015
6 6  
7 7  
8 8 1. Introduction
... ... @@ -141,7 +141,8 @@ actually returns the differential flux for a given set of energies.
141 141  
142 142 20. caldb
143 143 ---------
144   -None
  144 +Official Prod2 instrument response functions for the Southern and Northern
  145 +array have been added.
145 146  
146 147  
147 148 21. models
... ...
1 1 ctools information
2 2 ==================
3   -Version: 00-08-01 (8 January 2015)
  3 +Version: 0.9.0 (20 May 2015)
4 4 Author: Juergen Knodlseder (jurgen.knodlseder@irap.omp.eu)
5   -GammaLib dependency: 00-09-00
  5 +GammaLib dependency: 0.10.0
6 6  
7 7  
8 8 License information
... ... @@ -34,20 +34,27 @@ for the high-level analysis of astronomical gamma-ray data.
34 34  
35 35 The following tools are available:
36 36  
37   - ctbin - event binning
38   - ctlike - maximum likelihood model fitting
39   - ctmodel - generation of model counts map
40   - ctobssim - simulation of CTA observations
41   - ctselect - event selection
42   - ctskymap - CTA sky mapping tool
  37 + ctbin - event binning
  38 + ctbkgcube - generate a background cube
  39 + ctbutterfly - create a butterfly
  40 + ctcubemask - mask bins in binned analysis
  41 + ctexpcube - generate an exposure cube
  42 + ctlike - maximum likelihood model fitting
  43 + ctmodel - generation of model counts map
  44 + ctobssim - simulation of CTA observations
  45 + ctpsfcube - generate a PSF cube
  46 + ctselect - event selection
  47 + ctskymap - CTA sky mapping tool
  48 + cttsmap - generate a TS map
  49 + ctulimit - compute upper limits
43 50  
44 51  
45 52 Web sites
46 53 =========
47   -http://cta.irap.omp.eu/ctools - ctools documentation
48   -https://cta-redmine.irap.omp.eu/projects/ctools - for ctools development
49   -http://gammalib.sourceforge.net - for GammaLib documentation
50   -https://sourceforge.net/projects/gammalib/ - for GammaLib downloads
  54 +http://cta.irap.omp.eu/ctools - ctools documentation
  55 +https://cta-redmine.irap.omp.eu/projects/ctools - for ctools development
  56 +https://cta-redmine.irap.omp.eu/projects/gammalib - for GammaLib documentation
  57 +https://sourceforge.net/projects/gammalib/ - for GammaLib downloads
51 58  
52 59  
53 60 Prerequisites
... ...
caldb/Makefile.am
1 1 ## Process this file with automake to produce Makefile.in
2 2  
3 3 # Calibration files to distribute
4   -caldb_indx = caldb.indx
5   -caldb_irf = cta_dummy_irf.dat
6   -
7   -# Distribute calibration database files
8   -EXTRA_DIST = $(caldb_indx) $(caldb_irf)
9   -caldbindxdir = $(datadir)/caldb/data/cta/dummy
10   -caldbindx_DATA = $(caldb_indx)
11   -caldbirfdir = $(datadir)/caldb/data/cta/dummy/bcf
12   -caldbirf_DATA = $(caldb_irf)
  4 +caldb_prod2_indxdir = $(datadir)/caldb/data/cta/prod2
  5 +caldb_prod2_indx_DATA = data/cta/prod2/caldb.indx
  6 +caldb_prod2_north1dir = $(datadir)/caldb/data/cta/prod2/bcf/North_0.5h
  7 +caldb_prod2_north1_DATA = data/cta/prod2/bcf/North_0.5h/irf_file.fits.gz
  8 +caldb_prod2_north2dir = $(datadir)/caldb/data/cta/prod2/bcf/North_5h
  9 +caldb_prod2_north2_DATA = data/cta/prod2/bcf/North_5h/irf_file.fits.gz
  10 +caldb_prod2_north3dir = $(datadir)/caldb/data/cta/prod2/bcf/North_50h
  11 +caldb_prod2_north3_DATA = data/cta/prod2/bcf/North_50h/irf_file.fits.gz
  12 +#
  13 +caldb_prod2_south1dir = $(datadir)/caldb/data/cta/prod2/bcf/South_0.5h
  14 +caldb_prod2_south1_DATA = data/cta/prod2/bcf/South_0.5h/irf_file.fits.gz
  15 +caldb_prod2_south2dir = $(datadir)/caldb/data/cta/prod2/bcf/South_5h
  16 +caldb_prod2_south2_DATA = data/cta/prod2/bcf/South_5h/irf_file.fits.gz
  17 +caldb_prod2_south3dir = $(datadir)/caldb/data/cta/prod2/bcf/South_50h
  18 +caldb_prod2_south3_DATA = data/cta/prod2/bcf/South_50h/irf_file.fits.gz
... ...
caldb/caldb.indx deleted
No preview for this file type
caldb/cta_dummy_irf.dat deleted
1   -log(E) Area r68 r80 ERes. BG Rate Diff Sens
2   --1.7 261.6 0.3621 0.4908 0.5134 1.89924e-02 6.88237e-11
3   --1.5 5458.2 0.2712 0.3685 0.4129 1.00972e-01 1.72717e-11
4   --1.3 15590.0 0.1662 0.2103 0.2721 5.75623e-02 6.16963e-12
5   --1.1 26554.1 0.1253 0.1567 0.2611 2.13008e-02 2.89932e-12
6   --0.9 52100.5 0.1048 0.1305 0.1987 8.87292e-03 1.39764e-12
7   --0.7 66132.1 0.0827 0.1024 0.1698 1.09756e-03 6.03531e-13
8   --0.5 108656.8 0.0703 0.0867 0.1506 4.84287e-04 3.98147e-13
9   --0.3 129833.0 0.0585 0.0722 0.1338 1.57546e-04 3.23090e-13
10   --0.1 284604.3 0.0531 0.0656 0.1008 1.36703e-04 2.20178e-13
11   -0.1 263175.3 0.0410 0.0506 0.0831 2.09694e-05 1.87452e-13
12   -0.3 778048.6 0.0470 0.0591 0.0842 6.92374e-05 1.53976e-13
13   -0.5 929818.8 0.0391 0.0492 0.0650 1.45844e-05 1.18947e-13
14   -0.7 1078450.0 0.0335 0.0415 0.0541 1.15959e-05 1.51927e-13
15   -0.9 1448579.1 0.0317 0.0397 0.0516 4.71231e-06 1.42439e-13
16   -1.1 1899905.0 0.0290 0.0372 0.0501 8.14997e-06 1.96670e-13
17   -1.3 2476403.8 0.0285 0.0367 0.0538 5.91940e-06 2.20695e-13
18   -1.5 2832570.6 0.0284 0.0372 0.0636 7.33847e-06 3.22523e-13
19   -1.7 3534065.3 0.0290 0.0386 0.0731 1.34549e-05 4.84153e-13
20   -1.9 3250103.4 0.0238 0.0308 0.0729 4.42228e-06 6.26265e-13
21   -2.1 3916071.6 0.0260 0.0354 0.0908 2.26648e-06 7.69921e-13
22   ----------------------------------------------
23   -Notes
24   - 1) log(E) = log10(E/TeV) - bin centre
25   - 2) Eff Area - in square metres after background cut (no theta cut)
26   - 3) Ang. Res - 68% containment radius of gamma-ray PSF post cuts - in degrees
27   - 4) Ang. Res - 80% containment radius of gamma-ray PSF post cuts - in degrees
28   - 5) Fractional Energy Resolution (rms)
29   - 6) BG Rate - inside point-source selection region - post call cuts - in Hz
30   - 7) Diff Sens - differential sensitivity for this bin expressed as E^2 dN/dE
31   - - in erg cm^-2 s^-1 - for a 50 hours exposure - 5 sigma significance including
32   - systematics and statistics and at least 10 photons.
caldb/data/cta/prod2/bcf/North_0.5h/irf_file.fits.gz 0 → 100644
No preview for this file type
caldb/data/cta/prod2/bcf/North_50h/irf_file.fits.gz 0 → 100644
No preview for this file type
caldb/data/cta/prod2/bcf/North_5h/irf_file.fits.gz 0 → 100644
No preview for this file type
caldb/data/cta/prod2/bcf/South_0.5h/irf_file.fits.gz 0 → 100644
No preview for this file type
caldb/data/cta/prod2/bcf/South_50h/irf_file.fits.gz 0 → 100644
No preview for this file type
caldb/data/cta/prod2/bcf/South_5h/irf_file.fits.gz 0 → 100644
No preview for this file type
caldb/data/cta/prod2/caldb.indx 0 → 100644
No preview for this file type
configure.ac
... ... @@ -29,7 +29,7 @@
29 29 #############################################################################
30 30 # Initialisation #
31 31 #############################################################################
32   -AC_INIT([ctools], [1.0.0], [jurgen.knodlseder@irap.omp.eu], [ctools])
  32 +AC_INIT([ctools], [0.9.0], [jurgen.knodlseder@irap.omp.eu], [ctools])
33 33 AC_CONFIG_SRCDIR([src/ctselect/ctselect.cpp])
34 34 AC_CONFIG_MACRO_DIR([m4])
35 35 #AM_INIT_AUTOMAKE([gnu no-dependencies])
... ...
ctools.pc.in
... ... @@ -6,9 +6,9 @@ includedir=${prefix}/include
6 6 Name: ctools
7 7 Description: CTA science analysis tools
8 8 URL: http://cta.irap.omp.eu/ctools
9   -Version: 1.0.0
  9 +Version: 0.9.0
10 10 Requires:
11   -Requires.private: gammalib >= 1.0.0
  11 +Requires.private: gammalib >= 0.10.0
12 12 Conflicts:
13 13 Cflags: -I${includedir}/ctools @OPENMP_CXXFLAGS@
14 14 Libs: -L${libdir} -lctools
... ...
doc/Doxyfile
... ... @@ -32,7 +32,7 @@ PROJECT_NAME = ctools
32 32 # This could be handy for archiving the generated documentation or
33 33 # if some version control system is used.
34 34  
35   -PROJECT_NUMBER = 1.0.0
  35 +PROJECT_NUMBER = 0.9.0
36 36  
37 37 # Using the PROJECT_BRIEF tag one can provide an optional one line description
38 38 # for a project that appears at the top of each page and should give viewer
... ...
doc/source/conf.py
... ... @@ -66,10 +66,10 @@ copyright = u&#39;2014-2015, ctools developers&#39;
66 66 # built documents.
67 67 #
68 68 # The short X.Y version.
69   -version = '1.0'
  69 +version = '0.9'
70 70  
71 71 # The full version, including alpha/beta/rc tags.
72   -release = '1.0.0'
  72 +release = '0.9.0'
73 73  
74 74 # The language for content autogenerated by Sphinx. Refer to documentation
75 75 # for a list of supported languages.
... ...
doc/source/download.rst
... ... @@ -13,7 +13,7 @@ bugs.
13 13 Releases
14 14 --------
15 15  
16   -The latest ctools release is ``ctools-00-08-01`` (8 January 2015).
  16 +The latest ctools release is ``ctools-0.9.0`` (22 May 2015).
17 17  
18 18 Below a table of ctools releases. Please note that at this stage of the
19 19 project there is a strict link between the ctools and gammalib versions.
... ... @@ -28,6 +28,9 @@ gammalib.
28 28 * - `ctools <http://cta.irap.omp.eu/ctools/releases/ctools/ChangeLog>`_
29 29 - `gammalib <http://cta.irap.omp.eu/ctools/releases/gammalib/ChangeLog>`_
30 30 - Mac OS X package
  31 + * - `0.9.0 <http://cta.irap.omp.eu/ctools/releases/ctools/ctools-0.9.0.tar.gz>`_
  32 + - `0.10.0 <http://cta.irap.omp.eu/ctools/releases/gammalib/gammalib-0.10.0.tar.gz>`_
  33 + - `ctools-0.9.0-macosx10.3.dmg <http://cta.irap.omp.eu/ctools/releases/ctools/ctools-0.9.0-macosx10.3.dmg>`_
31 34 * - `0.8.1 <http://cta.irap.omp.eu/ctools/releases/ctools/ctools-00-08-01.tar.gz>`_
32 35 - `0.9.1 <http://cta.irap.omp.eu/ctools/releases/gammalib/gammalib-00-09-01.tar.gz>`_
33 36 - `ctools-00-08-01-macosx10.3.dmg <http://cta.irap.omp.eu/ctools/releases/ctools/ctools-00-08-01-macosx10.3.dmg>`_
... ...
doc/source/reference_manual/cslightcrv.rst 0 → 100644
  1 +.. _cslightcrv:
  2 +
  3 +cslightcrv
  4 +==========
  5 +
  6 +Computes a lightcurve for a given source.
  7 +
  8 +
  9 +Synopsis
  10 +--------
  11 +
  12 +Computes a lightcurve for a given source.
  13 +
  14 +
  15 +General parameters
  16 +------------------
  17 +
  18 +``(inobs = NONE) [file]``
  19 + Input event list, counts cube or observation definition XML file.
  20 +
  21 +``inmodel [file]``
  22 + Input source model XML file.
  23 +
  24 +``srcname [string]``
  25 + Name of the source in the source model XML file which should be used
  26 + for sensitivity computation.
  27 +
  28 +``outfile [file]``
  29 + Name of the source spectrum output file.
  30 +
  31 +``expcube [file]``
  32 + Exposure cube file (only needed for stacked analysis).
  33 +
  34 +``psfcube [file]``
  35 + PSF cube file (only needed for stacked analysis).
  36 +
  37 +``bkgcube [file]``
  38 + Background cube file (only needed for stacked analysis).
  39 +
  40 +``caldb [string]``
  41 + Calibration database.
  42 +
  43 +``irf [string]``
  44 + Instrumental response function.
  45 +
  46 +``tmin [real]``
  47 + Lightcurve start time (in MJD).
  48 +
  49 +``tmax [real]``
  50 + Lightcurve stop time (in MJD).
  51 +
  52 +``tbins [integer]``
  53 + Number of time bins.
  54 +
  55 +``(tbinalg = GTI) <FILE|LIN|GTI> [string]``
  56 + Algorithm for defining time bins.
  57 +
  58 +``tbinfile [file]``
  59 + File defining the time binning.
  60 +
  61 +``binned [boolean]``
  62 + Use binned analysis in each time bin.
  63 +
  64 +``enumbins [integer]``
  65 + Number of energy bins per light curve bin (0=unbinned).
  66 +
  67 +``emin [real]``
  68 + Lower energy limit of events (in TeV).
  69 +
  70 +``emax [real]``
  71 + Upper energy limit of events (in TeV).
  72 +
  73 +``coordsys <CEL|GAL> [string]``
  74 + Coordinate system (CEL - celestial, GAL - galactic).
  75 +
  76 +``proj <AIT|AZP|CAR|MER|MOL|STG|TAN> [string]``
  77 + Projection method.
  78 +
  79 +``xref [real]``
  80 + Right Ascension / Galactic longitude of image centre (J2000, in degrees).
  81 +
  82 +``yref [real]``
  83 + Declination / Galactic latitude of image centre (J2000, in degrees).
  84 +
  85 +``nxpix [integer]``
  86 + Size of the Right Ascension / Galactic longitude axis (in pixels).
  87 +
  88 +``nypix [integer]``
  89 + Size of the Declination / Galactic latitude axis (in pixels).
  90 +
  91 +``binsz [real]``
  92 + Pixel size (in degrees/pixel).
  93 +
  94 +``(calc_ts = yes) [boolean]``
  95 + Compute TS value for each time bin?
  96 +
  97 +``(calc_ulim = yes) [boolean]``
  98 + Compute upper limit for each time bin?
  99 +
  100 +``(fix_srcs = yes) [boolean]``
  101 + Fix other sky model parameters?
  102 +
  103 +``(fix_bkg = no) [boolean]``
  104 + Fix background model parameters?
  105 +
  106 +
  107 +Standard parameters
  108 +-------------------
  109 +
  110 +``(chatter = 2) [integer]``
  111 + Verbosity of the executable:
  112 + chatter = 0: no information will be logged
  113 +
  114 + chatter = 1: only errors will be logged
  115 +
  116 + chatter = 2: errors and actions will be logged
  117 +
  118 + chatter = 3: report about the task execution
  119 +
  120 + chatter = 4: detailed report about the task execution
  121 +
  122 +``(clobber = yes) [boolean]``
  123 + Specifies whether an existing output counts cube should be overwritten.
  124 +
  125 +``(debug = no) [boolean]``
  126 + Enables debug mode. In debug mode the executable will dump any log file output to the console.
  127 +
  128 +``(mode = ql) [string]``
  129 + Mode of automatic parameters (default is "ql", i.e. "query and learn").
  130 +
  131 +``(logfile = cslightcrv.log) [filename]``
  132 + Log filename.
  133 +
  134 +
  135 +Related tools
  136 +-------------
  137 +
  138 +None
... ...
doc/source/reference_manual/csobsdef.rst
... ... @@ -45,9 +45,9 @@ Here some usage examples:
45 45 ``csobsdef rad=5``
46 46 Creates observation definition file with a ROI radius of 5 deg.
47 47  
48   -``csobsdef caldb=dummy irf=cta_dummy_irf``
49   - Creates observation definition file using the "cta_dummy_irf" IRF in the
50   - "dummy" calibration database.
  48 +``csobsdef caldb=prod2 irf=South_50h``
  49 + Creates observation definition file using the "South_50h" IRF in the
  50 + "prod2" calibration database.
51 51  
52 52  
53 53 General parameters
... ...
doc/source/reference_manual/cspull.rst
... ... @@ -41,6 +41,9 @@ General parameters
41 41 ``irf [string]``
42 42 Instrumental response function.
43 43  
  44 +``(deadc = 0.95) [real]``
  45 + Average deadtime correction factor.
  46 +
44 47 ``(edisp = no) [boolean]``
45 48 Apply energy dispersion to response computation.
46 49  
... ... @@ -62,12 +65,18 @@ General parameters
62 65 ``enumbins [integer]``
63 66 Number of energy bins (0=unbinned).
64 67  
65   -``duration [real]``
66   - Duration of observation (in seconds).
  68 +``(tmin = 0.0) [real]``
  69 + Start time (in seconds).
67 70  
68   -``(deadc = 0.95) [real]``
69   - Average deadtime correction factor.
  71 +``tmax [real]``
  72 + Stop time (in seconds).
  73 +
  74 +``npix [integer]``
  75 + Number of pixels for binned analysis.
70 76  
  77 +``binsz [real]``
  78 + Pixel size for binned analysis.
  79 +
71 80 ``(rad = 5.0) [real]``
72 81 ROI radius (in degrees).
73 82  
... ... @@ -77,12 +86,6 @@ General parameters
77 86 ``(offset = 1.5) [real]``
78 87 Observation pattern offset (in degrees).
79 88  
80   -``(npix = 200) [integer]``
81   - Number of pixels for binned analysis.
82   -
83   -``(binsz = 0.05) [real]``
84   - Pixel size for binned analysis.
85   -
86 89  
87 90 Standard parameters
88 91 -------------------
... ... @@ -108,6 +111,9 @@ Standard parameters
108 111 ``(mode = ql) [string]``
109 112 Mode of automatic parameters (default is "ql", i.e. "query and learn").
110 113  
  114 +``(logfile = cspull.log) [string]``
  115 + Log filename.
  116 +
111 117  
112 118 Related tools
113 119 -------------
... ...
doc/source/reference_manual/csspec.rst
... ... @@ -83,16 +83,16 @@ General parameters
83 83 Pixel size (in degrees/pixel).
84 84  
85 85 ``(calc_ts = yes) [boolean]``
86   - Compute TS for each spectral point.
  86 + Compute TS for each spectral point?
87 87  
88 88 ``(calc_ulim = yes) [boolean]``
89   - Compute upper limit for each spectral point.
  89 + Compute upper limit for each spectral point?
90 90  
91 91 ``(fix_srcs = yes) [boolean]``
92   - Fix other sky model parameters.
  92 + Fix other sky model parameters?
93 93  
94 94 ``(fix_bkg = no) [boolean]``
95   - Fix background parameters.
  95 + Fix background model parameters?
96 96  
97 97  
98 98 Standard parameters
... ...
doc/source/reference_manual/cstsdist.rst
... ... @@ -16,30 +16,49 @@ Monte-Carlo simulations.
16 16 General parameters
17 17 ------------------
18 18  
19   -``(outfile = ts.dat) [file]``
  19 +``(inobs = NONE) [file]``
  20 + Input event list, counts cube or observation definition XML file.
  21 +
  22 +``inmodel [file]``
  23 + Input source model XML file.
  24 +
  25 +``srcname [string]``
  26 + Name of the source in the source model XML file which should be used
  27 + for sensitivity computation.
  28 +
  29 +``outfile [file]``
20 30 ASCII file containing the TS distribution values.
21   -
22   -``ntrials [integer]``
23   - Number of Monte Carlo samples.
24   -
  31 +
  32 +``expcube [file]``
  33 + Exposure cube file (only needed for stacked analysis).
  34 +
  35 +``psfcube [file]``
  36 + PSF cube file (only needed for stacked analysis).
  37 +
  38 +``bkgcube [file]``
  39 + Background cube file (only needed for stacked analysis).
  40 +
25 41 ``caldb [string]``
26 42 Calibration database.
27 43  
28 44 ``irf [string]``
29 45 Instrumental response function.
30 46  
31   -``type <point|gauss|shell|disk> [string]``
32   - Source model type.
33   -
34   -``(index = -2.48) [real]``
35   - Spectral index for source model.
36   -
37   -``offset [real]``
38   - Source offset angle (in degrees).
39   -
40   -``bkg [string]``
41   - Background model file function (none=power law for subarray E).
  47 +``(deadc = 0.95) [real]``
  48 + Average deadtime correction factor.
  49 +
  50 +``(edisp = no) [boolean]``
  51 + Apply energy dispersion to response computation.
  52 +
  53 +``ntrials [integer]``
  54 + Number of Monte Carlo samples.
  55 +
  56 +``ra [real]``
  57 + Right Ascension of CTA pointing (J2000, in degrees).
42 58  
  59 +``dec [real]``
  60 + Declination of CTA pointing (J2000, in degrees).
  61 +
43 62 ``emin [real]``
44 63 Lower energy limit (in TeV).
45 64  
... ... @@ -49,18 +68,27 @@ General parameters
49 68 ``enumbins [integer]``
50 69 Number of energy bins (0=unbinned).
51 70  
52   -``duration [real]``
53   - Effective exposure time (in seconds).
  71 +``(tmin = 0.0) [real]``
  72 + Start time (in seconds).
54 73  
55   -``(rad = 5.0) [real]``
56   - Radius of ROI (in degrees).
  74 +``tmax [real]``
  75 + Stop time (in seconds).
57 76  
58   -``(npix = 200) [integer]``
  77 +``npix [integer]``
59 78 Number of pixels for binned analysis.
60 79  
61   -``(binsz = 0.05) [real]``
  80 +``binsz [real]``
62 81 Pixel size for binned analysis.
63 82  
  83 +``(rad = 5.0) [real]``
  84 + Radius of ROI (in degrees).
  85 +
  86 +``(pattern = single) [string]``
  87 + Pattern for pointing simulation (single/four).
  88 +
  89 +``(offset = 1.5) [real]``
  90 + Observation pattern offset (in degrees).
  91 +
64 92  
65 93 Standard parameters
66 94 -------------------
... ... @@ -86,6 +114,9 @@ Standard parameters
86 114 ``(mode = ql) [string]``
87 115 Mode of automatic parameters (default is "ql", i.e. "query and learn").
88 116  
  117 +``(logfile = cstsdist.log) [string]``
  118 + Log filename.
  119 +
89 120  
90 121 Related tools
91 122 -------------
... ...
doc/source/reference_manual/index.rst
... ... @@ -38,6 +38,7 @@ cscripts
38 38  
39 39 cscaldb --- Lists available instrument response functions <cscaldb>
40 40 csobsdef --- Generates observation definition file <csobsdef>
  41 + cslightcrv --- Computes lightcurve <cslightcrv>
41 42 cspull --- Generates pull distribution <cspull>
42 43 cssens --- Computes CTA sensitivity <cssens>
43 44 csspec --- Computes spectral points <csspec>
... ...
doc/source/reference_manual/usage.rst
... ... @@ -26,7 +26,7 @@ Examples
26 26 ``infile [file]``
27 27 Describes an automatic (queried) file-type parameter with no default value.
28 28  
29   -``irf = kb_E_50h_v3 <kb_E_50h_v3|kb_H_50h_v3> [string]``
  29 +``irf = South_50h <North_50h|South_50h> [string]``
30 30 Describes an automatic (queried) string-type parameter with two value
31 31 options.
32 32  
... ... @@ -39,4 +39,4 @@ Examples
39 39 To set hidden parameters at runtime, specify them explicitly at
40 40 the command line; for example:
41 41  
42   - ``gtobssim start_time=900``
  42 + ``ctobssim start_time=900``
... ...
doc/source/user_manual/enhancing.rst
... ... @@ -14,5 +14,10 @@ The following C++ and Python examples can help get you started:
14 14 Building your own cscripts
15 15 --------------------------
16 16  
  17 +To be written ...
  18 +
  19 +
17 20 Building your own ctools
18 21 ------------------------
  22 +
  23 +To be written ...
... ...
doc/source/user_manual/expert.rst
... ... @@ -4,8 +4,16 @@ Behind the scenes
4 4 CTA data structure
5 5 ------------------
6 6  
  7 +To be written ...
  8 +
  9 +
7 10 Instrument response functions
8 11 -----------------------------
9 12  
  13 +To be written ...
  14 +
  15 +
10 16 Maximum likelihood fitting
11   ---------------------------
12 17 \ No newline at end of file
  18 +--------------------------
  19 +
  20 +To be written ...
... ...
doc/source/user_manual/getting.rst
... ... @@ -31,7 +31,7 @@ Installing gammalib
31 31 ctools is built on top of gammalib, hence gammalib needs to be built,
32 32 installed and configured before ctools can be installed. In case that
33 33 ctools is already installed on your system you may skip reading this
34   -section and continue with Section TBD that explains how to install ctools.
  34 +section and continue with the :ref:`sec_building_ctools` section.
35 35  
36 36 You will need the following to build the gammalib:
37 37  
... ... @@ -59,7 +59,7 @@ in an appropriate location (for example ``$HOME/builds``), and type
59 59  
60 60 .. code-block:: bash
61 61  
62   - $ tar xvfz gammalib-1.0.0.tar.gz
  62 + $ tar xvfz gammalib-0.10.0.tar.gz
63 63  
64 64 (the ``$`` symbol indicates the console prompt and is not part of the
65 65 command that you should type in).
... ... @@ -69,7 +69,7 @@ typing
69 69  
70 70 .. code-block:: bash
71 71  
72   - $ cd gammalib-1.0.0
  72 + $ cd gammalib-0.10.0
73 73 $ ./configure
74 74 $ make
75 75 $ make check
... ... @@ -117,6 +117,8 @@ If you use C shell or a variant then add the following to your
117 117 source $GAMMALIB/bin/gammalib-init.csh
118 118  
119 119  
  120 +.. _sec_building_ctools:
  121 +
120 122 Building ctools
121 123 ---------------
122 124  
... ... @@ -125,7 +127,7 @@ an appropriate location (for example ``$HOME/builds``), and type
125 127  
126 128 .. code-block:: bash
127 129  
128   - $ tar xvfz ctools-1.0.0.tar.gz
  130 + $ tar xvfz ctools-0.9.0.tar.gz
129 131  
130 132 (the ``$`` symbol indicates the console prompt and is not part of the
131 133 command that you should type in).
... ... @@ -134,7 +136,7 @@ Step in the directory and build the ctools by typing
134 136  
135 137 .. code-block:: bash
136 138  
137   - $ cd ctools-1.0.0
  139 + $ cd ctools-0.9.0
138 140 $ ./configure
139 141 $ make
140 142  
... ... @@ -171,7 +173,7 @@ following output at the end of the unit testing:
171 173 PASS: test_python.py
172 174 make[4]: Nothing to be done for `all'.
173 175 ============================================================================
174   - Testsuite summary for ctools 1.0.0
  176 + Testsuite summary for ctools 0.9.0
175 177 ============================================================================
176 178 # TOTAL: 3
177 179 # PASS: 3
... ... @@ -189,26 +191,33 @@ For older automake version, you should see
189 191 ***************
190 192 * Test ctools *
191 193 ***************
192   - Test ctobssim: .... ok
  194 + Test ctobssim: .. ok
193 195 Test ctskymap: .. ok
194 196 Test ctbin: .... ok
195   - Test ctmodel: ...... ok
196   - Test ctselect: .. ok
197   - Test ctlike: ........ ok
198   - Test cttsmap: .. ok
199 197 Test ctexpcube: .... ok
200 198 Test ctpsfcube: .... ok
201 199 Test ctbkgcube: ...... ok
  200 + Test ctmodel: ...... ok
  201 + Test ctselect: .. ok
  202 + Test ctlike: ...... ok
  203 + Test cttsmap: .. ok
202 204 Test ctcubemask: .. ok
203 205 Test ctbutterfly: .. ok
  206 + Test ctulimit: .. ok
204 207 PASS: test_ctools.sh
205 208  
206 209 *****************
207 210 * Test cscripts *
208 211 *****************
  212 + Test csobsdef: .. ok
209 213 Test cspull: .. ok
  214 + Test cssens: .. ok
210 215 Test cstsdist: .. ok
211 216 Test csresmap: .. ok
  217 + Test csspec (unbinned): .. ok
  218 + Test csspec (binned): .. ok
  219 + Test cslightcrv (unbinned): .. ok
  220 + Test cslightcrv (binned): .. ok
212 221 PASS: test_cscripts.sh
213 222  
214 223 ***********************
... ... @@ -227,6 +236,7 @@ For older automake version, you should see
227 236 Test ctbkgcube functionality: ... ok
228 237 Test ctcubemask functionality: ... ok
229 238 Test ctbutterfly functionality: ... ok
  239 + Test ctulimit functionality: ... ok
230 240 Test unbinned pipeline with FITS file saving: .... ok
231 241 Test unbinned in-memory pipeline: .... ok
232 242 PASS: test_python.py
... ... @@ -307,9 +317,8 @@ GammaLib unit tests fail
307 317  
308 318 Some users have reported failure of a large fraction of the GammaLib unit
309 319 tests after after typing ``make check``. In all cases, this was related to
310   -the absence of the directory where the shared ``libcfitsio`` library
311   -resides in the library load path. To solve the issue, locate the directory
312   -where the shared ``libcfitsio`` library resides and then type
  320 +not finding the ``libcfitsio`` library. To solve the issue, locate the
  321 +directory where the shared ``libcfitsio`` library resides and then type
313 322  
314 323 .. code-block:: bash
315 324  
... ...
doc/source/user_manual/getting_started/beyond_combine.rst
... ... @@ -20,12 +20,12 @@ nebula, each offset by 0.5 deg from the nebula in opposite directions:
20 20 RA of pointing (degrees) (0-360) [83.63]
21 21 Dec of pointing (degrees) (-90-90) [22.01] 21.51
22 22 Radius of FOV (degrees) (0-180) [5.0]
23   - Start time (MET in s) (0) [0.0]
24   - End time (MET in s) (0) [1800.0]
25   - Lower energy limit (TeV) (0) [0.1]
26   - Upper energy limit (TeV) (0) [100.0]
27   - Calibration database [dummy]
28   - Instrument response function [cta_dummy_irf]
  23 + Start time (MET in s) [0.0]
  24 + End time (MET in s) [1800.0]
  25 + Lower energy limit (TeV) [0.1]
  26 + Upper energy limit (TeV) [100.0]
  27 + Calibration database [prod2]
  28 + Instrument response function [South_50h]
29 29 Model [$CTOOLS/share/models/crab.xml]
30 30 Output event data file or observation definition file [events.fits] events1.fits
31 31  
... ... @@ -35,12 +35,12 @@ nebula, each offset by 0.5 deg from the nebula in opposite directions:
35 35 RA of pointing (degrees) (0-360) [83.63]
36 36 Dec of pointing (degrees) (-90-90) [21.51] 22.51
37 37 Radius of FOV (degrees) (0-180) [5.0]
38   - Start time (MET in s) (0) [0.0]
39   - End time (MET in s) (0) [1800.0]
40   - Lower energy limit (TeV) (0) [0.1]
41   - Upper energy limit (TeV) (0) [100.0]
42   - Calibration database [dummy]
43   - Instrument response function [cta_dummy_irf]
  38 + Start time (MET in s) [0.0]
  39 + End time (MET in s) [1800.0]
  40 + Lower energy limit (TeV) [0.1]
  41 + Upper energy limit (TeV) [100.0]
  42 + Calibration database [prod2]
  43 + Instrument response function [South_50h]
44 44 Model [$CTOOLS/share/models/crab.xml]
45 45 Output event data file or observation definition file [events1.fits] events2.fits
46 46  
... ... @@ -92,11 +92,11 @@ Now we are ready to do a joint maximum likelihood analysis using
92 92 .. code-block:: bash
93 93  
94 94 $ ctlike
95   - Event list, counts cube or observation definition file [events.fits] obs.xml
96   - Calibration database [dummy]
97   - Instrument response function [cta_dummy_irf]
  95 + Event list, counts cube or observation definition file [selected_events.fits] obs.xml
  96 + Calibration database [prod2]
  97 + Instrument response function [South_50h]
98 98 Source model [$CTOOLS/share/models/crab.xml]
99   - Source model output file [crab_results.xml]
  99 + Source model output file [crab_results.xml]
100 100  
101 101 Instead of providing an event list or a counts cube, we now provided the
102 102 filename of the observation definition XML file (here ``obs.xml``) as input
... ... @@ -106,102 +106,96 @@ joint analysis, as indicated in the log file:
106 106  
107 107 .. code-block:: xml
108 108  
109   - 2015-02-04T20:33:26: +==============+
110   - 2015-02-04T20:33:26: | Observations |
111   - 2015-02-04T20:33:26: +==============+
112   - 2015-02-04T20:33:26: === GObservations ===
113   - 2015-02-04T20:33:26: Number of observations ....: 2
114   - 2015-02-04T20:33:26: Number of predicted events : 0
115   - 2015-02-04T20:33:26: === GCTAObservation ===
116   - 2015-02-04T20:33:26: Name ......................: Crab
117   - 2015-02-04T20:33:26: Identifier ................: 00001
118   - 2015-02-04T20:33:26: Instrument ................: CTA
119   - 2015-02-04T20:33:26: Event file ................: events1.fits
120   - 2015-02-04T20:33:26: Event type ................: EventList
121   - 2015-02-04T20:33:26: Statistics ................: Poisson
122   - 2015-02-04T20:33:26: Ontime ....................: 1800 s
123   - 2015-02-04T20:33:26: Livetime ..................: 1710 s
124   - 2015-02-04T20:33:26: Deadtime correction .......: 0.95
125   - 2015-02-04T20:33:26: User energy range .........: undefined
126   - 2015-02-04T20:33:26: === GCTAPointing ===
127   - 2015-02-04T20:33:26: Pointing direction ........: (RA,Dec)=(83.63,21.51)
  109 + 2015-05-22T20:17:07: +==============+
  110 + 2015-05-22T20:17:07: | Observations |
  111 + 2015-05-22T20:17:07: +==============+
  112 + 2015-05-22T20:17:07: === GObservations ===
  113 + 2015-05-22T20:17:07: Number of observations ....: 2
  114 + 2015-05-22T20:17:07: Number of predicted events : 0
  115 + 2015-05-22T20:17:07: === GCTAObservation ===
  116 + 2015-05-22T20:17:07: Name ......................:
  117 + 2015-05-22T20:17:07: Identifier ................: 00001
  118 + 2015-05-22T20:17:07: Instrument ................: CTA
  119 + 2015-05-22T20:17:07: Event file ................: events1.fits
  120 + 2015-05-22T20:17:07: Event type ................: EventList
  121 + 2015-05-22T20:17:07: Statistics ................: Poisson
  122 + 2015-05-22T20:17:07: Ontime ....................: 1800 s
  123 + 2015-05-22T20:17:07: Livetime ..................: 1710 s
  124 + 2015-05-22T20:17:07: Deadtime correction .......: 0.95
  125 + 2015-05-22T20:17:07: User energy range .........: undefined
  126 + 2015-05-22T20:17:07: === GCTAPointing ===
  127 + 2015-05-22T20:17:07: Pointing direction ........: (RA,Dec)=(83.63,21.51)
128 128 ...
129   - 2015-02-04T20:33:26: === GCTAObservation ===
130   - 2015-02-04T20:33:26: Name ......................: Crab
131   - 2015-02-04T20:33:26: Identifier ................: 00002
132   - 2015-02-04T20:33:26: Instrument ................: CTA
133   - 2015-02-04T20:33:26: Event file ................: events2.fits
134   - 2015-02-04T20:33:26: Event type ................: EventList
135   - 2015-02-04T20:33:26: Statistics ................: Poisson
136   - 2015-02-04T20:33:26: Ontime ....................: 1800 s
137   - 2015-02-04T20:33:26: Livetime ..................: 1710 s
138   - 2015-02-04T20:33:26: Deadtime correction .......: 0.95
139   - 2015-02-04T20:33:26: User energy range .........: undefined
140   - 2015-02-04T20:33:26: === GCTAPointing ===
141   - 2015-02-04T20:33:26: Pointing direction ........: (RA,Dec)=(83.63,22.51)
  129 + 2015-05-22T20:17:07: === GCTAObservation ===
  130 + 2015-05-22T20:17:07: Name ......................:
  131 + 2015-05-22T20:17:07: Identifier ................: 00002
  132 + 2015-05-22T20:17:07: Instrument ................: CTA
  133 + 2015-05-22T20:17:07: Event file ................: events2.fits
  134 + 2015-05-22T20:17:07: Event type ................: EventList
  135 + 2015-05-22T20:17:07: Statistics ................: Poisson
  136 + 2015-05-22T20:17:07: Ontime ....................: 1800 s
  137 + 2015-05-22T20:17:07: Livetime ..................: 1710 s
  138 + 2015-05-22T20:17:07: Deadtime correction .......: 0.95
  139 + 2015-05-22T20:17:07: User energy range .........: undefined
  140 + 2015-05-22T20:17:07: === GCTAPointing ===
  141 + 2015-05-22T20:17:07: Pointing direction ........: (RA,Dec)=(83.63,22.51)
142 142 ...
143   - 2015-02-04T20:33:26: +=================================+
144   - 2015-02-04T20:33:26: | Maximum likelihood optimisation |
145   - 2015-02-04T20:33:26: +=================================+
146   - 2015-02-04T20:33:26: >Iteration 0: -logL=89099.788, Lambda=1.0e-03
147   - 2015-02-04T20:33:26: >Iteration 1: -logL=89094.435, Lambda=1.0e-03, delta=5.353, max(|grad|)=-4.388872 [Normalization:7]
148   - 2015-02-04T20:33:26: >Iteration 2: -logL=89094.420, Lambda=1.0e-04, delta=0.015, max(|grad|)=-0.116432 [Index:3]
149   - 2015-02-04T20:33:26: >Iteration 3: -logL=89094.420, Lambda=1.0e-05, delta=0.000, max(|grad|)=-0.003989 [Index:3]
150   - 2015-02-04T20:33:26:
151   - 2015-02-04T20:33:26: +=========================================+
152   - 2015-02-04T20:33:26: | Maximum likelihood optimization results |
153   - 2015-02-04T20:33:26: +=========================================+
154   - 2015-02-04T20:33:26: === GOptimizerLM ===
155   - 2015-02-04T20:33:26: Optimized function value ..: 89094.420
156   - 2015-02-04T20:33:26: Absolute precision ........: 0.005
157   - 2015-02-04T20:33:26: Acceptable value decrease .: 2
158   - 2015-02-04T20:33:26: Optimization status .......: converged
159   - 2015-02-04T20:33:26: Number of parameters ......: 9
160   - 2015-02-04T20:33:26: Number of free parameters .: 4
161   - 2015-02-04T20:33:26: Number of iterations ......: 3
162   - 2015-02-04T20:33:26: Lambda ....................: 1e-06
163   - 2015-02-04T20:33:26: Maximum log likelihood ....: -89094.420
164   - 2015-02-04T20:33:26: Observed events (Nobs) ...: 12260.000
165   - 2015-02-04T20:33:26: Predicted events (Npred) ..: 12260.000 (Nobs - Npred = 6.95764e-06)
166   - 2015-02-04T20:33:26: === GModels ===
167   - 2015-02-04T20:33:26: Number of models ..........: 2
168   - 2015-02-04T20:33:26: Number of parameters ......: 9
169   - 2015-02-04T20:33:26: === GModelSky ===
170   - 2015-02-04T20:33:26: Name ......................: Crab
171   - 2015-02-04T20:33:26: Instruments ...............: all
172   - 2015-02-04T20:33:26: Instrument scale factors ..: unity
173   - 2015-02-04T20:33:26: Observation identifiers ...: all
174   - 2015-02-04T20:33:26: Model type ................: PointSource
175   - 2015-02-04T20:33:26: Model components ..........: "SkyDirFunction" * "PowerLaw" * "Constant"
176   - 2015-02-04T20:33:26: Number of parameters ......: 6
177   - 2015-02-04T20:33:26: Number of spatial par's ...: 2
178   - 2015-02-04T20:33:26: RA .......................: 83.6331 [-360,360] deg (fixed,scale=1)
179   - 2015-02-04T20:33:26: DEC ......................: 22.0145 [-90,90] deg (fixed,scale=1)
180   - 2015-02-04T20:33:26: Number of spectral par's ..: 3
181   - 2015-02-04T20:33:26: Prefactor ................: 6.06322e-16 +/- 1.44948e-17 [1e-23,1e-13] ph/cm2/s/MeV (free,scale=1e-16,gradient)
182   - 2015-02-04T20:33:26: Index ....................: -2.49814 +/- 0.0178524 [-0,-5] (free,scale=-1,gradient)
183   - 2015-02-04T20:33:26: PivotEnergy ..............: 300000 [10000,1e+09] MeV (fixed,scale=1e+06,gradient)
184   - 2015-02-04T20:33:26: Number of temporal par's ..: 1
185   - 2015-02-04T20:33:26: Constant .................: 1 (relative value) (fixed,scale=1,gradient)
186   - 2015-02-04T20:33:26: === GCTAModelRadialAcceptance ===
187   - 2015-02-04T20:33:26: Name ......................: Background
188   - 2015-02-04T20:33:26: Instruments ...............: CTA
189   - 2015-02-04T20:33:26: Instrument scale factors ..: unity
190   - 2015-02-04T20:33:26: Observation identifiers ...: all
191   - 2015-02-04T20:33:26: Model type ................: "Gaussian" * "FileFunction" * "Constant"
192   - 2015-02-04T20:33:26: Number of parameters ......: 3
193   - 2015-02-04T20:33:26: Number of radial par's ....: 1
194   - 2015-02-04T20:33:26: Sigma ....................: 3.0356 +/- 0.0215259 [0.01,10] deg2 (free,scale=1,gradient)
195   - 2015-02-04T20:33:26: Number of spectral par's ..: 1
196   - 2015-02-04T20:33:26: Normalization ............: 0.99936 +/- 0.0122024 [0,1000] (free,scale=1,gradient)
197   - 2015-02-04T20:33:26: Number of temporal par's ..: 1
198   - 2015-02-04T20:33:26: Constant .................: 1 (relative value) (fixed,scale=1,gradient)
199   - 2015-02-04T20:33:26:
200   - 2015-02-04T20:33:26: +==============+
201   - 2015-02-04T20:33:26: | Save results |
202   - 2015-02-04T20:33:26: +==============+
203   - 2015-02-04T20:33:26:
204   - 2015-02-04T20:33:26: Application "ctlike" terminated after 10 wall clock seconds, consuming 0.385432 seconds of CPU time.
  143 + 2015-05-22T20:17:07: +=================================+
  144 + 2015-05-22T20:17:07: | Maximum likelihood optimisation |
  145 + 2015-05-22T20:17:07: +=================================+
  146 + 2015-05-22T20:17:07: >Iteration 0: -logL=201836.657, Lambda=1.0e-03
  147 + 2015-05-22T20:17:07: >Iteration 1: -logL=201829.438, Lambda=1.0e-03, delta=7.220, max(|grad|)=22.756507 [Index:7]
  148 + 2015-05-22T20:17:07: >Iteration 2: -logL=201829.432, Lambda=1.0e-04, delta=0.005, max(|grad|)=0.086395 [Index:3]
  149 + 2015-05-22T20:17:07: >Iteration 3: -logL=201829.432, Lambda=1.0e-05, delta=0.000, max(|grad|)=0.001287 [Index:3]
  150 + 2015-05-22T20:17:07:
  151 + 2015-05-22T20:17:07: +=========================================+
  152 + 2015-05-22T20:17:07: | Maximum likelihood optimization results |
  153 + 2015-05-22T20:17:07: +=========================================+
  154 + 2015-05-22T20:17:07: === GOptimizerLM ===
  155 + 2015-05-22T20:17:07: Optimized function value ..: 201829.432
  156 + 2015-05-22T20:17:07: Absolute precision ........: 0.005
  157 + 2015-05-22T20:17:07: Acceptable value decrease .: 2
  158 + 2015-05-22T20:17:07: Optimization status .......: converged
  159 + 2015-05-22T20:17:07: Number of parameters ......: 10
  160 + 2015-05-22T20:17:07: Number of free parameters .: 4
  161 + 2015-05-22T20:17:07: Number of iterations ......: 3
  162 + 2015-05-22T20:17:07: Lambda ....................: 1e-06
  163 + 2015-05-22T20:17:07: Maximum log likelihood ....: -201829.432
  164 + 2015-05-22T20:17:07: Observed events (Nobs) ...: 31799.000
  165 + 2015-05-22T20:17:07: Predicted events (Npred) ..: 31799.000 (Nobs - Npred = 2.67544e-06)
  166 + 2015-05-22T20:17:07: === GModels ===
  167 + 2015-05-22T20:17:07: Number of models ..........: 2
  168 + 2015-05-22T20:17:07: Number of parameters ......: 10
  169 + 2015-05-22T20:17:07: === GModelSky ===
  170 + 2015-05-22T20:17:07: Name ......................: Crab
  171 + 2015-05-22T20:17:07: Instruments ...............: all
  172 + 2015-05-22T20:17:07: Instrument scale factors ..: unity
  173 + 2015-05-22T20:17:07: Observation identifiers ...: all
  174 + 2015-05-22T20:17:07: Model type ................: PointSource
  175 + 2015-05-22T20:17:07: Model components ..........: "SkyDirFunction" * "PowerLaw" * "Constant"
  176 + 2015-05-22T20:17:07: Number of parameters ......: 6
  177 + 2015-05-22T20:17:07: Number of spatial par's ...: 2
  178 + 2015-05-22T20:17:07: RA .......................: 83.6331 [-360,360] deg (fixed,scale=1)
  179 + 2015-05-22T20:17:07: DEC ......................: 22.0145 [-90,90] deg (fixed,scale=1)
  180 + 2015-05-22T20:17:07: Number of spectral par's ..: 3
  181 + 2015-05-22T20:17:07: Prefactor ................: 5.8727e-16 +/- 8.04314e-18 [1e-23,1e-13] ph/cm2/s/MeV (free,scale=1e-16,gradient)
  182 + 2015-05-22T20:17:07: Index ....................: -2.49825 +/- 0.0118418 [-0,-5] (free,scale=-1,gradient)
  183 + 2015-05-22T20:17:07: PivotEnergy ..............: 300000 [10000,1e+09] MeV (fixed,scale=1e+06,gradient)
  184 + 2015-05-22T20:17:07: Number of temporal par's ..: 1
  185 + 2015-05-22T20:17:07: Normalization ............: 1 (relative value) (fixed,scale=1,gradient)
  186 + 2015-05-22T20:17:07: === GCTAModelIrfBackground ===
  187 + 2015-05-22T20:17:07: Name ......................: CTABackgroundModel
  188 + 2015-05-22T20:17:07: Instruments ...............: CTA
  189 + 2015-05-22T20:17:07: Instrument scale factors ..: unity
  190 + 2015-05-22T20:17:07: Observation identifiers ...: all
  191 + 2015-05-22T20:17:07: Model type ................: "PowerLaw" * "Constant"
  192 + 2015-05-22T20:17:07: Number of parameters ......: 4
  193 + 2015-05-22T20:17:07: Number of spectral par's ..: 3
  194 + 2015-05-22T20:17:07: Prefactor ................: 1.01608 +/- 0.0152751 [0.001,1000] ph/cm2/s/MeV (free,scale=1,gradient)
  195 + 2015-05-22T20:17:07: Index ....................: 0.0226023 +/- 0.0086794 [-5,5] (free,scale=1,gradient)
  196 + 2015-05-22T20:17:07: PivotEnergy ..............: 1e+06 [10000,1e+09] MeV (fixed,scale=1e+06,gradient)
  197 + 2015-05-22T20:17:07: Number of temporal par's ..: 1
  198 + 2015-05-22T20:17:07: Normalization ............: 1 (relative value) (fixed,scale=1,gradient)
205 199  
206 200 The log file indicates that the fit converged quickly, the spectral
207 201 parameters of the Crab nebula have now been constrained using the events
... ...
doc/source/user_manual/getting_started/beyond_irf.rst
... ... @@ -3,33 +3,50 @@
3 3 Connecting observations to dedicated instrument response functions
4 4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5 5  
6   -.. note::
7   -
8   - To execute the following examples on your machine you need to
9   - install a specific calibration database. Download the file
10   - :download:`caldb.tar.gz <caldb.tar.gz>` into a local working
11   - directory, decompress and untar the folder, and set the calibration
12   - database to this folder by typing:
13   -
14   - .. code-block:: bash
15   -
16   - $ export CALDB=$PWD/caldb
17   -
18   - Note that the response functions in the calibration database
19   - are all identical to the ``cta_dummy_irf`` response, yet there
20   - a multiple database and response entries so that the usage of
21   - specific response functions can be emulated.
22   -
23 6 So far the same instrument response function has been used for all
24 7 observations in our analysis examples.
25 8 You may have recognised that we always specified the calibration database
26   -``dummy`` and the instrument response function ``cta_dummy_irf`` that
27   -are shipped with the ctools release.
  9 +``prod2`` and the instrument response function ``South_50h`` that
  10 +are shipped with ctools.
28 11 When combining multiple observations in a joint analysis we may however
29 12 need to specify dedicated instrument response functions for the
30 13 different observations.
31   -This can be done by adding the calibration information to the observation
32   -definition XML file:
  14 +
  15 +Let's simulate two observations of the Crab nebula, one done with
  16 +the northern array and the other with the southern array:
  17 +
  18 +.. code-block:: bash
  19 +
  20 + $ ctobssim
  21 + RA of pointing (degrees) (0-360) [83.63]
  22 + Dec of pointing (degrees) (-90-90) [22.01] 21.51
  23 + Radius of FOV (degrees) (0-180) [5.0]
  24 + Start time (MET in s) [0.0]
  25 + End time (MET in s) [1800.0]
  26 + Lower energy limit (TeV) [0.1]
  27 + Upper energy limit (TeV) [100.0]
  28 + Calibration database [prod2]
  29 + Instrument response function [South_50h] North_50h
  30 + Model [$CTOOLS/share/models/crab.xml]
  31 + Output event data file or observation definition file [events.fits] events1.fits
  32 +
  33 +.. code-block:: bash
  34 +
  35 + $ ctobssim
  36 + RA of pointing (degrees) (0-360) [83.63]
  37 + Dec of pointing (degrees) (-90-90) [22.01] 22.51
  38 + Radius of FOV (degrees) (0-180) [5.0]
  39 + Start time (MET in s) [0.0]
  40 + End time (MET in s) [1800.0]
  41 + Lower energy limit (TeV) [0.1]
  42 + Upper energy limit (TeV) [100.0]
  43 + Calibration database [prod2]
  44 + Instrument response function [North_50h] South_50h
  45 + Model [$CTOOLS/share/models/crab.xml]
  46 + Output event data file or observation definition file [events1.fits] events2.fits
  47 +
  48 +Now we combine the information about these two observations in an
  49 +observation definition XML file:
33 50  
34 51 .. code-block:: xml
35 52  
... ... @@ -37,11 +54,11 @@ definition XML file:
37 54 <observation_list title="observation library">
38 55 <observation name="Crab" id="00001" instrument="CTA">
39 56 <parameter name="EventList" file="events1.fits"/>
40   - <parameter name="Calibration" database="north" response="cta_north_irf"/>
  57 + <parameter name="Calibration" database="prod2" response="North_50h"/>
41 58 </observation>
42 59 <observation name="Crab" id="00002" instrument="CTA">
43 60 <parameter name="EventList" file="events2.fits"/>
44   - <parameter name="Calibration" database="south" response="cta_south_irf"/>
  61 + <parameter name="Calibration" database="prod2" response="South_50h"/>
45 62 </observation>
46 63 </observation_list>
47 64  
... ... @@ -55,41 +72,39 @@ option to get the output of the script on the console):
55 72  
56 73 $ cscaldb debug=yes
57 74 Parfile cscaldb.par not found. Create default parfile.
58   - 2015-02-05T14:26:50: +============+
59   - 2015-02-05T14:26:50: | Parameters |
60   - 2015-02-05T14:26:50: +============+
61   - 2015-02-05T14:26:50: chatter ...................: 2
62   - 2015-02-05T14:26:50: clobber ...................: yes
63   - 2015-02-05T14:26:50: debug .....................: yes
64   - 2015-02-05T14:26:50: mode ......................: ql
65   - 2015-02-05T14:26:50:
66   - 2015-02-05T14:26:50: +==============+
67   - 2015-02-05T14:26:50: | Mission: cta |
68   - 2015-02-05T14:26:50: +==============+
69   - 2015-02-05T14:26:50: === Response functions in database "dummy" ===
70   - 2015-02-05T14:26:50: cta_dummy_irf
71   - 2015-02-05T14:26:50: cta_prod1_irf
72   - 2015-02-05T14:26:50: cta_prod2_irf
73   - 2015-02-05T14:26:50:
74   - 2015-02-05T14:26:50: === Response functions in database "north" ===
75   - 2015-02-05T14:26:50: cta_north_irf
76   - 2015-02-05T14:26:50:
77   - 2015-02-05T14:26:50: === Response functions in database "south" ===
78   - 2015-02-05T14:26:50: cta_south_irf
79   -
80   -You will see that for the CTA observatory three databases exist.
81   -The ``dummy`` database contains three response functions
82   -(``cta_dummy_irf``, ``cta_prod1_irf``, ``cta_prod2_irf``) while the
83   -``north`` and ``south`` databases contain a single response function.
84   -You may now do a :ref:`ctlike` fit using the XML file with the specific
85   -response definitions:
  75 + 2015-05-22T21:35:39: +============+
  76 + 2015-05-22T21:35:39: | Parameters |
  77 + 2015-05-22T21:35:39: +============+
  78 + 2015-05-22T21:35:39: chatter ...................: 2
  79 + 2015-05-22T21:35:39: clobber ...................: yes
  80 + 2015-05-22T21:35:39: debug .....................: yes
  81 + 2015-05-22T21:35:39: mode ......................: ql
  82 + 2015-05-22T21:35:39:
  83 + 2015-05-22T21:35:39: +==============+
  84 + 2015-05-22T21:35:39: | Mission: cta |
  85 + 2015-05-22T21:35:39: +==============+
  86 + 2015-05-22T21:35:40: === Response functions in database "prod2" ===
  87 + 2015-05-22T21:35:40: North_0.5h
  88 + 2015-05-22T21:35:40: North_50h
  89 + 2015-05-22T21:35:40: North_5h
  90 + 2015-05-22T21:35:40: South_0.5h
  91 + 2015-05-22T21:35:40: South_50h
  92 + 2015-05-22T21:35:40: South_5h
  93 +
  94 +You will see that ctools ships with one database for the CTA observatory.
  95 +This is the ``prod2`` database.
  96 +Within this database there are six response functions:
  97 +``North_0.5h``, ``North_5h``, ``North_50h``,
  98 +``South_0.5h``, ``South_5h``, and ``South_50h``.
  99 +
  100 +We now jointly fit both observations using :ref:`ctlike`:
86 101  
87 102 .. code-block:: bash
88 103  
89 104 $ ctlike
90   - Event list, counts cube or observation definition file [events.fits] obs_irf.xml
  105 + Event list, counts cube or observation definition file [obs.xml] obs_irf.xml
91 106 Source model [$CTOOLS/share/models/crab.xml]
92   - Source model output file [crab_results.xml]
  107 + Source model output file [crab_results.xml]
93 108  
94 109 To see the usage of the individual response functions you may inspect the
95 110 log file. You will notice that each observation now has a specific response
... ... @@ -98,69 +113,110 @@ both observations.
98 113  
99 114 .. code-block:: xml
100 115  
101   - 2015-02-05T14:48:46: +==============+
102   - 2015-02-05T14:48:46: | Observations |
103   - 2015-02-05T14:48:46: +==============+
104   - 2015-02-05T14:48:46: === GObservations ===
105   - 2015-02-05T14:48:46: Number of observations ....: 2
106   - 2015-02-05T14:48:46: Number of predicted events : 0
107   - 2015-02-05T14:48:46: === GCTAObservation ===
108   - 2015-02-05T14:48:46: Name ......................: Crab
109   - 2015-02-05T14:48:46: Identifier ................: 00001
110   - 2015-02-05T14:48:46: Instrument ................: CTA
111   - 2015-02-05T14:48:46: Event file ................: events1.fits
112   - 2015-02-05T14:48:46: Event type ................: EventList
113   - 2015-02-05T14:48:46: Statistics ................: Poisson
114   - 2015-02-05T14:48:46: Ontime ....................: 1800 s
115   - 2015-02-05T14:48:46: Livetime ..................: 1710 s
116   - 2015-02-05T14:48:46: Deadtime correction .......: 0.95
117   - 2015-02-05T14:48:46: User energy range .........: undefined
118   - 2015-02-05T14:48:46: === GCTAPointing ===
119   - 2015-02-05T14:48:46: Pointing direction ........: (RA,Dec)=(83.63,21.51)
120   - 2015-02-05T14:48:46: === GCTAResponseIrf ===
121   - 2015-02-05T14:48:46: Response name .............: cta_north_irf
122   - 2015-02-05T14:48:46: Energy dispersion .........: Not used
123   - 2015-02-05T14:48:46: Save energy range .........: undefined
124   - 2015-02-05T14:48:46: === GCaldb ===
125   - 2015-02-05T14:48:46: Database root .............: /Users/jurgen/Desktop/tmp/beyond/caldb
126   - 2015-02-05T14:48:46: Selected Mission ..........: CTA
127   - 2015-02-05T14:48:46: Selected Instrument .......: NORTH
128   - 2015-02-05T14:48:46: Calibration Index File ....: /Users/jurgen/Desktop/tmp/beyond/caldb/data/cta/north/caldb.indx
129   - 2015-02-05T14:48:46: Number of entries .........: 4
130   - 2015-02-05T14:48:46: === GCTAAeffPerfTable ===
131   - 2015-02-05T14:48:46: Filename ..................: /Users/jurgen/Desktop/tmp/beyond/caldb/data/cta/north/bcf/cta_north_irf.dat
132   - 2015-02-05T14:48:46: Number of energy bins .....: 20
133   - 2015-02-05T14:48:46: Log10(Energy) range .......: 0.0199526 - 125.893 TeV
134   - 2015-02-05T14:48:46: Offset angle dependence ...: Fixed sigma=3
135   - ...
136   - 2015-02-05T14:48:46: === GCTAObservation ===
137   - 2015-02-05T14:48:46: Name ......................: Crab
138   - 2015-02-05T14:48:46: Identifier ................: 00002
139   - 2015-02-05T14:48:46: Instrument ................: CTA
140   - 2015-02-05T14:48:46: Event file ................: events2.fits
141   - 2015-02-05T14:48:46: Event type ................: EventList
142   - 2015-02-05T14:48:46: Statistics ................: Poisson
143   - 2015-02-05T14:48:46: Ontime ....................: 1800 s
144   - 2015-02-05T14:48:46: Livetime ..................: 1710 s
145   - 2015-02-05T14:48:46: Deadtime correction .......: 0.95
146   - 2015-02-05T14:48:46: User energy range .........: undefined
147   - 2015-02-05T14:48:46: === GCTAPointing ===
148   - 2015-02-05T14:48:46: Pointing direction ........: (RA,Dec)=(83.63,22.51)
149   - 2015-02-05T14:48:46: === GCTAResponseIrf ===
150   - 2015-02-05T14:48:46: Response name .............: cta_south_irf
151   - 2015-02-05T14:48:46: Energy dispersion .........: Not used
152   - 2015-02-05T14:48:46: Save energy range .........: undefined
153   - 2015-02-05T14:48:46: === GCaldb ===
154   - 2015-02-05T14:48:46: Database root .............: /Users/jurgen/Desktop/tmp/beyond/caldb
155   - 2015-02-05T14:48:46: Selected Mission ..........: CTA
156   - 2015-02-05T14:48:46: Selected Instrument .......: SOUTH
157   - 2015-02-05T14:48:46: Calibration Index File ....: /Users/jurgen/Desktop/tmp/beyond/caldb/data/cta/south/caldb.indx
158   - 2015-02-05T14:48:46: Number of entries .........: 4
159   - 2015-02-05T14:48:46: === GCTAAeffPerfTable ===
160   - 2015-02-05T14:48:46: Filename ..................: /Users/jurgen/Desktop/tmp/beyond/caldb/data/cta/south/bcf/cta_south_irf.dat
161   - 2015-02-05T14:48:46: Number of energy bins .....: 20
162   - 2015-02-05T14:48:46: Log10(Energy) range .......: 0.0199526 - 125.893 TeV
163   - 2015-02-05T14:48:46: Offset angle dependence ...: Fixed sigma=3
  116 + 2015-05-22T22:06:43: +==============+
  117 + 2015-05-22T22:06:43: | Observations |
  118 + 2015-05-22T22:06:43: +==============+
  119 + 2015-05-22T22:06:43: === GObservations ===
  120 + 2015-05-22T22:06:43: Number of observations ....: 2
  121 + 2015-05-22T22:06:43: Number of predicted events : 0
  122 + 2015-05-22T22:06:43: === GCTAObservation ===
  123 + 2015-05-22T22:06:43: Name ......................:
  124 + 2015-05-22T22:06:43: Identifier ................: 00001
  125 + 2015-05-22T22:06:43: Instrument ................: CTA
  126 + 2015-05-22T22:06:43: Event file ................: events1.fits
  127 + 2015-05-22T22:06:43: Event type ................: EventList
  128 + 2015-05-22T22:06:43: Statistics ................: Poisson
  129 + 2015-05-22T22:06:43: Ontime ....................: 1800 s
  130 + 2015-05-22T22:06:43: Livetime ..................: 1710 s
  131 + 2015-05-22T22:06:43: Deadtime correction .......: 0.95
  132 + 2015-05-22T22:06:43: User energy range .........: undefined
  133 + 2015-05-22T22:06:43: === GCTAPointing ===
  134 + 2015-05-22T22:06:43: Pointing direction ........: (RA,Dec)=(83.63,21.51)
  135 + 2015-05-22T22:06:43: === GCTAResponseIrf ===
  136 + 2015-05-22T22:06:43: Caldb mission .............: cta
  137 + 2015-05-22T22:06:43: Caldb instrument ..........: prod2
  138 + 2015-05-22T22:06:43: Response name .............: North_50h
  139 + 2015-05-22T22:06:43: Energy dispersion .........: Not used
  140 + 2015-05-22T22:06:43: Save energy range .........: undefined
  141 + ...
  142 + 2015-05-22T22:06:43: === GCTAObservation ===
  143 + 2015-05-22T22:06:43: Name ......................:
  144 + 2015-05-22T22:06:43: Identifier ................: 00002
  145 + 2015-05-22T22:06:43: Instrument ................: CTA
  146 + 2015-05-22T22:06:43: Event file ................: events2.fits
  147 + 2015-05-22T22:06:43: Event type ................: EventList
  148 + 2015-05-22T22:06:43: Statistics ................: Poisson
  149 + 2015-05-22T22:06:43: Ontime ....................: 1800 s
  150 + 2015-05-22T22:06:43: Livetime ..................: 1710 s
  151 + 2015-05-22T22:06:43: Deadtime correction .......: 0.95
  152 + 2015-05-22T22:06:43: User energy range .........: undefined
  153 + 2015-05-22T22:06:43: === GCTAPointing ===
  154 + 2015-05-22T22:06:43: Pointing direction ........: (RA,Dec)=(83.63,22.51)
  155 + 2015-05-22T22:06:43: === GCTAResponseIrf ===
  156 + 2015-05-22T22:06:43: Caldb mission .............: cta
  157 + 2015-05-22T22:06:43: Caldb instrument ..........: prod2
  158 + 2015-05-22T22:06:43: Response name .............: South_50h
  159 + 2015-05-22T22:06:43: Energy dispersion .........: Not used
  160 + 2015-05-22T22:06:43: Save energy range .........: undefined
  161 + ...
  162 + 2015-05-22T22:06:43: +=================================+
  163 + 2015-05-22T22:06:43: | Maximum likelihood optimisation |
  164 + 2015-05-22T22:06:43: +=================================+
  165 + 2015-05-22T22:06:43: >Iteration 0: -logL=138039.472, Lambda=1.0e-03
  166 + 2015-05-22T22:06:43: >Iteration 1: -logL=138035.501, Lambda=1.0e-03, delta=3.971, max(|grad|)=16.203761 [Index:7]
  167 + 2015-05-22T22:06:43: >Iteration 2: -logL=138035.496, Lambda=1.0e-04, delta=0.005, max(|grad|)=-0.053284 [Index:7]
  168 + 2015-05-22T22:06:43: >Iteration 3: -logL=138035.496, Lambda=1.0e-05, delta=0.000, max(|grad|)=0.001386 [Index:7]
  169 + 2015-05-22T22:06:44:
  170 + 2015-05-22T22:06:44: +=========================================+
  171 + 2015-05-22T22:06:44: | Maximum likelihood optimization results |
  172 + 2015-05-22T22:06:44: +=========================================+
  173 + 2015-05-22T22:06:44: === GOptimizerLM ===
  174 + 2015-05-22T22:06:44: Optimized function value ..: 138035.496
  175 + 2015-05-22T22:06:44: Absolute precision ........: 0.005
  176 + 2015-05-22T22:06:44: Acceptable value decrease .: 2
  177 + 2015-05-22T22:06:44: Optimization status .......: converged
  178 + 2015-05-22T22:06:44: Number of parameters ......: 10
  179 + 2015-05-22T22:06:44: Number of free parameters .: 4
  180 + 2015-05-22T22:06:44: Number of iterations ......: 3
  181 + 2015-05-22T22:06:44: Lambda ....................: 1e-06
  182 + 2015-05-22T22:06:44: Maximum log likelihood ....: -138035.496
  183 + 2015-05-22T22:06:44: Observed events (Nobs) ...: 20814.000
  184 + 2015-05-22T22:06:44: Predicted events (Npred) ..: 20814.000 (Nobs - Npred = 2.67698e-06)
  185 + 2015-05-22T22:06:44: === GModels ===
  186 + 2015-05-22T22:06:44: Number of models ..........: 2
  187 + 2015-05-22T22:06:44: Number of parameters ......: 10
  188 + 2015-05-22T22:06:44: === GModelSky ===
  189 + 2015-05-22T22:06:44: Name ......................: Crab
  190 + 2015-05-22T22:06:44: Instruments ...............: all
  191 + 2015-05-22T22:06:44: Instrument scale factors ..: unity
  192 + 2015-05-22T22:06:44: Observation identifiers ...: all
  193 + 2015-05-22T22:06:44: Model type ................: PointSource
  194 + 2015-05-22T22:06:44: Model components ..........: "SkyDirFunction" * "PowerLaw" * "Constant"
  195 + 2015-05-22T22:06:44: Number of parameters ......: 6
  196 + 2015-05-22T22:06:44: Number of spatial par's ...: 2
  197 + 2015-05-22T22:06:44: RA .......................: 83.6331 [-360,360] deg (fixed,scale=1)
  198 + 2015-05-22T22:06:44: DEC ......................: 22.0145 [-90,90] deg (fixed,scale=1)
  199 + 2015-05-22T22:06:44: Number of spectral par's ..: 3
  200 + 2015-05-22T22:06:44: Prefactor ................: 5.9184e-16 +/- 9.68924e-18 [1e-23,1e-13] ph/cm2/s/MeV (free,scale=1e-16,gradient)
  201 + 2015-05-22T22:06:44: Index ....................: -2.49569 +/- 0.0145376 [-0,-5] (free,scale=-1,gradient)
  202 + 2015-05-22T22:06:44: PivotEnergy ..............: 300000 [10000,1e+09] MeV (fixed,scale=1e+06,gradient)
  203 + 2015-05-22T22:06:44: Number of temporal par's ..: 1
  204 + 2015-05-22T22:06:44: Normalization ............: 1 (relative value) (fixed,scale=1,gradient)
  205 + 2015-05-22T22:06:44: === GCTAModelIrfBackground ===
  206 + 2015-05-22T22:06:44: Name ......................: CTABackgroundModel
  207 + 2015-05-22T22:06:44: Instruments ...............: CTA
  208 + 2015-05-22T22:06:44: Instrument scale factors ..: unity
  209 + 2015-05-22T22:06:44: Observation identifiers ...: all
  210 + 2015-05-22T22:06:44: Model type ................: "PowerLaw" * "Constant"
  211 + 2015-05-22T22:06:44: Number of parameters ......: 4
  212 + 2015-05-22T22:06:44: Number of spectral par's ..: 3
  213 + 2015-05-22T22:06:44: Prefactor ................: 1.02524 +/- 0.0182054 [0.001,1000] ph/cm2/s/MeV (free,scale=1,gradient)
  214 + 2015-05-22T22:06:44: Index ....................: 0.0229728 +/- 0.0104713 [-5,5] (free,scale=1,gradient)
  215 + 2015-05-22T22:06:44: PivotEnergy ..............: 1e+06 [10000,1e+09] MeV (fixed,scale=1e+06,gradient)
  216 + 2015-05-22T22:06:44: Number of temporal par's ..: 1
  217 + 2015-05-22T22:06:44: Normalization ............: 1 (relative value) (fixed,scale=1,gradient)
  218 +
  219 +
164 220  
165 221 A more fine grained control over the response function can be achieved by
166 222 specifying individual filenames for the various response components.
... ... @@ -173,17 +229,17 @@ This is definitely expert mode, to be used with utmost care.
173 229 <observation_list title="observation library">
174 230 <observation name="Crab" id="00001" instrument="CTA">
175 231 <parameter name="EventList" file="events1.fits"/>
176   - <parameter name="EffectiveArea" file="$(CALDB)/data/cta/dummy/bcf/cta_dummy_irf.dat"/>
177   - <parameter name="PointSpreadFunction" file="$(CALDB)/data/cta/dummy/bcf/cta_prod1_irf.dat"/>
178   - <parameter name="EnergyDispersion" file="$(CALDB)/data/cta/dummy/bcf/cta_prod2_irf.dat"/>
179   - <parameter name="Background" file="$(CALDB)/data/cta/north/bcf/cta_north_irf.dat"/>
  232 + <parameter name="EffectiveArea" file="$(CALDB)/data/cta/prod2/bcf/North_50h/irf_file.fits.gz"/>
  233 + <parameter name="PointSpreadFunction" file="$(CALDB)/data/cta/prod2/bcf/North_50h/irf_file.fits.gz"/>
  234 + <parameter name="EnergyDispersion" file="$(CALDB)/data/cta/prod2/bcf/North_50h/irf_file.fits.gz"/>
  235 + <parameter name="Background" file="$(CALDB)/data/cta/prod2/bcf/North_50h/irf_file.fits.gz"/>
180 236 </observation>
181 237 <observation name="Crab" id="00002" instrument="CTA">
182 238 <parameter name="EventList" file="events2.fits"/>
183   - <parameter name="EffectiveArea" file="$(CALDB)/data/cta/dummy/bcf/cta_dummy_irf.dat"/>
184   - <parameter name="PointSpreadFunction" file="$(CALDB)/data/cta/dummy/bcf/cta_prod1_irf.dat"/>
185   - <parameter name="EnergyDispersion" file="$(CALDB)/data/cta/dummy/bcf/cta_prod2_irf.dat"/>
186   - <parameter name="Background" file="$(CALDB)/data/cta/south/bcf/cta_south_irf.dat"/>
  239 + <parameter name="EffectiveArea" file="$(CALDB)/data/cta/prod2/bcf/South_50h/irf_file.fits.gz"/>
  240 + <parameter name="PointSpreadFunction" file="$(CALDB)/data/cta/prod2/bcf/South_50h/irf_file.fits.gz"/>
  241 + <parameter name="EnergyDispersion" file="$(CALDB)/data/cta/prod2/bcf/South_50h/irf_file.fits.gz"/>
  242 + <parameter name="Background" file="$(CALDB)/data/cta/prod2/bcf/South_50h/irf_file.fits.gz"/>
187 243 </observation>
188 244 </observation_list>
189 245  
... ... @@ -199,11 +255,13 @@ file is given below:
199 255 <parameter name="CountsCube" file="cntcube1.fits"/>
200 256 <parameter name="ExposureCube" file="expcube1.fits"/>
201 257 <parameter name="PsfCube" file="psfcube1.fits"/>
  258 + <parameter name="BkgCube" file="bkgcube1.fits"/>
202 259 </observation>
203 260 <observation name="Crab" id="00002" instrument="CTA">
204 261 <parameter name="CountsCube" file="cntcube2.fits"/>
205 262 <parameter name="ExposureCube" file="expcube2.fits"/>
206 263 <parameter name="PsfCube" file="psfcube2.fits"/>
  264 + <parameter name="BkgCube" file="bkgcube2.fits"/>
207 265 </observation>
208 266 </observation_list>
209 267  
... ...
doc/source/user_manual/getting_started/beyond_model.rst
... ... @@ -56,23 +56,21 @@ event list.
56 56 <parameter name="DEC" scale="1.0" value="22.0145" min="-90" max="90" free="0"/>
57 57 </spatialModel>
58 58 </source>
59   - <source name="Background_00001" type="RadialAcceptance" instrument="CTA" id="00001">
60   - <spectrum type="FileFunction" file="$CTOOLS/share/models/bkg_dummy.txt">
61   - <parameter scale="1.0" name="Normalization" min="0.0" max="1000.0" value="1.0" free="1"/>
  59 + <source name="Background_00001" type="CTAIrfBackground" instrument="CTA" id="00001">
  60 + <spectrum type="PowerLaw">
  61 + <parameter name="Prefactor" scale="1.0" value="1.0" min="1e-3" max="1e+3" free="1"/>
  62 + <parameter name="Index" scale="1.0" value="0.0" min="-5.0" max="+5.0" free="1"/>
  63 + <parameter name="Scale" scale="1e6" value="1.0" min="0.01" max="1000.0" free="0"/>
62 64 </spectrum>
63   - <radialModel type="Gaussian">
64   - <parameter name="Sigma" scale="1.0" value="3.0" min="0.01" max="10.0" free="1"/>
65   - </radialModel>
66 65 </source>
67   - <source name="Background_00002" type="RadialAcceptance" instrument="CTA" id="00002">
68   - <spectrum type="FileFunction" file="$CTOOLS/share/models/bkg_dummy.txt">
69   - <parameter scale="1.0" name="Normalization" min="0.0" max="1000.0" value="10.0" free="1"/>
  66 + <source name="Background_00002" type="CTAIrfBackground" instrument="CTA" id="00002">
  67 + <spectrum type="PowerLaw">
  68 + <parameter name="Prefactor" scale="1.0" value="10.0" min="1e-3" max="1e+3" free="1"/>
  69 + <parameter name="Index" scale="1.0" value="0.0" min="-5.0" max="+5.0" free="1"/>
  70 + <parameter name="Scale" scale="1e6" value="1.0" min="0.01" max="1000.0" free="0"/>
70 71 </spectrum>
71   - <radialModel type="Gaussian">
72   - <parameter name="Sigma" scale="1.0" value="3.0" min="0.01" max="10.0" free="1"/>
73   - </radialModel>
74 72 </source>
75   - </source_library>
  73 + </source_library>
76 74  
77 75 Note that both background model components distinguish in their event rate;
78 76 component ``Background_00002`` has a ten times larger background rate than
... ... @@ -112,21 +110,19 @@ This is illustrated in the model definition file below where component
112 110 <parameter name="DEC" scale="1.0" value="22.0145" min="-90" max="90" free="0"/>
113 111 </spatialModel>
114 112 </source>
115   - <source name="Background_00001" type="RadialAcceptance" instrument="CTA" id="00001,00003,00004">
116   - <spectrum type="FileFunction" file="$CTOOLS/share/models/bkg_dummy.txt">
117   - <parameter scale="1.0" name="Normalization" min="0.0" max="1000.0" value="1.0" free="1"/>
  113 + <source name="Background_00001" type="CTAIrfBackground" instrument="CTA" id="00001,00003,00004">
  114 + <spectrum type="PowerLaw">
  115 + <parameter name="Prefactor" scale="1.0" value="1.0" min="1e-3" max="1e+3" free="1"/>
  116 + <parameter name="Index" scale="1.0" value="0.0" min="-5.0" max="+5.0" free="1"/>
  117 + <parameter name="Scale" scale="1e6" value="1.0" min="0.01" max="1000.0" free="0"/>
118 118 </spectrum>
119   - <radialModel type="Gaussian">
120   - <parameter name="Sigma" scale="1.0" value="3.0" min="0.01" max="10.0" free="1"/>
121   - </radialModel>
122 119 </source>
123   - <source name="Background_00002" type="RadialAcceptance" instrument="CTA" id="00002">
124   - <spectrum type="FileFunction" file="$CTOOLS/share/models/bkg_dummy.txt">
125   - <parameter scale="1.0" name="Normalization" min="0.0" max="1000.0" value="10.0" free="1"/>
  120 + <source name="Background_00002" type="CTAIrfBackground" instrument="CTA" id="00002">
  121 + <spectrum type="PowerLaw">
  122 + <parameter name="Prefactor" scale="1.0" value="10.0" min="1e-3" max="1e+3" free="1"/>
  123 + <parameter name="Index" scale="1.0" value="0.0" min="-5.0" max="+5.0" free="1"/>
  124 + <parameter name="Scale" scale="1e6" value="1.0" min="0.01" max="1000.0" free="0"/>
126 125 </spectrum>
127   - <radialModel type="Gaussian">
128   - <parameter name="Sigma" scale="1.0" value="3.0" min="0.01" max="10.0" free="1"/>
129   - </radialModel>
130 126 </source>
131 127 </source_library>
132 128  
... ...
doc/source/user_manual/getting_started/beyond_residual.rst
... ... @@ -16,15 +16,27 @@ the model value to obtained the fractional residuals
16 16 Residual = \frac{Counts-Model}{Model}
17 17  
18 18 for all map pixels.
19   -The :ref:`csresmap` script is used as follows:
  19 +
  20 +Suppose that you have done the following unbinned ``ctlike`` analysis:
  21 +
  22 +.. code-block:: bash
  23 +
  24 + $ ctlike
  25 + Event list, counts cube or observation definition file [events.fits] obs.xml
  26 + Calibration database [prod2]
  27 + Instrument response function [South_50h]
  28 + Source model [$CTOOLS/share/models/crab.xml]
  29 + Source model output file [crab_results.xml]
  30 +
  31 +The :ref:`csresmap` script is then used as follows:
20 32  
21 33 .. code-block:: bash
22 34  
23 35 $ csresmap
24 36 Parfile csresmap.par not found. Create default parfile.
25 37 Event list, counts cube, or observation definition file [events.fits] obs.xml
26   - Calibration database [dummy]
27   - Instrument response function [cta_dummy_irf]
  38 + Calibration database [prod2]
  39 + Instrument response function [South_50h]
28 40 Source model [$CTOOLS/share/models/crab.xml] crab_results.xml
29 41 Output residual map [resmap.fits]
30 42 First coordinate of image center in degrees (RA or galactic l) [83.63]
... ...
doc/source/user_manual/getting_started/beyond_stacked.rst
... ... @@ -15,10 +15,10 @@ into a single counts cube:
15 15 .. code-block:: bash
16 16  
17 17 $ ctbin
18   - Event list or observation definition file [events2.fits] obs.xml
19   - First coordinate of image center in degrees (RA or galactic l) [83.63]
20   - Second coordinate of image center in degrees (DEC or galactic b) [22.01]
21   - Projection method e.g. AIT|AZP|CAR|MER|STG|TAN (AIT|AZP|CAR|MER|STG|TAN) [CAR]
  18 + Event list or observation definition file [events.fits] obs.xml
  19 + First coordinate of image center in degrees (RA or galactic l) (0-360) [83.63]
  20 + Second coordinate of image center in degrees (DEC or galactic b) (-90-90) [22.01]
  21 + Projection method (AIT|AZP|CAR|MER|MOL|STG|TAN) [CAR]
22 22 Coordinate system (CEL - celestial, GAL - galactic) (CEL|GAL) [CEL]
23 23 Image scale (in degrees/pixel) [0.02]
24 24 Size of the X axis in pixels [200]
... ... @@ -27,15 +27,16 @@ into a single counts cube:
27 27 Start value for first energy bin in TeV [0.1]
28 28 Stop value for last energy bin in TeV [100.0]
29 29 Number of energy bins [20]
30   - Output counts cube [cntcube2.fits] cntcube.fits
  30 + Output counts cube [cntcube.fits]
31 31  
32 32 We now have a stacked counts cube ``cntcube.fits`` on disk.
33 33 Before we can use that counts cube in a maximum likelihood
34 34 analysis, we have to compute the instrument response and the
35 35 background model that are needed to describe the stacked data.
  36 +
36 37 For the former, we have to compute the total exposure for the stacked
37 38 cube (i.e. the sum of the effective areas for each observation multiplied
38   -by the corresponding lifetimes) and an effective point spread function
  39 +by the corresponding livetimes) and an effective point spread function
39 40 (i.e. the point spread function of the different observations weighted by
40 41 the corresponding exposures).
41 42 To get both informations we use the :ref:`ctexpcube` and
... ... @@ -45,29 +46,29 @@ To get both informations we use the :ref:`ctexpcube` and
45 46  
46 47 $ ctexpcube
47 48 Event list or observation definition file [NONE] obs.xml
48   - Calibration database [dummy]
49   - Instrument response function [cta_dummy_irf]
  49 + Calibration database [prod2]
  50 + Instrument response function [South_50h]
50 51 Counts cube for exposure cube definition [NONE] cntcube.fits
51   - Output exposure cube file [expcube.fits]
  52 + Output exposure cube file [expcube.fits]
52 53  
53 54 .. code-block:: bash
54 55  
55 56 $ ctpsfcube
56 57 Event list or observation definition file [NONE] obs.xml
57   - Calibration database [dummy]
58   - Instrument response function [cta_dummy_irf]
  58 + Calibration database [prod2]
  59 + Instrument response function [South_50h]
59 60 Counts cube for psf cube definition [NONE]
60   - First coordinate of image center in degrees (RA or galactic l) [83.63]
61   - Second coordinate of image center in degrees (DEC or galactic b) [22.01]
62   - Projection method e.g. AIT|AZP|CAR|MER|MOL|STG|TAN (AIT|AZP|CAR|MER|MOL|STG|TAN) [CAR]
  61 + First coordinate of image center in degrees (RA or galactic l) (0-360) [83.63]
  62 + Second coordinate of image center in degrees (DEC or galactic b) (-90-90) [22.01]
  63 + Projection method (AIT|AZP|CAR|MER|MOL|STG|TAN) [CAR]
63 64 Coordinate system (CEL - celestial, GAL - galactic) (CEL|GAL) [CEL]
64 65 Image scale (in degrees/pixel) [1.0]
65 66 Size of the X axis in pixels [10]
66 67 Size of the Y axis in pixels [10]
67   - Start value for first energy bin in TeV [0.1]
68   - Stop value for last energy bin in TeV [100.0]
  68 + Lower energy limit (TeV) [0.1]
  69 + Upper energy limit (TeV) [100.0]
69 70 Number of energy bins [20]
70   - Output psf cube file [psfcube.fits]
  71 + Output psf cube file [psfcube.fits]
71 72  
72 73 We provide the ``obs.xml`` file on input to inform both tools which
73 74 observations have been combined.
... ... @@ -93,17 +94,17 @@ background cube using the :ref:`ctbkgcube` tool:
93 94  
94 95 $ ctbkgcube
95 96 Input event list or observation definition file [NONE] obs.xml
96   - Calibration database [dummy]
97   - Instrument response function [cta_dummy_irf]
98   - Input (background) model XML file [NONE] $CTOOLS/share/models/crab.xml
  97 + Calibration database [prod2]
  98 + Instrument response function [South_50h]
99 99 Counts cube for background cube definition [NONE] cntcube.fits
  100 + Input model XML file [NONE] $CTOOLS/share/models/crab.xml
100 101 Output background cube file [bkgcube.fits]
101   - Output (background) model XML file [NONE] model.xml
  102 + Output model XML file [NONE] model.xml
102 103  
103 104 The usage of :ref:`ctbkgcube` is very similar to that of :ref:`ctexpcube`,
104 105 yet it takes the model XML file as an additional input parameter.
105   -We here use the usual ``$CTOOLS/share/models/crab.xml`` Crab plus
106   -background model file that is shipped with the ctools.
  106 +We here use the usual ``$CTOOLS/share/models/crab.xml`` model
  107 +file that is shipped with the ctools.
107 108 :ref:`ctbkgcube` provides on output the background cube file
108 109 ``bkgcube.fits`` and the model XML file ``model.xml`` that can
109 110 be used for further analysis.
... ... @@ -125,25 +126,21 @@ modelling works:
125 126 <parameter name="DEC" value="22.0145" scale="1" min="-90" max="90" free="0" />
126 127 </spatialModel>
127 128 </source>
128   - <source name="ctbkgcube default background model" type="CTACubeBackground">
  129 + <source name="BackgroundModel" type="CTACubeBackground" instrument="CTA,HESS,MAGIC,VERITAS">
129 130 <spectrum type="PowerLaw">
130 131 <parameter name="Prefactor" value="1" error="0" scale="1" min="0" free="1" />
131 132 <parameter name="Index" value="0" error="0" scale="1" min="-10" max="10" free="1" />
132 133 <parameter name="Scale" value="1" scale="1e+06" free="0" />
133 134 </spectrum>
134   - <spatialModel type="MapCubeFunction" file="bkgcube.fits">
135   - <parameter name="Normalization" value="1" scale="1" min="0.001" max="1000" free="0" />
136   - </spatialModel>
137 135 </source>
138 136 </source_library>
139 137  
140 138 The Crab source component is the same that is also present in
141 139 ``$CTOOLS/share/models/crab.xml`` and is not modified.
142   -The background component, however, has been replaced and now is
143   -the ``ctbkgcube default background model``.
144   -This model is of type ``CTACubeBackground`` which is a 3-dimensional
145   -data cube that describes the expected background rate as function
146   -of spatial position and energy.
  140 +The background component, however, has been replaced by a model of
  141 +type ``CTACubeBackground``.
  142 +This model is a 3-dimensional data cube that describes the expected
  143 +background rate as function of spatial position and energy.
147 144 The data cube is multiplied by a power law spectrum that allows to adjust
148 145 the normalization and slope of the background spectrum in the fit.
149 146 This power law could be replaced by any spectral model that is found
... ... @@ -166,87 +163,82 @@ analysis using the :ref:`ctlike` tool:
166 163 .. code-block:: bash
167 164  
168 165 $ ctlike
169   - Event list, counts cube or observation definition file [events.fits] cntcube.fits
170   - Exposure cube file [NONE] expcube.fits
171   - PSF cube file [NONE] psfcube.fits
  166 + Event list, counts cube or observation definition file [obs.xml] cntcube.fits
  167 + Exposure cube file (only needed for stacked analysis) [NONE] expcube.fits
  168 + PSF cube file (only needed for stacked analysis) [NONE] psfcube.fits
  169 + Background cube file (only needed for stacked analysis) [NONE] bkgcube.fits
172 170 Source model [$CTOOLS/share/models/crab.xml] model.xml
173   - Source model output file [crab_results.xml]
  171 + Source model output file [crab_results.xml]
174 172  
175 173 :ref:`ctlike` recognises that a counts cube should be analysed and queries
176   -for the exposure cube and PSF cube file names.
177   -We specified the names of the files produced by the :ref:`ctexpcube` and
178   -:ref:`ctpsfcube` tools and furthermore provided the ``model.xml`` file
179   -that is generated by the :ref:`ctbkgcube` tool as source model.
  174 +for the exposure cube, the PSF cube, and the background cube file names.
  175 +We specified the names of the files produced by the :ref:`ctexpcube`,
  176 +the :ref:`ctpsfcube` and the :ref:`ctbkgcube` tools.
  177 +Furthermore we provided as model the ``model.xml`` file that has been
  178 +generated by the :ref:`ctbkgcube` tool.
  179 +
180 180 The log file of the :ref:`ctlike` run is shown below.
181 181 Note that the spectral model that is multiplied with the background
182   -cube has a Prefactor of 1.06 +/- 0.02 and an Index of 0.004 +/- 0.009,
  182 +cube has a Prefactor of 1.09 +/- 0.02 and an Index of 0.03 +/- 0.01,
183 183 indicating a very small correction to the actual spectrum of the background
184 184 cube.
185 185 Real life situations may of course require larger correction factors.
186 186  
187 187 .. code-block:: xml
188 188  
189   - 2015-02-04T23:00:25: +=================================+
190   - 2015-02-04T23:00:25: | Maximum likelihood optimisation |
191   - 2015-02-04T23:00:25: +=================================+
192   - 2015-02-04T23:00:29: >Iteration 0: -logL=36748.112, Lambda=1.0e-03
193   - 2015-02-04T23:00:33: >Iteration 1: -logL=36734.170, Lambda=1.0e-03, delta=13.942, max(|grad|)=34.291911 [Index:8]
194   - 2015-02-04T23:00:38: >Iteration 2: -logL=36734.127, Lambda=1.0e-04, delta=0.044, max(|grad|)=0.178088 [Index:8]
195   - 2015-02-04T23:00:42: >Iteration 3: -logL=36734.127, Lambda=1.0e-05, delta=0.000, max(|grad|)=-0.001993 [Index:8]
196   - 2015-02-04T23:00:46:
197   - 2015-02-04T23:00:46: +=========================================+
198   - 2015-02-04T23:00:46: | Maximum likelihood optimization results |
199   - 2015-02-04T23:00:46: +=========================================+
200   - 2015-02-04T23:00:46: === GOptimizerLM ===
201   - 2015-02-04T23:00:46: Optimized function value ..: 36734.127
202   - 2015-02-04T23:00:46: Absolute precision ........: 0.005
203   - 2015-02-04T23:00:46: Acceptable value decrease .: 2
204   - 2015-02-04T23:00:46: Optimization status .......: converged
205   - 2015-02-04T23:00:46: Number of parameters ......: 11
206   - 2015-02-04T23:00:46: Number of free parameters .: 4
207   - 2015-02-04T23:00:46: Number of iterations ......: 3
208   - 2015-02-04T23:00:46: Lambda ....................: 1e-06
209   - 2015-02-04T23:00:46: Maximum log likelihood ....: -36734.127
210   - 2015-02-04T23:00:46: Observed events (Nobs) ...: 10685.000
211   - 2015-02-04T23:00:46: Predicted events (Npred) ..: 10685.000 (Nobs - Npred = 2.06522e-06)
212   - 2015-02-04T23:00:46: === GModels ===
213   - 2015-02-04T23:00:46: Number of models ..........: 2
214   - 2015-02-04T23:00:46: Number of parameters ......: 11
215   - 2015-02-04T23:00:46: === GModelSky ===
216   - 2015-02-04T23:00:46: Name ......................: Crab
217   - 2015-02-04T23:00:46: Instruments ...............: all
218   - 2015-02-04T23:00:46: Instrument scale factors ..: unity
219   - 2015-02-04T23:00:46: Observation identifiers ...: all
220   - 2015-02-04T23:00:46: Model type ................: PointSource
221   - 2015-02-04T23:00:46: Model components ..........: "SkyDirFunction" * "PowerLaw" * "Constant"
222   - 2015-02-04T23:00:46: Number of parameters ......: 6
223   - 2015-02-04T23:00:46: Number of spatial par's ...: 2
224   - 2015-02-04T23:00:46: RA .......................: 83.6331 [-360,360] deg (fixed,scale=1)
225   - 2015-02-04T23:00:46: DEC ......................: 22.0145 [-90,90] deg (fixed,scale=1)
226   - 2015-02-04T23:00:46: Number of spectral par's ..: 3
227   - 2015-02-04T23:00:46: Prefactor ................: 6.01471e-16 +/- 1.44183e-17 [1e-23,1e-13] ph/cm2/s/MeV (free,scale=1e-16,gradient)
228   - 2015-02-04T23:00:46: Index ....................: -2.49533 +/- 0.0179769 [-0,-5] (free,scale=-1,gradient)
229   - 2015-02-04T23:00:46: PivotEnergy ..............: 300000 [10000,1e+09] MeV (fixed,scale=1e+06,gradient)
230   - 2015-02-04T23:00:46: Number of temporal par's ..: 1
231   - 2015-02-04T23:00:46: Constant .................: 1 (relative value) (fixed,scale=1,gradient)
232   - 2015-02-04T23:00:46: === GCTAModelCubeBackground ===
233   - 2015-02-04T23:00:46: Name ......................: ctbkgcube default background model
234   - 2015-02-04T23:00:46: Instruments ...............: all
235   - 2015-02-04T23:00:46: Instrument scale factors ..: unity
236   - 2015-02-04T23:00:46: Observation identifiers ...: all
237   - 2015-02-04T23:00:46: Model type ................: "MapCubeFunction" * "PowerLaw" * "Constant"
238   - 2015-02-04T23:00:46: Number of parameters ......: 5
239   - 2015-02-04T23:00:46: Number of spatial par's ...: 1
240   - 2015-02-04T23:00:46: Normalization ............: 1 [0.001,1000] (fixed,scale=1,gradient)
241   - 2015-02-04T23:00:46: Number of spectral par's ..: 3
242   - 2015-02-04T23:00:46: Prefactor ................: 1.05876 +/- 0.0178132 [0,infty[ ph/cm2/s/MeV (free,scale=1,gradient)
243   - 2015-02-04T23:00:46: Index ....................: 0.00396962 +/- 0.00881842 [-10,10] (free,scale=1,gradient)
244   - 2015-02-04T23:00:46: PivotEnergy ..............: 1e+06 MeV (fixed,scale=1e+06,gradient)
245   - 2015-02-04T23:00:46: Number of temporal par's ..: 1
246   - 2015-02-04T23:00:46: Constant .................: 1 (relative value) (fixed,scale=1,gradient)
247   - 2015-02-04T23:00:46:
248   - 2015-02-04T23:00:46: +==============+
249   - 2015-02-04T23:00:46: | Save results |
250   - 2015-02-04T23:00:46: +==============+
251   - 2015-02-04T23:00:46:
252   - 2015-02-04T23:00:46: Application "ctlike" terminated after 43 wall clock seconds, consuming 21.5624 seconds of CPU time.
  189 + 2015-05-22T21:10:09: +=================================+
  190 + 2015-05-22T21:10:09: | Maximum likelihood optimisation |
  191 + 2015-05-22T21:10:09: +=================================+
  192 + 2015-05-22T21:10:10: >Iteration 0: -logL=60663.798, Lambda=1.0e-03
  193 + 2015-05-22T21:10:11: >Iteration 1: -logL=60642.413, Lambda=1.0e-03, delta=21.385, max(|grad|)=120.031102 [Index:7]
  194 + 2015-05-22T21:10:13: >Iteration 2: -logL=60642.233, Lambda=1.0e-04, delta=0.180, max(|grad|)=1.139187 [Index:7]
  195 + 2015-05-22T21:10:14: >Iteration 3: -logL=60642.233, Lambda=1.0e-05, delta=0.000, max(|grad|)=-0.001247 [Index:7]
  196 + 2015-05-22T21:10:16:
  197 + 2015-05-22T21:10:16: +=========================================+
  198 + 2015-05-22T21:10:16: | Maximum likelihood optimization results |
  199 + 2015-05-22T21:10:16: +=========================================+
  200 + 2015-05-22T21:10:16: === GOptimizerLM ===
  201 + 2015-05-22T21:10:16: Optimized function value ..: 60642.233
  202 + 2015-05-22T21:10:16: Absolute precision ........: 0.005
  203 + 2015-05-22T21:10:16: Acceptable value decrease .: 2
  204 + 2015-05-22T21:10:16: Optimization status .......: converged
  205 + 2015-05-22T21:10:16: Number of parameters ......: 10
  206 + 2015-05-22T21:10:16: Number of free parameters .: 4
  207 + 2015-05-22T21:10:16: Number of iterations ......: 3
  208 + 2015-05-22T21:10:16: Lambda ....................: 1e-06
  209 + 2015-05-22T21:10:16: Maximum log likelihood ....: -60642.233
  210 + 2015-05-22T21:10:16: Observed events (Nobs) ...: 25963.000
  211 + 2015-05-22T21:10:16: Predicted events (Npred) ..: 25963.000 (Nobs - Npred = 1.5749e-05)
  212 + 2015-05-22T21:10:16: === GModels ===
  213 + 2015-05-22T21:10:16: Number of models ..........: 2
  214 + 2015-05-22T21:10:16: Number of parameters ......: 10
  215 + 2015-05-22T21:10:16: === GModelSky ===
  216 + 2015-05-22T21:10:16: Name ......................: Crab
  217 + 2015-05-22T21:10:16: Instruments ...............: all
  218 + 2015-05-22T21:10:16: Instrument scale factors ..: unity
  219 + 2015-05-22T21:10:16: Observation identifiers ...: all
  220 + 2015-05-22T21:10:16: Model type ................: PointSource
  221 + 2015-05-22T21:10:16: Model components ..........: "SkyDirFunction" * "PowerLaw" * "Constant"
  222 + 2015-05-22T21:10:16: Number of parameters ......: 6
  223 + 2015-05-22T21:10:16: Number of spatial par's ...: 2
  224 + 2015-05-22T21:10:16: RA .......................: 83.6331 [-360,360] deg (fixed,scale=1)
  225 + 2015-05-22T21:10:16: DEC ......................: 22.0145 [-90,90] deg (fixed,scale=1)
  226 + 2015-05-22T21:10:16: Number of spectral par's ..: 3
  227 + 2015-05-22T21:10:16: Prefactor ................: 5.8499e-16 +/- 8.02289e-18 [1e-23,1e-13] ph/cm2/s/MeV (free,scale=1e-16,gradient)
  228 + 2015-05-22T21:10:16: Index ....................: -2.49909 +/- 0.0118976 [-0,-5] (free,scale=-1,gradient)
  229 + 2015-05-22T21:10:16: PivotEnergy ..............: 300000 [10000,1e+09] MeV (fixed,scale=1e+06,gradient)
  230 + 2015-05-22T21:10:16: Number of temporal par's ..: 1
  231 + 2015-05-22T21:10:16: Normalization ............: 1 (relative value) (fixed,scale=1,gradient)
  232 + 2015-05-22T21:10:16: === GCTAModelCubeBackground ===
  233 + 2015-05-22T21:10:16: Name ......................: BackgroundModel
  234 + 2015-05-22T21:10:16: Instruments ...............: CTA, HESS, MAGIC, VERITAS
  235 + 2015-05-22T21:10:16: Instrument scale factors ..: unity
  236 + 2015-05-22T21:10:16: Observation identifiers ...: all
  237 + 2015-05-22T21:10:16: Model type ................: "PowerLaw" * "Constant"
  238 + 2015-05-22T21:10:16: Number of parameters ......: 4
  239 + 2015-05-22T21:10:16: Number of spectral par's ..: 3
  240 + 2015-05-22T21:10:16: Prefactor ................: 1.08781 +/- 0.0212678 [0,infty[ ph/cm2/s/MeV (free,scale=1,gradient)
  241 + 2015-05-22T21:10:16: Index ....................: 0.0269681 +/- 0.0111532 [-10,10] (free,scale=1,gradient)
  242 + 2015-05-22T21:10:16: PivotEnergy ..............: 1e+06 MeV (fixed,scale=1e+06,gradient)
  243 + 2015-05-22T21:10:16: Number of temporal par's ..: 1
  244 + 2015-05-22T21:10:16: Normalization ............: 1 (relative value) (fixed,scale=1,gradient)
... ...
doc/source/user_manual/getting_started/beyond_tsmap.rst
... ... @@ -6,7 +6,7 @@ Generating a Test Statistic map
6 6 In the above examples we were always considering that we knew exactly
7 7 where the source is located, but in real life situations this may not
8 8 necessarily be the case.
9   -We thus need a mean to search for significant excess emission in our data.
  9 +We thus need a means to search for significant excess emission in our data.
10 10 One possibility to accomplish this task is to compute the Test Statistic
11 11 for a specific source at a grid of trial positions.
12 12 The :ref:`cttsmap` tool will exactly do that job.
... ... @@ -32,25 +32,25 @@ nominal position of the Crab nebula with a grid spacing of 0.02 degrees.
32 32  
33 33 $ cttsmap
34 34 Input event list, counts cube or observation definition file [events.fits] obs.xml
35   - Calibration database [dummy]
36   - Instrument response function [cta_dummy_irf]
  35 + Calibration database [prod2]
  36 + Instrument response function [South_50h]
37 37 Source model [$CTOOLS/share/models/crab.xml]
38 38 Test source [Crab]
39   - First coordinate of image center in degrees (RA or galactic l) [83.63]
40   - Second coordinate of image center in degrees (DEC or galactic b) [22.01]
41   - Projection method e.g. AIT|AZP|CAR|MER|STG|TAN (AIT|AZP|CAR|MER|STG|TAN) [CAR]
  39 + First coordinate of image center in degrees (RA or galactic l) (0-360) [83.63]
  40 + Second coordinate of image center in degrees (DEC or galactic b) (-90-90) [22.01]
  41 + Projection method (AIT|AZP|CAR|MER|MOL|STG|TAN) [CAR]
42 42 Coordinate system (CEL - celestial, GAL - galactic) (CEL|GAL) [CEL]
43 43 Image scale (in degrees/pixel) [0.02]
44 44 Size of the X axis in pixels [200] 10
45 45 Size of the Y axis in pixels [200] 10
46   - Output Test Statistic map [tsmap.fits]
  46 + Output Test Statistic map [tsmap.fits]
47 47  
48 48 :ref:`cttsmap` writes the Test Statistic map in the ``tsmap.fits`` file
49 49 that contains one extension for the Test Statistic value and further
50 50 extensions for the spectral parameters that have been fitted for the
51 51 source at each position of the grid.
52 52 The figure below show the Test Statistic map which reaches a maximum
53   -value of 13782 near the centre of the map.
  53 +value of 37484 near the centre of the map.
54 54  
55 55 .. figure:: tsmap-crab.png
56 56 :height: 400px
... ...
doc/source/user_manual/getting_started/caldb.tar.gz deleted
No preview for this file type
doc/source/user_manual/getting_started/irf-aeff.png 0 → 100644

3.24 KB

doc/source/user_manual/getting_started/irf-file.png 0 → 100644

7.1 KB

doc/source/user_manual/getting_started/models.rst
... ... @@ -319,22 +319,6 @@ CTA cube background
319 319 .. code-block:: xml
320 320  
321 321 <source name="Background" type="CTACubeBackground" instrument="CTA">
322   - <spatialModel type="GaussFunction">
323   - <parameter name="RA" scale="1.0" value="83.6221" min="0.0" max="360.0" free="0"/>
324   - <parameter name="DEC" scale="1.0" value="22.01" min="-90.0" max="90.0" free="0"/>
325   - <parameter name="Sigma" scale="1.0" value="1.0" min="0.0" max="10.0" free="0"/>
326   - </spatialModel>
327   - <spectrum type="...">
328   - ...
329   - </spectrum>
330   - </source>
331   -
332   - .. code-block:: xml
333   -
334   - <source name="Background" type="CTACubeBackground" instrument="CTA">
335   - <spatialModel type="MapCubeFunction" file="map_cube.fits">
336   - <parameter name="Normalization" scale="1" value="1" min="0.001" max="1000.0" free="0"/>
337   - </spatialModel>
338 322 <spectrum type="...">
339 323 ...
340 324 </spectrum>
... ...
doc/source/user_manual/getting_started/python.rst
... ... @@ -20,7 +20,7 @@ generally not very useful.
20 20  
21 21 .. warning::
22 22  
23   - The GammaLib module needs to be imported before the ctools
  23 + The GammaLib module needs to be imported **before** the ctools
24 24 module so that GammaLib class types are handled correctly.
25 25 So make sure that you **always import the GammaLib module before the ctools
26 26 module.**
... ... @@ -42,8 +42,8 @@ way as if it were executed from the command line.
42 42 >>> sim = ctools.ctobssim()
43 43 >>> sim["inmodel"].filename("${CTOOLS}/share/models/crab.xml")
44 44 >>> sim["outevents"].filename("events.fits")
45   - >>> sim["caldb"].string("dummy")
46   - >>> sim["irf"].string("cta_dummy_irf")
  45 + >>> sim["caldb"].string("prod2")
  46 + >>> sim["irf"].string("South_50h")
47 47 >>> sim["ra"].real(83.63)
48 48 >>> sim["dec"].real(22.01)
49 49 >>> sim["rad"].real(5.0)
... ... @@ -95,13 +95,13 @@ in that observation you may type:
95 95  
96 96 >>> print(sim.obs()[0].events())
97 97 === GCTAEventList ===
98   - Number of events ..........: 12152
  98 + Number of events ..........: 31928
99 99 Time interval .............: 51544.5 - 51544.5 days
100 100 === GEbounds ===
101 101 Number of intervals .......: 1
102 102 Energy range ..............: 100 GeV - 100 TeV
103 103 === GCTARoi ===
104   - ROI centre ................: RA=83.63, DEC=22.01 [0, 0]
  104 + ROI centre ................: RA=83.63, DEC=22.01 [0,0]
105 105 ROI radius ................: 5 deg
106 106  
107 107 The ``obs()[0]`` operator returns the first observation in the observation
... ... @@ -114,11 +114,12 @@ To see what kind of object you actually got, use:
114 114 >>> type(sim.obs()[0].events())
115 115 <class 'gammalib.cta.GCTAEventList'>
116 116  
117   -The CTA event list is implement as the ``GCTAEventList`` class in the
  117 +The CTA event list is implement by the ``GCTAEventList`` class in the
118 118 ``cta`` module of GammaLib.
119 119 To visualise the individual events you can iterate over the events using a
120 120 for loop.
121   -This will show the simulated celestial coordinates (RA, DEC), energies and
  121 +This will show the simulated celestial coordinates (RA, DEC), the
  122 +coordinate in the camera system [DETX, DETY], energies and
122 123 terrestrial times (TT) of all events.
123 124  
124 125 .. code-block:: python
... ... @@ -127,9 +128,9 @@ terrestrial times (TT) of all events.
127 128 >>> for event in events:
128 129 ... print(event)
129 130 ...
130   - Dir=RA=83.6477, DEC=22.0202 [0.000178879, 0.000286637] Energy=3.235 TeV Time=-3.15576e+08 s (TT)
131   - Dir=RA=83.482, DEC=22.0189 [0.000155643, -0.00239471] Energy=141.949 GeV Time=-3.15576e+08 s (TT)
132   - Dir=RA=83.6058, DEC=22.1586 [0.00259306, -0.000391919] Energy=316.376 GeV Time=-3.15576e+08 s (TT)
  131 + Dir=RA=83.5759, DEC=21.9757 [-0.000597839,-0.000875483] Energy=328.153 GeV Time=-3.15576e+08 s (TT)
  132 + Dir=RA=83.5775, DEC=22.0128 [4.88943e-05,-0.000849504] Energy=353.264 GeV Time=-3.15576e+08 s (TT)
  133 + Dir=RA=83.4302, DEC=21.931 [-0.00137616,-0.0032343] Energy=117.999 GeV Time=-3.15576e+08 s (TT)
133 134 ...
134 135  
135 136 .. note::
... ... @@ -150,13 +151,13 @@ terrestrial times (TT) of all events.
150 151 >>> sim.run()
151 152 >>> print(sim.obs()[0].events())
152 153 === GCTAEventList ===
153   - Number of events ..........: 6141
  154 + Number of events ..........: 15964
154 155 Time interval .............: 51544.5 - 51544.5 days
155 156 === GEbounds ===
156 157 Number of intervals .......: 1
157 158 Energy range ..............: 100 GeV - 100 TeV
158 159 === GCTARoi ===
159   - ROI centre ................: RA=83.63, DEC=22.01 [0, 0]
  160 + ROI centre ................: RA=83.63, DEC=22.01 [0,0]
160 161 ROI radius ................: 5 deg
161 162  
162 163  
... ... @@ -178,28 +179,30 @@ Where are the user parameters?
178 179 :ref:`ctlike` doesn't in fact need any as all the relevant information is
179 180 already contained in the observation container produced by the
180 181 :ref:`ctobssim` class.
181   -And you make have recognised that we constructed the :ref:`ctlike`
  182 +And you may have recognised that we constructed the :ref:`ctlike`
182 183 instance by using the :ref:`ctobssim` observation container as
183 184 constructor argument.
184 185  
185   -To check how the fit went you may inspect the optimiser class used by
  186 +To check how the fit went you can inspect the optimiser used by
186 187 :ref:`ctlike`:
187 188  
188 189 .. code-block:: python
189 190  
190 191 >>> print(like.opt())
191 192 === GOptimizerLM ===
192   - Optimized function value ..: 44578.761
  193 + Optimized function value ..: 101048.382
193 194 Absolute precision ........: 0.005
194 195 Acceptable value decrease .: 2
195 196 Optimization status .......: converged
196   - Number of parameters ......: 9
  197 + Number of parameters ......: 10
197 198 Number of free parameters .: 4
198   - Number of iterations ......: 3
199   - Lambda ....................: 1e-06
  199 + Number of iterations ......: 2
  200 + Lambda ....................: 1e-05
200 201  
201   -Apparently, the fit converged after fitting 4 parameters in 3 iterations.
202   -To inspect the fit results you may print the model container that is a
  202 +Apparently, the fit converged after 2 iterations.
  203 +Out of 10 parameters in the model 4 have been fitted (the others were kept
  204 +fixed).
  205 +To inspect the fit results you can print the model container that is a
203 206 member of the observation container:
204 207  
205 208 .. code-block:: python
... ... @@ -207,7 +210,7 @@ member of the observation container:
207 210 >>> print(like.obs().models())
208 211 === GModels ===
209 212 Number of models ..........: 2
210   - Number of parameters ......: 9
  213 + Number of parameters ......: 10
211 214 === GModelSky ===
212 215 Name ......................: Crab
213 216 Instruments ...............: all
... ... @@ -220,24 +223,24 @@ member of the observation container:
220 223 RA .......................: 83.6331 [-360,360] deg (fixed,scale=1)
221 224 DEC ......................: 22.0145 [-90,90] deg (fixed,scale=1)
222 225 Number of spectral par's ..: 3
223   - Prefactor ................: 6.13265e-16 +/- 2.05734e-17 [1e-23,1e-13] ph/cm2/s/MeV (free,scale=1e-16,gradient)
224   - Index ....................: -2.50565 +/- 0.0250831 [-0,-5] (free,scale=-1,gradient)
  226 + Prefactor ................: 5.80565e-16 +/- 1.11147e-17 [1e-23,1e-13] ph/cm2/s/MeV (free,scale=1e-16,gradient)
  227 + Index ....................: -2.49266 +/- 0.0163476 [-0,-5] (free,scale=-1,gradient)
225 228 PivotEnergy ..............: 300000 [10000,1e+09] MeV (fixed,scale=1e+06,gradient)
226 229 Number of temporal par's ..: 1
227   - Constant .................: 1 (relative value) (fixed,scale=1,gradient)
228   - === GCTAModelRadialAcceptance ===
229   - Name ......................: Background
  230 + Normalization ............: 1 (relative value) (fixed,scale=1,gradient)
  231 + === GCTAModelIrfBackground ===
  232 + Name ......................: CTABackgroundModel
230 233 Instruments ...............: CTA
231 234 Instrument scale factors ..: unity
232 235 Observation identifiers ...: all
233   - Model type ................: "Gaussian" * "FileFunction" * "Constant"
234   - Number of parameters ......: 3
235   - Number of radial par's ....: 1
236   - Sigma ....................: 3.03693 +/- 0.0304896 [0.01,10] deg2 (free,scale=1,gradient)
237   - Number of spectral par's ..: 1
238   - Normalization ............: 0.998667 +/- 0.0172585 [0,1000] (free,scale=1,gradient)
  236 + Model type ................: "PowerLaw" * "Constant"
  237 + Number of parameters ......: 4
  238 + Number of spectral par's ..: 3
  239 + Prefactor ................: 1.01701 +/- 0.0216563 [0.001,1000] ph/cm2/s/MeV (free,scale=1,gradient)
  240 + Index ....................: 0.0230864 +/- 0.0123006 [-5,5] (free,scale=1,gradient)
  241 + PivotEnergy ..............: 1e+06 [10000,1e+09] MeV (fixed,scale=1e+06,gradient)
239 242 Number of temporal par's ..: 1
240   - Constant .................: 1 (relative value) (fixed,scale=1,gradient)
  243 + Normalization ............: 1 (relative value) (fixed,scale=1,gradient)
241 244  
242 245 Suppose you want to repeat the fit by optimising also the position of the
243 246 point source.
... ... @@ -250,8 +253,8 @@ This is easy from Python:
250 253 >>> like.run()
251 254 >>> print(like.obs().models())
252 255 ...
253   - RA .......................: 83.633 +/- 0.00137216 [-360,360] deg (free,scale=1)
254   - DEC ......................: 22.0144 +/- 0.00127247 [-90,90] deg (free,scale=1)
  256 + RA .......................: 83.6341 +/- 0.000958947 [-360,360] deg (free,scale=1)
  257 + DEC ......................: 22.0139 +/- 0.000870912 [-90,90] deg (free,scale=1)
255 258  
256 259 The ``like.obs().models()`` method provides the model container, using the
257 260 ``["Crab"]`` operator we access the Crab model in that container and using
... ... @@ -293,12 +296,12 @@ the ``fix()`` method.
293 296 >>> print(like.obs())
294 297 === GObservations ===
295 298 Number of observations ....: 1
296   - Number of predicted events : 6141
  299 + Number of predicted events : 15964
297 300  
298 301 is okay as the ``ctools.ctlike(sim.obs())`` constructor will create
299 302 a copy of the observation container that lives within the :ref:`ctlike`
300 303 instance.
301   - To preserve an observation container after a ctools object went out
  304 + To preserve an observation container after a ctools object goes out
302 305 of scope you have to create a local copy of the container using the
303 306 ``copy()`` method:
304 307  
... ... @@ -327,8 +330,8 @@ Here an example of how to use ``obsutils``:
327 330 >>> import ctools
328 331 >>> from ctools import obsutils
329 332 >>> pattern = obsutils.set_obs_patterns("four", ra=83.63, dec=22.01, offset=1.0)
330   - >>> obs = obsutils.set_obs_list(pattern, duration=1800, emin=0.1, emax=100.0, rad=5.0, caldb="dummy", irf="cta_dummy_irf")
331   - >>> print(like.obs())
  333 + >>> obs = obsutils.set_obs_list(pattern, duration=1800, emin=0.1, emax=100.0, rad=5.0, caldb="prod2", irf="South_50h")
  334 + >>> print(obs)
332 335 === GObservations ===
333 336 Number of observations ....: 4
334 337 Number of predicted events : 0
... ... @@ -339,7 +342,7 @@ Here an example of how to use ``obsutils``:
339 342 >>> print(like.obs().models())
340 343 === GModels ===
341 344 Number of models ..........: 2
342   - Number of parameters ......: 9
  345 + Number of parameters ......: 10
343 346 ...
344 347  
345 348 The module is imported using the ``from ctools import obsutils`` directive.
... ...
doc/source/user_manual/getting_started/quickstart.rst
... ... @@ -39,14 +39,14 @@ type :ref:`ctobssim` at the console prompt (which is denoted by ``$``).
39 39 RA of pointing (degrees) (0-360) [83.63]
40 40 Dec of pointing (degrees) (-90-90) [22.01]
41 41 Radius of FOV (degrees) (0-180) [5.0]
42   - Start time (MET in s) (0) [0.0]
43   - End time (MET in s) (0) [1800.0]
44   - Lower energy limit (TeV) (0) [0.1]
45   - Upper energy limit (TeV) (0) [100.0]
46   - Calibration database [dummy]
47   - Instrument response function [cta_dummy_irf]
  42 + Start time (MET in s) [0.0]
  43 + End time (MET in s) [1800.0]
  44 + Lower energy limit (TeV) [0.1]
  45 + Upper energy limit (TeV) [100.0]
  46 + Calibration database [prod2]
  47 + Instrument response function [South_50h]
48 48 Model [$CTOOLS/share/models/crab.xml]
49   - Output event data file or observation definition file [events.fits]
  49 + Output event data file or observation definition file [events.fits]
50 50  
51 51 Each line represents a query for one parameter value.
52 52 The line starts with a short description of the parameter, followed by
... ... @@ -62,8 +62,18 @@ You may have recognised that the environment variable ``$CTOOLS`` has
62 62 been used in the path name of the model. ctools will automatically expand
63 63 the environment variables in parameter inputs.
64 64  
65   -The CTA instrument properties (effective area, PSF width) are taken for
66   -the moment from a dummy calibration database.
  65 +The CTA instrument properties (effective area, PSF width) are taken from
  66 +the prod2 database. The response for the southern array using the cuts
  67 +optimised for 50 hours of observing time are used.
  68 +
  69 +.. note::
  70 +
  71 + ctools comes bundled with CTA response functions for the northern and
  72 + the southern array. The response functions are based on a Prod2
  73 + analysis with cuts optimised for 0.5 hours, 5 hours and 50 hours of
  74 + observing time. The following Instrument Response Functions
  75 + (IRFs) are available: ``North_0.5h``, ``North_5h``, ``North_50h``,
  76 + ``South_0.5h``, ``South_5h``, and ``South_50h``.
67 77  
68 78 Events are simulated based on the instrument properties and based on a
69 79 source and background model. Only events that fall within the specified
... ... @@ -90,14 +100,13 @@ The source and background model is defined by the XML file
90 100 <parameter name="DEC" scale="1.0" value="22.0145" min="-90" max="90" free="0"/>
91 101 </spatialModel>
92 102 </source>
93   - <source name="Background" type="RadialAcceptance" instrument="CTA">
94   - <spectrum type="FileFunction" file="$CTOOLS/share/models/bkg_dummy.txt">
95   - <parameter scale="1.0" name="Normalization" min="0.0" max="1000.0" value="1.0" free="1"/>
  103 + <source name="CTABackgroundModel" type="CTAIrfBackground" instrument="CTA">
  104 + <spectrum type="PowerLaw">
  105 + <parameter name="Prefactor" scale="1.0" value="1.0" min="1e-3" max="1e+3" free="1"/>
  106 + <parameter name="Index" scale="1.0" value="0.0" min="-5.0" max="+5.0" free="1"/>
  107 + <parameter name="Scale" scale="1e6" value="1.0" min="0.01" max="1000.0" free="0"/>
96 108 </spectrum>
97   - <radialModel type="Gaussian">
98   - <parameter name="Sigma" scale="1.0" value="3.0" min="0.01" max="10.0" free="1"/>
99   - </radialModel>
100   - </source>
  109 + </source>
101 110 </source_library>
102 111  
103 112 The model consists of a source library that contains two components:
... ... @@ -107,14 +116,15 @@ The Crab nebula is modelled by a factorized sky model that has a spectral
107 116 and a spatial component (tags ``<spectrum>`` and ``<spatialModel>``,
108 117 respectively). The spectrum is modelled by a power law, which is defined by
109 118 three parameters: the ``Prefactor``, the ``Index`` and the ``Scale``.
110   -The spatial model has two parameters: Right Ascension in degrees (RA), and
111   -Declination in degrees (DEC). Each parameter has a value and a scale factor,
  119 +The spatial model has two parameters: Right Ascension in degrees (``RA``), and
  120 +Declination in degrees (``DEC``). Each parameter has a value and a scale factor,
112 121 the real value of the parameter being the product ``value * scale``. Typically,
113   -scale is chosen so that value is of the order of 1 (this is relevant for
114   -model fitting). In addition, value is bound by a minimum (min) and
115   -maximum (max) value, and a parameter may be free (``free="1"``) or fixed
116   -(``free="0"``). The min, max, and free attributes are not relevant here for
117   -the simulations, but they will be important for the model fitting later.
  122 +``scale`` is chosen so that ``value`` is of the order of 1 (this is relevant for
  123 +model fitting). In addition, ``value`` is bound by a minimum (``min``) and
  124 +maximum (``max``) value, and a parameter may be free (``free="1"``) or fixed
  125 +(``free="0"``). The ``min``, ``max``, and ``free`` attributes are not
  126 +relevant here for the simulations, but they will be important for the model
  127 +fitting later.
118 128  
119 129 The spectral intensity I(E) (in units of photons/cm2/s/MeV) of the power
120 130 law is given by
... ... @@ -128,19 +138,20 @@ where the parameters in the XML definition have the following mappings:
128 138 * :math:`\gamma` = ``Index``
129 139 * :math:`E_0` = ``Scale``
130 140  
131   -Note that energies are given in MeV. This is a GammaLib convention that
132   -can not be modified. **So make sure you always use MeV as energy unit in
133   -an XML file.**
  141 +.. warning::
  142 +
  143 + Energies are given in the XML file in MeV units. This is a GammaLib
  144 + convention that can not be modified. **So make sure you always use
  145 + MeV as energy unit in an XML file.**
134 146  
135   -The instrumental background of CTA is modelled by a factorized data model
136   -that has a spectral and a radial component (tags ``<spectrum>`` and
137   -``<radialModel>``, respectively). The spectral component describes the
138   -on-axis background counting rate of CTA as function of energy in units of
139   -counts/s/sr/MeV. The radial component describes the variation of the
140   -background rate with offset angle squared, (i.e. square of the offset angle
141   -with respect to the pointing direction) which is modelled here by a Gaussian.
142   -The only parameter of the radial component is the width of the Gaussian Sigma,
143   -which is here set to 3 degrees squared.
  147 +The instrumental background of CTA is modelled using the background
  148 +information provided in the IRF (``CTAIrfBackground``) multipled
  149 +by a power law. As it is defined here, the power law represents a
  150 +constant of 1, hence the background IRF will be used without any
  151 +modification. The power law will become active when fitting the data
  152 +later and allows a spectral adjustment of the background model that
  153 +may account for uncertainties in the background information provided
  154 +in the IRF.
144 155  
145 156 :ref:`ctobssim` has a couple of hidden parameters, the most important one being
146 157 certainly ``seed``. ``seed`` is an integer that specifies the seed value
... ... @@ -167,25 +178,25 @@ from this file are shown here:
167 178  
168 179 .. code-block:: xml
169 180  
170   - 2015-02-04T15:04:56: +======================+
171   - 2015-02-04T15:04:56: | Simulate observation |
172   - 2015-02-04T15:04:56: +======================+
173   - 2015-02-04T15:04:56: === Observation ===
174   - 2015-02-04T15:04:56: Simulation area ...........: 1.9635e+11 cm2
175   - 2015-02-04T15:04:56: Simulation cone ...........: RA=83.63 deg, Dec=22.01 deg, r=5.5 deg
176   - 2015-02-04T15:04:56: Time interval .............: 0 - 1800 s
177   - 2015-02-04T15:04:56: Photon energy range .......: 100 GeV - 100 TeV
178   - 2015-02-04T15:04:56: Event energy range ........: 100 GeV - 100 TeV
179   - 2015-02-04T15:04:56: MC source photons .........: 207547 [Crab]
180   - 2015-02-04T15:04:56: MC source events ..........: 995 [Crab]
181   - 2015-02-04T15:04:56: MC source events ..........: 995 (all source models)
182   - 2015-02-04T15:04:56: MC background events ......: 5146
183   - 2015-02-04T15:04:56: MC events .................: 6141 (all models)
  181 + 2015-05-22T19:24:53: +======================+
  182 + 2015-05-22T19:24:53: | Simulate observation |
  183 + 2015-05-22T19:24:53: +======================+
  184 + 2015-05-22T19:24:53: === Observation ===
  185 + 2015-05-22T19:24:53: Simulation area ...........: 1.9635e+11 cm2
  186 + 2015-05-22T19:24:53: Simulation cone ...........: RA=83.63 deg, Dec=22.01 deg, r=5.5 deg
  187 + 2015-05-22T19:24:53: Time interval .............: 0 - 1800 s
  188 + 2015-05-22T19:24:53: Photon energy range .......: 100 GeV - 100 TeV
  189 + 2015-05-22T19:24:53: Event energy range ........: 100 GeV - 100 TeV
  190 + 2015-05-22T19:24:53: MC source photons .........: 207547 [Crab]
  191 + 2015-05-22T19:24:53: MC source events ..........: 2961 [Crab]
  192 + 2015-05-22T19:24:53: MC source events ..........: 2961 (all source models)
  193 + 2015-05-22T19:24:55: MC background events ......: 13003
  194 + 2015-05-22T19:24:55: MC events .................: 15964 (all models)
184 195  
185 196 Each line starts with the UTC time at which the line has been written. In
186 197 this run, 207547 Crab photons have been thrown over an area of 19.6 square
187   -kilometres during a time interval of 1800 seconds. 995 of these photons have
188   -been registered by CTA as events. In the same time interval, 5146 background
  198 +kilometres during a time interval of 1800 seconds. 2961 of these photons have
  199 +been registered by CTA as events. In the same time interval, 13003 background
189 200 events have been registred by CTA.
190 201  
191 202 You may change the name of the log file using the hidden parameter
... ... @@ -233,9 +244,9 @@ control).
233 244  
234 245 $ ctbin
235 246 Event list or observation definition file [events.fits]
236   - First coordinate of image center in degrees (RA or galactic l) [83.63]
237   - Second coordinate of image center in degrees (DEC or galactic b) [22.01]
238   - Projection method e.g. AIT|AZP|CAR|MER|STG|TAN (AIT|AZP|CAR|MER|STG|TAN) [CAR]
  247 + First coordinate of image center in degrees (RA or galactic l) (0-360) [83.63]
  248 + Second coordinate of image center in degrees (DEC or galactic b) (-90-90) [22.01]
  249 + Projection method (AIT|AZP|CAR|MER|MOL|STG|TAN) [CAR]
239 250 Coordinate system (CEL - celestial, GAL - galactic) (CEL|GAL) [CEL]
240 251 Image scale (in degrees/pixel) [0.02]
241 252 Size of the X axis in pixels [200]
... ... @@ -244,7 +255,7 @@ control).
244 255 Start value for first energy bin in TeV [0.1]
245 256 Stop value for last energy bin in TeV [100.0]
246 257 Number of energy bins [20]
247   - Output counts cube [cntcube.fits]
  258 + Output counts cube [cntcube.fits]
248 259  
249 260 The counts cube will be centred on the location of the Crab (Right Ascension
250 261 83.63 degrees, Declination 22.01 degrees) and will be aligned in celestial
... ... @@ -285,41 +296,18 @@ reproduced below:
285 296  
286 297 .. code-block:: xml
287 298  
288   - 2015-02-04T15:33:34: +====================+
289   - 2015-02-04T15:33:34: | Binned observation |
290   - 2015-02-04T15:33:34: +====================+
291   - 2015-02-04T15:33:34: === GObservations ===
292   - 2015-02-04T15:33:34: Number of observations ....: 1
293   - 2015-02-04T15:33:34: Number of predicted events : 0
294   - 2015-02-04T15:33:34: === GCTAObservation ===
295   - 2015-02-04T15:33:34: Name ......................:
296   - 2015-02-04T15:33:34: Identifier ................:
297   - 2015-02-04T15:33:34: Instrument ................: CTA
298   - 2015-02-04T15:33:34: Event file ................:
299   - 2015-02-04T15:33:34: Event type ................: CountsCube
300   - 2015-02-04T15:33:34: Statistics ................: Poisson
301   - 2015-02-04T15:33:34: Ontime ....................: 1800 s
302   - 2015-02-04T15:33:34: Livetime ..................: 1710 s
303   - 2015-02-04T15:33:34: Deadtime correction .......: 0.95
304   - 2015-02-04T15:33:34: User energy range .........: undefined
305   - 2015-02-04T15:33:34: === GCTAPointing ===
306   - 2015-02-04T15:33:34: Pointing direction ........: (RA,Dec)=(83.63,22.01)
307   - 2015-02-04T15:33:34: Response function .........: undefined
308   - 2015-02-04T15:33:34: === GCTAEventCube ===
309   - 2015-02-04T15:33:34: Number of events ..........: 5542
310   - 2015-02-04T15:33:34: Number of elements ........: 800000
311   - 2015-02-04T15:33:34: Number of pixels ..........: 40000
312   - 2015-02-04T15:33:34: Number of energy bins .....: 20
313   - 2015-02-04T15:33:34: Time interval .............: 0 - 1800 sec
314   - 2015-02-04T15:33:34:
315   - 2015-02-04T15:33:34: +==================+
316   - 2015-02-04T15:33:34: | Save observation |
317   - 2015-02-04T15:33:34: +==================+
318   - 2015-02-04T15:33:34:
319   - 2015-02-04T15:33:34: Application "ctbin" terminated after 14 wall clock seconds, consuming 0.332675 seconds of CPU time.
320   -
321   -From the 6141 events that have been simulated and stored in the
322   -``events.fits`` file, 5542 lie within the cube boundaries and are thus put
  299 + 2015-05-22T19:40:30: +=================+
  300 + 2015-05-22T19:40:30: | Bin observation |
  301 + 2015-05-22T19:40:30: +=================+
  302 + 2015-05-22T19:40:30: === Observation ===
  303 + 2015-05-22T19:40:30: Events in list ............: 15964
  304 + 2015-05-22T19:40:30: Events in cube ............: 13360
  305 + 2015-05-22T19:40:30: Event bins outside RoI ....: 0
  306 + 2015-05-22T19:40:30: Events outside cube area ..: 2604
  307 + 2015-05-22T19:40:30: Events outside energy bins : 0
  308 +
  309 +From the 15964 events that have been simulated and stored in the
  310 +``events.fits`` file, 13360 lie within the cube boundaries and are thus put
323 311 into the resulting counts cube. The counts cube is stored in a cartesian
324 312 projection in a World Coordinate System (WCS) compliant format.
325 313  
... ... @@ -340,12 +328,13 @@ and we do the fit by typing:
340 328 Event list, counts cube or observation definition file [events.fits] cntcube.fits
341 329 Exposure cube file (only needed for stacked analysis) [NONE]
342 330 PSF cube file (only needed for stacked analysis) [NONE]
343   - Calibration database [dummy]
344   - Instrument response function [cta_dummy_irf]
  331 + Background cube file (only needed for stacked analysis) [NONE]
  332 + Calibration database [prod2]
  333 + Instrument response function [South_50h]
345 334 Source model [$CTOOLS/share/models/crab.xml]
346 335 Source model output file [crab_results.xml]
347 336  
348   -Fitting of the data is done in *binned* mode, which means that the events
  337 +The data are fitted in *binned* mode, which means that the events
349 338 have been binned into a counts cube and the fit computes the log-likelihood
350 339 function by summing over all 200 x 200 x 20 bins of the counts cube. There is
351 340 an alternative method, the so called *unbinned* mode, where the events are
... ... @@ -356,8 +345,8 @@ One of the parameters of :ref:`ctlike` is a source model output file
356 345 (we specified ``crab_results.xml`` in the example), and this file will be
357 346 a copy of the source model input XML file where the parameter values have
358 347 been replaced by the fit results. In addition, the statistical uncertainties
359   -are added for each fitted parameter using the attribute error. Below we show
360   -the XML result file that has been produced by the run:
  348 +are added for each fitted parameter using the attribute ``error``.
  349 +Below we show the XML result file that has been produced by the run:
361 350  
362 351 .. code-block:: xml
363 352  
... ... @@ -365,8 +354,8 @@ the XML result file that has been produced by the run:
365 354 <source_library title="source library">
366 355 <source name="Crab" type="PointSource">
367 356 <spectrum type="PowerLaw">
368   - <parameter name="Prefactor" value="6.07928" error="0.204582" scale="1e-16" min="1e-07" max="1000" free="1" />
369   - <parameter name="Index" value="2.5009" error="0.0252057" scale="-1" min="0" max="5" free="1" />
  357 + <parameter name="Prefactor" value="5.78197" error="0.110889" scale="1e-16" min="1e-07" max="1000" free="1" />
  358 + <parameter name="Index" value="2.49174" error="0.0164369" scale="-1" min="0" max="5" free="1" />
370 359 <parameter name="Scale" value="0.3" scale="1e+06" min="0.01" max="1000" free="0" />
371 360 </spectrum>
372 361 <spatialModel type="SkyDirFunction">
... ... @@ -374,20 +363,31 @@ the XML result file that has been produced by the run:
374 363 <parameter name="DEC" value="22.0145" scale="1" min="-90" max="90" free="0" />
375 364 </spatialModel>
376 365 </source>
377   - <source name="Background" type="RadialAcceptance" instrument="CTA">
378   - <spectrum type="FileFunction" file="$CTOOLS/share/models/bkg_dummy.txt">
379   - <parameter name="Normalization" value="0.990708" error="0.0192887" scale="1" min="0" max="1000" free="1" />
  366 + <source name="CTABackgroundModel" type="CTAIrfBackground" instrument="CTA">
  367 + <spectrum type="PowerLaw">
  368 + <parameter name="Prefactor" value="1.02048" error="0.0280684" scale="1" min="0.001" max="1000" free="1" />
  369 + <parameter name="Index" value="0.0197856" error="0.0156686" scale="1" min="-5" max="5" free="1" />
  370 + <parameter name="Scale" value="1" scale="1e+06" min="0.01" max="1000" free="0" />
380 371 </spectrum>
381   - <radialModel type="Gaussian">
382   - <parameter name="Sigma" value="3.02523" error="0.0594117" scale="1" min="0.01" max="10" free="1" />
383   - </radialModel>
384 372 </source>
385 373 </source_library>
386 374  
387 375 In this example, the ``Prefactor`` and ``Index`` of the spectral model for the
388   -Crab as well as the ``Normalization`` and ``Sigma`` parameter of the radial
389   -acceptance model have been fitted (all parameters having the attribute
390   -``free="1"`` are fitted).
  376 +Crab as well as the ``Prefactor`` and ``Index`` of the background spectral
  377 +model have been fitted (all parameters having the attribute ``free="1"`` are
  378 +fitted). Now we see also the effect of having multiplied the background
  379 +model with a power law. In that way, the amplitude of the background as
  380 +well as it's spectral slope is adjusted by the fit. Obviously, in this
  381 +example the adjustment compensates only for the statistical fluctuations
  382 +of the background, but with real data, the adjustment may account also for
  383 +some of the systematic uncertainties.
  384 +
  385 +.. warning::
  386 +
  387 + As good practice, the amplitude of the background model should always be
  388 + left as a free parameter of the fit. Otherwise, any uncertainty in the
  389 + background rate will immediately propagate into the flux estimate of the
  390 + source.
391 391  
392 392 To get more details about the model fitting you can inspect the log file.
393 393 Below the last lines of the ctlike.log log file that has been produced by
... ... @@ -395,70 +395,63 @@ this run:
395 395  
396 396 .. code-block:: xml
397 397  
398   - 2015-02-04T15:50:43: +=================================+
399   - 2015-02-04T15:50:43: | Maximum likelihood optimisation |
400   - 2015-02-04T15:50:43: +=================================+
401   - 2015-02-04T15:50:44: >Iteration 0: -logL=22752.553, Lambda=1.0e-03
402   - 2015-02-04T15:50:46: >Iteration 1: -logL=22750.640, Lambda=1.0e-03, delta=1.913, max(|grad|)=-0.941594 [Index:3]
403   - 2015-02-04T15:50:47: >Iteration 2: -logL=22750.632, Lambda=1.0e-04, delta=0.008, max(|grad|)=-0.079270 [Index:3]
404   - 2015-02-04T15:50:48: >Iteration 3: -logL=22750.632, Lambda=1.0e-05, delta=0.000, max(|grad|)=-0.003073 [Index:3]
405   - 2015-02-04T15:50:49:
406   - 2015-02-04T15:50:49: +=========================================+
407   - 2015-02-04T15:50:49: | Maximum likelihood optimization results |
408   - 2015-02-04T15:50:49: +=========================================+
409   - 2015-02-04T15:50:49: === GOptimizerLM ===
410   - 2015-02-04T15:50:49: Optimized function value ..: 22750.632
411   - 2015-02-04T15:50:49: Absolute precision ........: 0.005
412   - 2015-02-04T15:50:49: Acceptable value decrease .: 2
413   - 2015-02-04T15:50:49: Optimization status .......: converged
414   - 2015-02-04T15:50:49: Number of parameters ......: 9
415   - 2015-02-04T15:50:49: Number of free parameters .: 4
416   - 2015-02-04T15:50:49: Number of iterations ......: 3
417   - 2015-02-04T15:50:49: Lambda ....................: 1e-06
418   - 2015-02-04T15:50:49: Maximum log likelihood ....: -22750.632
419   - 2015-02-04T15:50:49: Observed events (Nobs) ...: 5542.000
420   - 2015-02-04T15:50:49: Predicted events (Npred) ..: 5542.000 (Nobs - Npred = 3.3498e-06)
421   - 2015-02-04T15:50:49: === GModels ===
422   - 2015-02-04T15:50:49: Number of models ..........: 2
423   - 2015-02-04T15:50:49: Number of parameters ......: 9
424   - 2015-02-04T15:50:49: === GModelSky ===
425   - 2015-02-04T15:50:49: Name ......................: Crab
426   - 2015-02-04T15:50:49: Instruments ...............: all
427   - 2015-02-04T15:50:49: Instrument scale factors ..: unity
428   - 2015-02-04T15:50:49: Observation identifiers ...: all
429   - 2015-02-04T15:50:49: Model type ................: PointSource
430   - 2015-02-04T15:50:49: Model components ..........: "SkyDirFunction" * "PowerLaw" * "Constant"
431   - 2015-02-04T15:50:49: Number of parameters ......: 6
432   - 2015-02-04T15:50:49: Number of spatial par's ...: 2
433   - 2015-02-04T15:50:49: RA .......................: 83.6331 [-360,360] deg (fixed,scale=1)
434   - 2015-02-04T15:50:49: DEC ......................: 22.0145 [-90,90] deg (fixed,scale=1)
435   - 2015-02-04T15:50:49: Number of spectral par's ..: 3
436   - 2015-02-04T15:50:49: Prefactor ................: 6.07928e-16 +/- 2.04582e-17 [1e-23,1e-13] ph/cm2/s/MeV (free,scale=1e-16,gradient)
437   - 2015-02-04T15:50:49: Index ....................: -2.5009 +/- 0.0252057 [-0,-5] (free,scale=-1,gradient)
438   - 2015-02-04T15:50:49: PivotEnergy ..............: 300000 [10000,1e+09] MeV (fixed,scale=1e+06,gradient)
439   - 2015-02-04T15:50:49: Number of temporal par's ..: 1
440   - 2015-02-04T15:50:49: Constant .................: 1 (relative value) (fixed,scale=1,gradient)
441   - 2015-02-04T15:50:49: === GCTAModelRadialAcceptance ===
442   - 2015-02-04T15:50:49: Name ......................: Background
443   - 2015-02-04T15:50:49: Instruments ...............: CTA
444   - 2015-02-04T15:50:49: Instrument scale factors ..: unity
445   - 2015-02-04T15:50:49: Observation identifiers ...: all
446   - 2015-02-04T15:50:49: Model type ................: "Gaussian" * "FileFunction" * "Constant"
447   - 2015-02-04T15:50:49: Number of parameters ......: 3
448   - 2015-02-04T15:50:49: Number of radial par's ....: 1
449   - 2015-02-04T15:50:49: Sigma ....................: 3.02523 +/- 0.0594117 [0.01,10] deg2 (free,scale=1,gradient)
450   - 2015-02-04T15:50:49: Number of spectral par's ..: 1
451   - 2015-02-04T15:50:49: Normalization ............: 0.990708 +/- 0.0192887 [0,1000] (free,scale=1,gradient)
452   - 2015-02-04T15:50:49: Number of temporal par's ..: 1
453   - 2015-02-04T15:50:49: Constant .................: 1 (relative value) (fixed,scale=1,gradient)
454   - 2015-02-04T15:50:49:
455   - 2015-02-04T15:50:49: +==============+
456   - 2015-02-04T15:50:49: | Save results |
457   - 2015-02-04T15:50:49: +==============+
458   - 2015-02-04T15:50:49:
459   - 2015-02-04T15:50:49: Application "ctlike" terminated after 15 wall clock seconds, consuming 5.92686 seconds of CPU time.
460   -
461   -The maximum likelihood optimizer required 3 iterations to converge. This
  398 + 2015-05-22T19:45:15: +=================================+
  399 + 2015-05-22T19:45:15: | Maximum likelihood optimisation |
  400 + 2015-05-22T19:45:15: +=================================+
  401 + 2015-05-22T19:45:16: >Iteration 0: -logL=39910.748, Lambda=1.0e-03
  402 + 2015-05-22T19:45:18: >Iteration 1: -logL=39908.788, Lambda=1.0e-03, delta=1.960, max(|grad|)=6.701856 [Index:7]
  403 + 2015-05-22T19:45:19: >Iteration 2: -logL=39908.787, Lambda=1.0e-04, delta=0.001, max(|grad|)=-0.057041 [Index:3]
  404 + 2015-05-22T19:45:21:
  405 + 2015-05-22T19:45:21: +=========================================+
  406 + 2015-05-22T19:45:21: | Maximum likelihood optimization results |
  407 + 2015-05-22T19:45:21: +=========================================+
  408 + 2015-05-22T19:45:21: === GOptimizerLM ===
  409 + 2015-05-22T19:45:21: Optimized function value ..: 39908.787
  410 + 2015-05-22T19:45:21: Absolute precision ........: 0.005
  411 + 2015-05-22T19:45:21: Acceptable value decrease .: 2
  412 + 2015-05-22T19:45:21: Optimization status .......: converged
  413 + 2015-05-22T19:45:21: Number of parameters ......: 10
  414 + 2015-05-22T19:45:21: Number of free parameters .: 4
  415 + 2015-05-22T19:45:21: Number of iterations ......: 2
  416 + 2015-05-22T19:45:21: Lambda ....................: 1e-05
  417 + 2015-05-22T19:45:21: Maximum log likelihood ....: -39908.787
  418 + 2015-05-22T19:45:21: Observed events (Nobs) ...: 13360.000
  419 + 2015-05-22T19:45:21: Predicted events (Npred) ..: 13359.998 (Nobs - Npred = 0.00180799)
  420 + 2015-05-22T19:45:21: === GModels ===
  421 + 2015-05-22T19:45:21: Number of models ..........: 2
  422 + 2015-05-22T19:45:21: Number of parameters ......: 10
  423 + 2015-05-22T19:45:21: === GModelSky ===
  424 + 2015-05-22T19:45:21: Name ......................: Crab
  425 + 2015-05-22T19:45:21: Instruments ...............: all
  426 + 2015-05-22T19:45:21: Instrument scale factors ..: unity
  427 + 2015-05-22T19:45:21: Observation identifiers ...: all
  428 + 2015-05-22T19:45:21: Model type ................: PointSource
  429 + 2015-05-22T19:45:21: Model components ..........: "SkyDirFunction" * "PowerLaw" * "Constant"
  430 + 2015-05-22T19:45:21: Number of parameters ......: 6
  431 + 2015-05-22T19:45:21: Number of spatial par's ...: 2
  432 + 2015-05-22T19:45:21: RA .......................: 83.6331 [-360,360] deg (fixed,scale=1)
  433 + 2015-05-22T19:45:21: DEC ......................: 22.0145 [-90,90] deg (fixed,scale=1)
  434 + 2015-05-22T19:45:21: Number of spectral par's ..: 3
  435 + 2015-05-22T19:45:21: Prefactor ................: 5.78197e-16 +/- 1.10889e-17 [1e-23,1e-13] ph/cm2/s/MeV (free,scale=1e-16,gradient)
  436 + 2015-05-22T19:45:21: Index ....................: -2.49174 +/- 0.0164369 [-0,-5] (free,scale=-1,gradient)
  437 + 2015-05-22T19:45:21: PivotEnergy ..............: 300000 [10000,1e+09] MeV (fixed,scale=1e+06,gradient)
  438 + 2015-05-22T19:45:21: Number of temporal par's ..: 1
  439 + 2015-05-22T19:45:21: Normalization ............: 1 (relative value) (fixed,scale=1,gradient)
  440 + 2015-05-22T19:45:21: === GCTAModelIrfBackground ===
  441 + 2015-05-22T19:45:21: Name ......................: CTABackgroundModel
  442 + 2015-05-22T19:45:21: Instruments ...............: CTA
  443 + 2015-05-22T19:45:21: Instrument scale factors ..: unity
  444 + 2015-05-22T19:45:21: Observation identifiers ...: all
  445 + 2015-05-22T19:45:21: Model type ................: "PowerLaw" * "Constant"
  446 + 2015-05-22T19:45:21: Number of parameters ......: 4
  447 + 2015-05-22T19:45:21: Number of spectral par's ..: 3
  448 + 2015-05-22T19:45:21: Prefactor ................: 1.02048 +/- 0.0280684 [0.001,1000] ph/cm2/s/MeV (free,scale=1,gradient)
  449 + 2015-05-22T19:45:21: Index ....................: 0.0197856 +/- 0.0156686 [-5,5] (free,scale=1,gradient)
  450 + 2015-05-22T19:45:21: PivotEnergy ..............: 1e+06 [10000,1e+09] MeV (fixed,scale=1e+06,gradient)
  451 + 2015-05-22T19:45:21: Number of temporal par's ..: 1
  452 + 2015-05-22T19:45:21: Normalization ............: 1 (relative value) (fixed,scale=1,gradient)
  453 +
  454 +The maximum likelihood optimizer required 2 iterations to converge. This
462 455 is pretty fast, but recall that we used the same model file for the simulation
463 456 and for fitting, hence the initial parameter values were already very close
464 457 to the best fitting values. To see the impact of the initial parameters on
... ... @@ -466,7 +459,7 @@ the fit result, you may re-run :ref:`ctlike` using another copy of the model
466 459 XML file where you change the value attributes of the parameters that should be
467 460 fitted. You will see that the optimizer requires a couple of more iterations,
468 461 but it should converge to the same solution (provided that the initial values
469   -are not too far of the best fitting values).
  462 +are not too far from the best fitting values).
470 463  
471 464 .. note::
472 465  
... ... @@ -502,17 +495,17 @@ are not too far of the best fitting values).
502 495  
503 496 .. code-block:: xml
504 497  
505   - 2015-02-05T08:29:07: === GModelSky ===
506   - 2015-02-05T08:29:07: Name ......................: Crab
507   - 2015-02-05T08:29:07: Instruments ...............: all
508   - 2015-02-05T08:29:07: Test Statistic ............: 6875.35
  498 + 2015-05-22T19:58:43: === GModelSky ===
  499 + 2015-05-22T19:58:43: Name ......................: Crab
  500 + 2015-05-22T19:58:43: Instruments ...............: all
  501 + 2015-05-22T19:58:43: Test Statistic ............: 18662.6
509 502  
510 503 The Test Statistic value will also be added as new attribute
511 504 ``ts`` to the XML result file:
512 505  
513 506 .. code-block:: xml
514 507  
515   - <source name="Crab" type="PointSource" ts="6875.350" tscalc="1">
  508 + <source name="Crab" type="PointSource" ts="18662.576" tscalc="1">
516 509  
517 510  
518 511 .. _sec_unbinned_cta:
... ... @@ -521,8 +514,8 @@ Doing an unbinned analysis
521 514 ~~~~~~~~~~~~~~~~~~~~~~~~~~
522 515  
523 516 As gamma-ray events are rare, the counts cubes generated by :ref:`ctbin`
524   -will in general be sparse, having many empty pixels, in particular at
525   -high energies.
  517 +will in general be sparsly populated, having many empty pixels, in
  518 +particular at high energies.
526 519 An alternative analysis technique consists of working directly on the event
527 520 list without binning the events in a counts cube. We will see the benefit of
528 521 such an analysis later once you re-run :ref:`ctlike` in unbinned mode.
... ... @@ -553,10 +546,10 @@ following example shows how to run ctselect:
553 546 RA for ROI centre (degrees) (0-360) [83.63]
554 547 Dec for ROI centre (degrees) (-90-90) [22.01]
555 548 Radius of ROI (degrees) (0-180) [3.0]
556   - Start time (CTA MET in seconds) (0) [0.0]
557   - End time (CTA MET in seconds) (0) [0.0]
558   - Lower energy limit (TeV) (0) [0.1]
559   - Upper energy limit (TeV) (0) [100.0]
  549 + Start time (CTA MET in seconds) [0.0]
  550 + End time (CTA MET in seconds) [0.0]
  551 + Lower energy limit (TeV) [0.1]
  552 + Upper energy limit (TeV) [100.0]
560 553 Output event list or observation definition file [selected_events.fits]
561 554  
562 555 :ref:`ctselect` takes the input event list ``events.fits``, performs an
... ... @@ -585,16 +578,16 @@ part:
585 578  
586 579 .. code-block:: xml
587 580  
588   - 2015-02-04T17:21:41: +=================+
589   - 2015-02-04T17:21:41: | Event selection |
590   - 2015-02-04T17:21:41: +=================+
591   - 2015-02-04T17:21:41: === Observation ===
592   - 2015-02-04T17:21:41: Selected energy range .....: 0.1 - 100 TeV
593   - 2015-02-04T17:21:41: Requested ROI .............: Centre(RA,DEC)=(83.63, 22.01) deg, Radius=3 deg
594   - 2015-02-04T17:21:41: ROI of data ...............: Centre(RA,DEC)=(83.63, 22.01) deg, Radius=5 deg
595   - 2015-02-04T17:21:41: Selected ROI ..............: Centre(RA,DEC)=(83.63, 22.01) deg, Radius=3 deg
596   - 2015-02-04T17:21:41: cfitsio selection .........: ENERGY >= 0.10000000 && ENERGY <= 100.00000000 && ANGSEP(83.630000,22.010000,RA,DEC) <= 3.000000
597   - 2015-02-04T17:21:41: FITS filename .............: /var/tmp/tmp.0.pTIaTL[EVENTS][ENERGY >= 0.10000000 && ENERGY <= 100.00000000 && ANGSEP(83.630000,22.010000,RA,DEC) <= 3.000000]
  581 + 2015-05-22T20:01:46: +=================+
  582 + 2015-05-22T20:01:46: | Event selection |
  583 + 2015-05-22T20:01:46: +=================+
  584 + 2015-05-22T20:01:46: === Observation ===
  585 + 2015-05-22T20:01:47: Selected energy range .....: 0.1 - 100 TeV
  586 + 2015-05-22T20:01:47: Requested ROI .............: Centre(RA,DEC)=(83.63, 22.01) deg, Radius=3 deg
  587 + 2015-05-22T20:01:47: ROI of data ...............: Centre(RA,DEC)=(83.63, 22.01) deg, Radius=5 deg
  588 + 2015-05-22T20:01:47: Selected ROI ..............: Centre(RA,DEC)=(83.63, 22.01) deg, Radius=3 deg
  589 + 2015-05-22T20:01:47: cfitsio selection .........: ENERGY >= 0.10000000 && ENERGY <= 100.00000000 && ANGSEP(83.630000,22.010000,RA,DEC) <= 3.000000
  590 + 2015-05-22T20:01:47: FITS filename .............: /var/tmp/tmp.0.rRgLpO[EVENTS][ENERGY >= 0.10000000 && ENERGY <= 100.00000000 && ANGSEP(83.630000,22.010000,RA,DEC) <= 3.000000]
598 591  
599 592 .. note::
600 593  
... ... @@ -608,10 +601,10 @@ part:
608 601 :ref:`ctselect` will automatically adjust
609 602 the selection parameters to guarantee full enclosure. To keep track of
610 603 this adjustment, the :ref:`ctselect` log file quotes the requested
611   - selection, and existing selections, and the selection that was finally
  604 + selection, any existing selections, and the selection that was finally
612 605 applied.
613 606  
614   -.. note::
  607 +.. warning::
615 608  
616 609 :ref:`ctselect` may of course also be used for event selection prior to
617 610 binned analysis, for example to select events for a given period in
... ... @@ -627,24 +620,25 @@ instead of the counts cube:
627 620  
628 621 .. code-block:: bash
629 622  
630   - $ ctlike
631   - Event list, counts cube or observation definition file [cntmap.fits] selected_events.fits
632   - Calibration database [dummy]
633   - Instrument response function [cta_dummy_irf]
634   - Source model [$CTOOLS/share/models/crab.xml]
635   - Source model output file [crab_results.xml]
  623 + $ ctlike
  624 + Event list, counts cube or observation definition file [cntcube.fits] selected_events.fits
  625 + Calibration database [prod2]
  626 + Instrument response function [South_50h]
  627 + Source model [$CTOOLS/share/models/crab.xml]
  628 + Source model output file [crab_results.xml]
636 629  
637 630 You will recognise that :ref:`ctlike` runs much faster in unbinned mode
638 631 compared to binned mode.
639 632 This is understandable as the selected event list contains
640   -only 6127 events, while the binned counts cube we used before had
  633 +only 15312 events, while the binned counts cube we used before had
641 634 200 x 200 x 20 = 800000 pixels. As unbinned maximum likelihood fitting loops
642 635 over the events (while binned maximum likelihood loops over the pixels),
643 636 there are much less operations to perform in unbinned than in binned mode
644 637 (there is some additional overhead in unbinned mode that comes from
645 638 integrating the models over the region of interest, yet this is negligible
646   -compared to the operations needed when looping over the pixels). So as long
647   -as you work with short event lists, unbinned mode is faster.
  639 +compared to the operations needed when looping over all pixels). So as long
  640 +as you work with small event lists, unbinned mode is faster (this
  641 +typically holds up to 100 hours of observing time).
648 642 Unbinned :ref:`ctlike` should also be more precise as no binning is performed,
649 643 hence there is no loss of information due to histogramming.
650 644  
... ... @@ -658,68 +652,62 @@ the same events for both analyses.
658 652  
659 653 .. code-block:: xml
660 654  
661   - 2015-02-04T17:31:58: +=================================+
662   - 2015-02-04T17:31:58: | Maximum likelihood optimisation |
663   - 2015-02-04T17:31:58: +=================================+
664   - 2015-02-04T17:31:58: >Iteration 0: -logL=44395.244, Lambda=1.0e-03
665   - 2015-02-04T17:31:58: Iteration 1: -logL=44396.223, Lambda=1.0e-03, delta=-0.979, max(|grad|)=9.644743 [Sigma:6] (stalled)
666   - 2015-02-04T17:31:58: >Iteration 2: -logL=44396.162, Lambda=1.0e-02, delta=0.061, max(|grad|)=-0.309683 [Normalization:7]
667   - 2015-02-04T17:31:59: >Iteration 3: -logL=44396.162, Lambda=1.0e-03, delta=0.000, max(|grad|)=-0.008931 [Index:3]
668   - 2015-02-04T17:31:59:
669   - 2015-02-04T17:31:59: +=========================================+
670   - 2015-02-04T17:31:59: | Maximum likelihood optimization results |
671   - 2015-02-04T17:31:59: +=========================================+
672   - 2015-02-04T17:31:59: === GOptimizerLM ===
673   - 2015-02-04T17:31:59: Optimized function value ..: 44396.162
674   - 2015-02-04T17:31:59: Absolute precision ........: 0.005
675   - 2015-02-04T17:31:59: Acceptable value decrease .: 2
676   - 2015-02-04T17:31:59: Optimization status .......: converged
677   - 2015-02-04T17:31:59: Number of parameters ......: 9
678   - 2015-02-04T17:31:59: Number of free parameters .: 4
679   - 2015-02-04T17:31:59: Number of iterations ......: 3
680   - 2015-02-04T17:31:59: Lambda ....................: 0.0001
681   - 2015-02-04T17:31:59: Maximum log likelihood ....: -44396.162
682   - 2015-02-04T17:31:59: Observed events (Nobs) ...: 6127.000
683   - 2015-02-04T17:31:59: Predicted events (Npred) ..: 6127.000 (Nobs - Npred = 0.000303534)
684   - 2015-02-04T17:31:59: === GModels ===
685   - 2015-02-04T17:31:59: Number of models ..........: 2
686   - 2015-02-04T17:31:59: Number of parameters ......: 9
687   - 2015-02-04T17:31:59: === GModelSky ===
688   - 2015-02-04T17:31:59: Name ......................: Crab
689   - 2015-02-04T17:31:59: Instruments ...............: all
690   - 2015-02-04T17:31:59: Instrument scale factors ..: unity
691   - 2015-02-04T17:31:59: Observation identifiers ...: all
692   - 2015-02-04T17:31:59: Model type ................: PointSource
693   - 2015-02-04T17:31:59: Model components ..........: "SkyDirFunction" * "PowerLaw" * "Constant"
694   - 2015-02-04T17:31:59: Number of parameters ......: 6
695   - 2015-02-04T17:31:59: Number of spatial par's ...: 2
696   - 2015-02-04T17:31:59: RA .......................: 83.6331 [-360,360] deg (fixed,scale=1)
697   - 2015-02-04T17:31:59: DEC ......................: 22.0145 [-90,90] deg (fixed,scale=1)
698   - 2015-02-04T17:31:59: Number of spectral par's ..: 3
699   - 2015-02-04T17:31:59: Prefactor ................: 6.13325e-16 +/- 2.05738e-17 [1e-23,1e-13] ph/cm2/s/MeV (free,scale=1e-16,gradient)
700   - 2015-02-04T17:31:59: Index ....................: -2.5057 +/- 0.0250818 [-0,-5] (free,scale=-1,gradient)
701   - 2015-02-04T17:31:59: PivotEnergy ..............: 300000 [10000,1e+09] MeV (fixed,scale=1e+06,gradient)
702   - 2015-02-04T17:31:59: Number of temporal par's ..: 1
703   - 2015-02-04T17:31:59: Constant .................: 1 (relative value) (fixed,scale=1,gradient)
704   - 2015-02-04T17:31:59: === GCTAModelRadialAcceptance ===
705   - 2015-02-04T17:31:59: Name ......................: Background
706   - 2015-02-04T17:31:59: Instruments ...............: CTA
707   - 2015-02-04T17:31:59: Instrument scale factors ..: unity
708   - 2015-02-04T17:31:59: Observation identifiers ...: all
709   - 2015-02-04T17:31:59: Model type ................: "Gaussian" * "FileFunction" * "Constant"
710   - 2015-02-04T17:31:59: Number of parameters ......: 3
711   - 2015-02-04T17:31:59: Number of radial par's ....: 1
712   - 2015-02-04T17:31:59: Sigma ....................: 3.04429 +/- 0.0330227 [0.01,10] deg2 (free,scale=1,gradient)
713   - 2015-02-04T17:31:59: Number of spectral par's ..: 1
714   - 2015-02-04T17:31:59: Normalization ............: 0.996767 +/- 0.0175227 [0,1000] (free,scale=1,gradient)
715   - 2015-02-04T17:31:59: Number of temporal par's ..: 1
716   - 2015-02-04T17:31:59: Constant .................: 1 (relative value) (fixed,scale=1,gradient)
717   - 2015-02-04T17:31:59:
718   - 2015-02-04T17:31:59: +==============+
719   - 2015-02-04T17:31:59: | Save results |
720   - 2015-02-04T17:31:59: +==============+
721   - 2015-02-04T17:31:59:
722   - 2015-02-04T17:31:59: Application "ctlike" terminated after 8 wall clock seconds, consuming 0.21275 seconds of CPU time.
  655 + 2015-05-22T20:05:54: +=================================+
  656 + 2015-05-22T20:05:54: | Maximum likelihood optimisation |
  657 + 2015-05-22T20:05:54: +=================================+
  658 + 2015-05-22T20:05:54: >Iteration 0: -logL=93854.543, Lambda=1.0e-03
  659 + 2015-05-22T20:05:54: >Iteration 1: -logL=93848.595, Lambda=1.0e-03, delta=5.948, max(|grad|)=22.480581 [Index:7]
  660 + 2015-05-22T20:05:54: >Iteration 2: -logL=93848.587, Lambda=1.0e-04, delta=0.008, max(|grad|)=-0.081846 [Index:3]
  661 + 2015-05-22T20:05:54: >Iteration 3: -logL=93848.587, Lambda=1.0e-05, delta=0.000, max(|grad|)=-0.003485 [Index:3]
  662 + 2015-05-22T20:05:54:
  663 + 2015-05-22T20:05:54: +=========================================+
  664 + 2015-05-22T20:05:54: | Maximum likelihood optimization results |
  665 + 2015-05-22T20:05:54: +=========================================+
  666 + 2015-05-22T20:05:54: === GOptimizerLM ===
  667 + 2015-05-22T20:05:54: Optimized function value ..: 93848.587
  668 + 2015-05-22T20:05:54: Absolute precision ........: 0.005
  669 + 2015-05-22T20:05:54: Acceptable value decrease .: 2
  670 + 2015-05-22T20:05:54: Optimization status .......: converged
  671 + 2015-05-22T20:05:54: Number of parameters ......: 10
  672 + 2015-05-22T20:05:54: Number of free parameters .: 4
  673 + 2015-05-22T20:05:54: Number of iterations ......: 3
  674 + 2015-05-22T20:05:54: Lambda ....................: 1e-06
  675 + 2015-05-22T20:05:54: Maximum log likelihood ....: -93848.587
  676 + 2015-05-22T20:05:54: Observed events (Nobs) ...: 15312.000
  677 + 2015-05-22T20:05:54: Predicted events (Npred) ..: 15312.000 (Nobs - Npred = 3.03823e-06)
  678 + 2015-05-22T20:05:54: === GModels ===
  679 + 2015-05-22T20:05:54: Number of models ..........: 2
  680 + 2015-05-22T20:05:54: Number of parameters ......: 10
  681 + 2015-05-22T20:05:54: === GModelSky ===
  682 + 2015-05-22T20:05:54: Name ......................: Crab
  683 + 2015-05-22T20:05:54: Instruments ...............: all
  684 + 2015-05-22T20:05:54: Instrument scale factors ..: unity
  685 + 2015-05-22T20:05:54: Observation identifiers ...: all
  686 + 2015-05-22T20:05:54: Model type ................: PointSource
  687 + 2015-05-22T20:05:54: Model components ..........: "SkyDirFunction" * "PowerLaw" * "Constant"
  688 + 2015-05-22T20:05:54: Number of parameters ......: 6
  689 + 2015-05-22T20:05:54: Number of spatial par's ...: 2
  690 + 2015-05-22T20:05:54: RA .......................: 83.6331 [-360,360] deg (fixed,scale=1)
  691 + 2015-05-22T20:05:54: DEC ......................: 22.0145 [-90,90] deg (fixed,scale=1)
  692 + 2015-05-22T20:05:54: Number of spectral par's ..: 3
  693 + 2015-05-22T20:05:54: Prefactor ................: 5.80619e-16 +/- 1.11149e-17 [1e-23,1e-13] ph/cm2/s/MeV (free,scale=1e-16,gradient)
  694 + 2015-05-22T20:05:54: Index ....................: -2.49282 +/- 0.0163467 [-0,-5] (free,scale=-1,gradient)
  695 + 2015-05-22T20:05:54: PivotEnergy ..............: 300000 [10000,1e+09] MeV (fixed,scale=1e+06,gradient)
  696 + 2015-05-22T20:05:54: Number of temporal par's ..: 1
  697 + 2015-05-22T20:05:54: Normalization ............: 1 (relative value) (fixed,scale=1,gradient)
  698 + 2015-05-22T20:05:54: === GCTAModelIrfBackground ===
  699 + 2015-05-22T20:05:54: Name ......................: CTABackgroundModel
  700 + 2015-05-22T20:05:54: Instruments ...............: CTA
  701 + 2015-05-22T20:05:54: Instrument scale factors ..: unity
  702 + 2015-05-22T20:05:54: Observation identifiers ...: all
  703 + 2015-05-22T20:05:54: Model type ................: "PowerLaw" * "Constant"
  704 + 2015-05-22T20:05:54: Number of parameters ......: 4
  705 + 2015-05-22T20:05:54: Number of spectral par's ..: 3
  706 + 2015-05-22T20:05:54: Prefactor ................: 1.03511 +/- 0.024311 [0.001,1000] ph/cm2/s/MeV (free,scale=1,gradient)
  707 + 2015-05-22T20:05:54: Index ....................: 0.0333176 +/- 0.0134386 [-5,5] (free,scale=1,gradient)
  708 + 2015-05-22T20:05:54: PivotEnergy ..............: 1e+06 [10000,1e+09] MeV (fixed,scale=1e+06,gradient)
  709 + 2015-05-22T20:05:54: Number of temporal par's ..: 1
  710 + 2015-05-22T20:05:54: Normalization ............: 1 (relative value) (fixed,scale=1,gradient)
723 711  
724 712  
725 713 .. _sec_butterfly_cta:
... ... @@ -739,14 +727,14 @@ line.
739 727 .. code-block:: bash
740 728  
741 729 $ ctbutterfly
742   - Input event list, cube or observation definition file [events.fits]
743   - Calibration database [dummy]
744   - Instrument response function [cta_dummy_irf]
745   - Source model [$CTOOLS/share/models/crab.xml] crab_results.xml
  730 + Input event list, counts cube or observation definition file [events.fits]
  731 + Calibration database [prod2]
  732 + Instrument response function [South_50h]
  733 + Source model [$CTOOLS/share/models/crab.xml]
746 734 Source of interest [Crab]
747 735 Start value for first energy bin in TeV [0.1]
748 736 Stop value for last energy bin in TeV [100.0]
749   - Output ascii file [butterfly.txt]
  737 + Output ascii file [butterfly.txt]
750 738  
751 739 Now that you have computed the confidence band of the spectral fit and
752 740 that you will have an ASCII file named ``butterfly.txt`` on disk you can
... ...
doc/source/user_manual/getting_started/response.rst
... ... @@ -3,20 +3,6 @@
3 3 CTA Instrument Response Functions
4 4 ---------------------------------
5 5  
6   -.. note ::
7   -
8   - Instrument response functions are formally not part of ctools as they
9   - should be provided by the instrument teams. The GammaLib framework on
10   - which ctools are built comes with a set of basic response functions, but
11   - for getting the latest instrument response functions you should contact
12   - the relevant instrument teams. CTA consortium members should
13   - `download
14   - <https://portal.cta-observatory.org/WG/DM/DM_wiki/DATA_Access/Pages/Science%20Tools.aspx>`_
15   - the latest calibration database containing Prod1 and Prod2 instrument
16   - response functions from the consortium Sharepoint site (requires
17   - password).
18   -
19   -
20 6 What are instrument response functions?
21 7 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
22 8  
... ... @@ -47,98 +33,64 @@ atmospheric conditions, etc.). All these quantities and hence the
47 33 instrument response function may depend on time.
48 34  
49 35  
50   -Data formats
51   -~~~~~~~~~~~~
52   -
53   -So far the data format of the CTA instrument response functions has not
54   -yet been settled, and information about instrument response functions is
55   -provided in various ways. Three types of data formats are supported:
56   -
57   -- :ref:`sec_cta_rsp_perftable`
58   -
59   -- :ref:`sec_cta_rsp_xspec`
60   -
61   -- :ref:`sec_cta_rsp_rsptable`
62   -
63   -All formats provide the instrument response as function of true (and
64   -sometimes also measured) photon energy, typically from about 20 GeV to
65   -about 125 TeV.
66   -Performance tables provide the instrument response for on-axis sources.
67   -ARF, RMF and PSF files provide the instrument response for a specific
68   -source position (and region) within the field of view.
69   -Response tables provide the instrument response as function of position in
70   -the field of view. Response tables are thus the most universal form of
71   -instrument response functions available, and we recommend using this form
72   -for any analysis.
73   -
74   -.. note ::
75   -
76   - Instrument response functions are so far only provided for a fixed
77   - zenith angle of 20 deg. Therefore, no zenith or azimuth angle dependence has
78   - been implemented so far.
79   -
80   -
81   -Installing the CTA calibration database
82   -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
83   -
84   -After `downloading
85   -<https://portal.cta-observatory.org/WG/DM/DM_wiki/DATA_Access/Pages/Science%20Tools.aspx>`_
86   -the latest calibration database (only possible for CTA consortium members),
87   -the database is installed using
88   -
89   -.. code-block:: bash
90   -
91   - $ [sudo] tar -C $CALDB -zxvf cta-caldb-20150220.tar.gz
92   -
93   -or
94   -
95   -.. code-block:: bash
96   -
97   - $ [sudo] tar -C $CALDB -xvf cta-caldb-20150220.tar
98   -
99   -depending on whether the database has been retrieved as a gzipped file or
100   -not. Depending on your access rights to the ``$CALDB`` directory,
101   -installation of the calibration database may require root privileges
102   -(type ``sudo`` in this case, otherwise omit this part of the command).
103   -
104   -The calibration database must be installed into the directory to which you
105   -``CALDB`` environment variable points. By default, ctools sets this
106   -enviroment variable to
107   -
108   -.. code-block:: bash
109   -
110   - $CTOOLS/share/caldb
111   -
112   -but it may be that due to some other analysis software on your system the
113   -``CALDB`` environment variable points to another directory. If in doubt, type
114   -
115   -.. code-block:: bash
116   -
117   - echo $CALDB
118   -
119   -to find out to which directory your ``CALDB`` environment variable points.
120   -You may always overwrite this setting using
121   -
122   -.. code-block:: bash
123   -
124   - export CALDB=/my/preferred/caldb/directory
125   -
126   -which you can add to your ``.bashrc`` file to set the directory
127   -permanently.
128   -ctools will use the ``CALDB`` environment variable to find out where the
129   -calibration database is located. If needed, this mechanism can be
130   -circumvented (see :ref:`sec_cta_rsp_abspath`).
131   -
132   -
133   -Specifying the CTA Instrument Response Functions
134   -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  36 +CTA response functions
  37 +~~~~~~~~~~~~~~~~~~~~~~
  38 +
  39 +The instrument response functions for CTA are factorised into
  40 +the effective area :math:`A_{\rm eff}(d, p, E, t)` (units :math:`cm^2`),
  41 +the point spread function :math:`PSF(p' | d, p, E, t)`,
  42 +and the energy dispersion :math:`E_{\rm disp}(E' | d, p, E, t)`
  43 +following:
  44 +
  45 +.. math::
  46 + R(p', E', t' | d, p, E, t) =
  47 + A_{\rm eff}(d, p, E, t) \times
  48 + PSF(p' | d, p, E, t) \times
  49 + E_{\rm disp}(E' | d, p, E, t)
  50 +
  51 +ctools are shipped with response functions for the northern and southern
  52 +arrays, and variants are available that have been optimised for exposure
  53 +times of 0.5 hours, 5 hours and 50 hours.
  54 +In total, the following six instrument response functions are available:
  55 +``North_0.5h``, ``North_5h``, ``North_50h``, ``South_0.5h``,
  56 +``South_5h``, and ``South_50h``.
  57 +
  58 +Each response is stored in a single FITS file, and each component of
  59 +the response factorisation is stored in a binary table of that FITS
  60 +file.
  61 +In addition, the response files contain an additional table that
  62 +describes the background rate as function of energy and position in
  63 +the field of view.
  64 +An example of a CTA response file is shown below:
  65 +
  66 +.. figure:: irf-file.png
  67 + :width: 100%
  68 +
  69 +Each table in the response file is in a standardised format that is
  70 +the one that is also used for the Fermi/LAT telescope.
  71 +As an example, the effective area component of the response file
  72 +is shown below.
  73 +Response information is stored in a n-dimensional cube, and each axis
  74 +of this cube is described by the lower and upper edges of the axis bins.
  75 +In this example the effective area is stored as a 2D matrix with the
  76 +first axis being energy and the second axis being offaxis angle.
  77 +Effective area information is stored for true (``EFFAREA``) and
  78 +reconstructed (``EFFAREA_RECO``) energy.
  79 +Vector columns are used to store all information.
  80 +
  81 +.. figure:: irf-aeff.png
  82 + :width: 100%
  83 +
  84 +
  85 +Specifying CTA response functions
  86 +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
135 87  
136 88 The specification of the CTA Instrument Response Functions depends on the
137 89 way how ctools are used. Common to all methods is that the IRFs are
138 90 defined by a response name and a calibration database name.
139   -
140   -There are different means to specify the CTA Instrument Response Functions
141   -when using ctools, and the following section describe the
  91 +ctools makes use of HEASARC's CALDB format to index and store
  92 +IRFs, and specification of the database and response names is
  93 +sufficient to access the response.
142 94  
143 95  
144 96 Specifying the response function as input parameters
... ... @@ -146,23 +98,22 @@ Specifying the response function as input parameters
146 98  
147 99 ctools that require instrument response functions have two parameters
148 100 to specify the calibration database name and the response function name.
149   -The following example shows a ``ctobssim`` run using the ``dummy``
150   -calibration database and the ``cta_dummy_irf`` response function:
  101 +The following example shows a ``ctobssim`` run using the ``prod2``
  102 +calibration database and the ``South_50h`` response function:
151 103  
152 104 .. code-block:: bash
153 105  
154 106 $ ctobssim
155   - Model [$CTOOLS/share/models/crab.xml]
156   - Calibration database [dummy]
157   - Instrument response function [cta_dummy_irf]
158 107 RA of pointing (degrees) (0-360) [83.63]
159   - Dec of pointing (degrees) (-90-90) [22.01]
  108 + Dec of pointing (degrees) (-90-90) [22.51]
160 109 Radius of FOV (degrees) (0-180) [5.0]
161   - Start time (MET in s) (0) [0.0]
162   - End time (MET in s) (0) [1800.0]
163   - Lower energy limit (TeV) (0) [0.1]
164   - Upper energy limit (TeV) (0) [100.0]
165   - Output event data file or observation definition file [events.fits]
  110 + Start time (MET in s) [0.0]
  111 + End time (MET in s) [1800.0]
  112 + Lower energy limit (TeV) [0.1]
  113 + Upper energy limit (TeV) [100.0]
  114 + Calibration database [prod2]
  115 + Instrument response function [South_50h]
  116 + Model [$CTOOLS/share/models/crab.xml]
166 117  
167 118 Running the other tools is equivalent.
168 119  
... ... @@ -180,7 +131,7 @@ definition file:
180 131 <observation_list title="observation library">
181 132 <observation name="Crab" id="00001" instrument="CTA">
182 133 <parameter name="EventList" file="events.fits"/>
183   - <parameter name="Calibration" database="dummy" response="cta_dummy_irf"/>
  134 + <parameter name="Calibration" database="prod2" response="South_50h"/>
184 135 </observation>
185 136 </observation_list>
186 137  
... ... @@ -190,9 +141,9 @@ response name. You can then pass this file directly to, e.g., ``ctlike``:
190 141 .. code-block:: bash
191 142  
192 143 $ ctlike
193   - Event list, counts map or observation definition file [events.fits] obs_rsp.xml
  144 + Event list, counts cube or observation definition file [events.fits] obs_irf.xml
194 145 Source model [$CTOOLS/share/models/crab.xml]
195   - Source model output file [crab_results.xml]
  146 + Source model output file [crab_results.xml]
196 147  
197 148 Note that ``ctlike`` does not ask for the calibration database and
198 149 response name as it found the relevant information in the XML file.
... ... @@ -211,10 +162,10 @@ specify them individually in the XML observation file as follows:
211 162 <observation_list title="observation library">
212 163 <observation name="Crab" id="00001" instrument="CTA">
213 164 <parameter name="EventList" file="events.fits"/>
214   - <parameter name="EffectiveArea" file="$CALDB/data/cta/dummy/bcf/cta_dummy_irf.dat"/>
215   - <parameter name="PointSpreadFunction" file="$CALDB/data/cta/dummy/bcf/cta_dummy_irf.dat"/>
216   - <parameter name="EnergyDispersion" file="$CALDB/data/cta/dummy/bcf/cta_dummy_irf.dat"/>
217   - <parameter name="Background" file="$CALDB/data/cta/dummy/bcf/cta_dummy_irf.dat"/>
  165 + <parameter name="EffectiveArea" file="$CALDB/data/cta/prod2/bcf/North_0.5h/irf_file.fits.gz"/>
  166 + <parameter name="PointSpreadFunction" file="$CALDB/data/cta/prod2/bcf/North_0.5h/irf_file.fits.gz"/>
  167 + <parameter name="EnergyDispersion" file="$CALDB/data/cta/prod2/bcf/North_0.5h/irf_file.fits.gz"/>
  168 + <parameter name="Background" file="$CALDB/data/cta/prod2/bcf/North_0.5h/irf_file.fits.gz"/>
218 169 </observation>
219 170 </observation_list>
220 171  
... ... @@ -229,169 +180,12 @@ and response name from within Python:
229 180  
230 181 import gammalib
231 182 obs = gammalib.GCTAObservation()
232   - caldb = gammalib.GCaldb("cta", "dummy")
233   - irf = "cta_dummy_irf"
  183 + caldb = gammalib.GCaldb("cta", "prod2")
  184 + irf = "South_50h"
234 185 obs.response(irf, caldb)
235 186  
236 187 The calibration database is set by creating a ``GCaldb`` object. The
237 188 constructor takes as argument the mission (always ``cta``) and the
238   -database name, in our case ``dummy``. The response function is then set
239   -by passing the response name (here ``cta_dummy_irf``) and the calibration
  189 +database name, in our case ``prod2``. The response function is then set
  190 +by passing the response name (here ``South_50h``) and the calibration
240 191 database object to the ``response`` method.
241   -
242   -Alternatively, you can specify a specific response file by using
243   -
244   -.. code-block:: python
245   -
246   - import gammalib
247   - obs = gammalib.GCTAObservation()
248   - caldb = gammalib.GCaldb("$CALDB/data/cta/dummy/bcf")
249   - irf = "cta_dummy_irf.dat"
250   - obs.response(irf, caldb)
251   -
252   -Here, the directory in which the calibration file resides is specified
253   -as argument to the ``GCaldb`` constructor, and the filename is passed
254   -as response function name to the ``response`` method.
255   -
256   -
257   -What response functions are available?
258   -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
259   -
260   -To see what response functions are available on your system, type
261   -
262   -.. code-block:: bash
263   -
264   - $ cscaldb
265   -
266   -This creates the file ``cscaldb.log`` in your current working directory
267   -that contains information about the available response functions. The
268   -format of the file is:
269   -
270   -.. code-block:: bash
271   -
272   - 2014-02-20T17:15:21: +==============+
273   - 2014-02-20T17:15:21: | Mission: cta |
274   - 2014-02-20T17:15:21: +==============+
275   - 2014-02-20T17:15:21: === Calibration: aar ===
276   - 2014-02-20T17:15:21: DESY20140105_50h
277   - 2014-02-20T17:15:21: DESY20140105_50h_0deg
278   - 2014-02-20T17:15:21: DESY20140105_50h_180deg
279   - 2014-02-20T17:15:21:
280   - 2014-02-20T17:15:21: === Calibration: aar500 ===
281   - 2014-02-20T17:15:21: DESY20140105_50h
282   - 2014-02-20T17:15:21: DESY20140105_50h_0deg
283   - 2014-02-20T17:15:21: DESY20140105_50h_180deg
284   -
285   -The name after ``Calibration`` is what we called earlier the calibration
286   -database, and the names that are following each
287   -``=== Calibration: xxx ===`` header are the response file names.
288   -
289   -To get the same information also onto the console, type
290   -
291   -.. code-block:: bash
292   -
293   - $ cscaldb debug=yes
294   -
295   -
296   -Data format details
297   -~~~~~~~~~~~~~~~~~~~
298   -
299   -.. _sec_cta_rsp_perftable:
300   -
301   -Performance tables
302   -^^^^^^^^^^^^^^^^^^
303   -
304   -In the early days, the instrument performances derived from Monte-Carlo
305   -simulations have been summarised in what we call here Performance
306   -Tables, which are ASCII files that contain as function of energy the
307   -on-axis performance parameters of CTA, such as effective area, point spread
308   -function containment radius, energy resolution, background count rate and
309   -differential sensitivity.
310   -
311   -Below an example of a CTA performance table::
312   -
313   - log(E) Area r68 r80 ERes. BG Rate Diff Sens
314   - -1.7 261.6 0.3621 0.4908 0.5134 0.0189924 6.88237e-11
315   - -1.5 5458.2 0.2712 0.3685 0.4129 0.1009715 1.72717e-11
316   - -1.3 15590.0 0.1662 0.2103 0.2721 0.0575623 6.16963e-12
317   - -1.1 26554.1 0.1253 0.1567 0.2611 0.0213008 2.89932e-12
318   - -0.9 52100.5 0.1048 0.1305 0.1987 0.0088729 1.39764e-12
319   - -0.7 66132.1 0.0827 0.1024 0.1698 0.0010976 6.03531e-13
320   - -0.5 108656.8 0.0703 0.0867 0.1506 0.0004843 3.98147e-13
321   - -0.3 129833.0 0.0585 0.0722 0.1338 0.0001575 3.23090e-13
322   - -0.1 284604.3 0.0531 0.0656 0.1008 0.0001367 2.20178e-13
323   - 0.1 263175.3 0.0410 0.0506 0.0831 0.0000210 1.87452e-13
324   - 0.3 778048.6 0.0470 0.0591 0.0842 0.0000692 1.53976e-13
325   - 0.5 929818.8 0.0391 0.0492 0.0650 0.0000146 1.18947e-13
326   - 0.7 1078450.0 0.0335 0.0415 0.0541 0.0000116 1.51927e-13
327   - 0.9 1448579.1 0.0317 0.0397 0.0516 0.0000047 1.42439e-13
328   - 1.1 1899905.0 0.0290 0.0372 0.0501 0.0000081 1.96670e-13
329   - 1.3 2476403.8 0.0285 0.0367 0.0538 0.0000059 2.20695e-13
330   - 1.5 2832570.6 0.0284 0.0372 0.0636 0.0000073 3.22523e-13
331   - 1.7 3534065.3 0.0290 0.0386 0.0731 0.0000135 4.84153e-13
332   - 1.9 3250103.4 0.0238 0.0308 0.0729 0.0000044 6.26265e-13
333   - 2.1 3916071.6 0.0260 0.0354 0.0908 0.0000023 7.69921e-13
334   - ---------------------------------------------
335   - 1) log(E) = log10(E/TeV) - bin centre
336   - 2) Eff Area - in square metres after background cut (no theta cut)
337   - 3) Ang. Res - 68% containment radius of gamma-ray PSF post cuts - in degrees
338   - 4) Ang. Res - 80% containment radius of gamma-ray PSF post cuts - in degrees
339   - 5) Fractional Energy Resolution (rms)
340   - 6) BG Rate - inside point-source selection region - post call cuts - in Hz
341   - 7) Diff Sens - differential sensitivity for this bin expressed as E^2 dN/dE
342   - - in erg cm^-2 s^-1 - for a 50 hours exposure - 5 sigma significance including
343   - systematics and statistics and at least 10 photons.
344   -
345   -
346   -.. _sec_cta_rsp_xspec:
347   -
348   -ARF, RMF and PSF files
349   -^^^^^^^^^^^^^^^^^^^^^^
350   -
351   -Instrument response information for the first CTA Data Challenge (1DC) has been
352   -provided in a format that was heavily inspired by the
353   -`RMF and ARF file formats
354   -<http://heasarc.gsfc.nasa.gov/docs/heasarc/caldb/docs/memos/cal_gen_92_002/cal_gen_92_002.html>`_
355   -that have been introduced by
356   -`HEASARC <http://heasarc.gsfc.nasa.gov/>`_
357   -for spectral analysis of X-ray data.
358   -
359   -The Redistribution Matrix File (RMF) describes how an incoming photon with
360   -a given true energy is redistributed in measured energy. In other words, it
361   -describes the energy dispersion of the instrument. The RMF is organised as
362   -a two-dimensional matrix, with the first axis being in true energies while
363   -the second axis represents the measured energies.
364   -
365   -The Ancillary Response File (ARF) describes the sensitivity of the
366   -instrument to photons of a given true energy. The ARF gives the effective
367   -area of the detector system after applying an event selection cut
368   -(theta cut). For computing the ARF, some knowledge of the Point Spread
369   -Function (PSF) is needed, so that the fraction of photons that falls into
370   -the event selection region for a given source can be properly estimated.
371   -Once this is done, no further PSF information is needed for the analysis.
372   -
373   -ctools however relies on the full modelling of the instrument, including
374   -the Point Spread Function, and hence, PSF information has also been
375   -provided for 1DC. Two data formats have been used for this: a first that
376   -is based on a simple one-dimensional vector, providing the width of a
377   -2-dimensional Gaussian as function of energy; and a second that is based
378   -on a three-component 2D Gaussian as function of energy and offset angle
379   -in the camera system. While the former was implement by a simply FITS
380   -table with two columns, the latter was implemented by
381   -:ref:`sec_cta_rsp_rsptable`.
382   -
383   -
384   -.. _sec_cta_rsp_rsptable:
385   -
386   -Response tables
387   -^^^^^^^^^^^^^^^
388   -
389   -The CTA response table class ``GCTAResponseTable`` provides a generic
390   -handle for multi-dimensional response information. It is based on the
391   -response format used for storing response information for the
392   -*Fermi*/LAT telescope. In this format, all information is stored in
393   -a single row of a FITS binary table. Each element of the row contains
394   -a vector column, that describes the axes of the multi-dimensional response
395   -cube and the response information. Note that this class may in the future
396   -be promoted to the GammaLib core, as a similar class has been implemented
397   -in the *Fermi*/LAT interface.
... ...
doc/source/user_manual/getting_started/tsmap-crab.png

75.2 KB | W: | H:

70.7 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
examples/README
... ... @@ -9,6 +9,13 @@ benchmark_cta_analysis.py
9 9 check_models.py
10 10 Checks a variety of models using an unbinned analysis.
11 11  
  12 +make_pointings.py
  13 + This script creates pointings for CTA surveys. For the moment the
  14 + Galactic Plane Survey (gps), the Extragalactic Survey (extgal),
  15 + the Galactic Centre Survey (gc) and the LMC survey (lmc) are
  16 + implemented. The script outputs and ASCII file that can be used by
  17 + csobsdef.
  18 +
12 19 make_pull_at_sensitivity_limit.py
13 20 This script creates pull distributions as function of energy
14 21 for a test source that is at the 5 sigma sensitivity limit for
... ...
examples/benchmark_cta_analysis.py
... ... @@ -39,8 +39,8 @@ def unbinned_pipeline(duration):
39 39 """
40 40 # Set script parameters
41 41 model_name = "${CTOOLS}/share/models/crab.xml"
42   - caldb = "dummy"
43   - irf = "cta_dummy_irf"
  42 + caldb = "prod2"
  43 + irf = "South_50h"
44 44 ra = 83.63
45 45 dec = 22.01
46 46 rad_sim = 10.0
... ... @@ -103,8 +103,8 @@ def binned_pipeline(duration):
103 103 """
104 104 # Set script parameters
105 105 model_name = "${CTOOLS}/share/models/crab.xml"
106   - caldb = "dummy"
107   - irf = "cta_dummy_irf"
  106 + caldb = "prod2"
  107 + irf = "South_50h"
108 108 ra = 83.63
109 109 dec = 22.01
110 110 rad_sim = 10.0
... ... @@ -167,17 +167,17 @@ def binned_pipeline(duration):
167 167 return telapsed, tctlike
168 168  
169 169  
170   -# ============================ #
171   -# Cube-style analysis pipeline #
172   -# ============================ #
173   -def cube_pipeline(duration):
  170 +# ========================= #
  171 +# Stacked analysis pipeline #
  172 +# ========================= #
  173 +def stacked_pipeline(duration):
174 174 """
175 175 Cube-style analysis pipeline.
176 176 """
177 177 # Set script parameters
178 178 model_name = "${CTOOLS}/share/models/crab.xml"
179   - caldb = "dummy"
180   - irf = "cta_dummy_irf"
  179 + caldb = "prod2"
  180 + irf = "South_50h"
181 181 ra = 83.63
182 182 dec = 22.01
183 183 rad_sim = 10.0
... ... @@ -260,17 +260,34 @@ def cube_pipeline(duration):
260 260 psfcube["yref"].real(dec)
261 261 psfcube.run()
262 262  
263   - # Set exposure and PSF cube for first CTA observation
264   - obs = bin.obs()
265   - cta = gammalib.GCTAObservation(obs[0])
266   - cta.response(expcube.expcube(), psfcube.psfcube())
267   - obs[0] = cta
  263 + # Create background cube
  264 + bkgcube = ctools.ctbkgcube(sim.obs())
  265 + bkgcube["incube"].filename("NONE")
  266 + bkgcube["ebinalg"].string("LOG")
  267 + bkgcube["emin"].real(emin)
  268 + bkgcube["emax"].real(emax)
  269 + bkgcube["enumbins"].integer(enumbins)
  270 + bkgcube["nxpix"].integer(10)
  271 + bkgcube["nypix"].integer(10)
  272 + bkgcube["binsz"].real(1.0)
  273 + bkgcube["coordsys"].string(coordsys)
  274 + bkgcube["proj"].string(proj)
  275 + bkgcube["xref"].real(ra)
  276 + bkgcube["yref"].real(dec)
  277 + bkgcube.run()
  278 +
  279 + # Attach background model to observation container
  280 + bin.obs().models(bkgcube.models())
  281 +
  282 + # Set Exposure and Psf cube for first CTA observation
  283 + # (ctbin will create an observation with a single container)
  284 + bin.obs()[0].response(expcube.expcube(), psfcube.psfcube(), bkgcube.bkgcube())
268 285  
269 286 # Get ctlike start CPU time
270 287 tctlike = time.clock()
271 288  
272 289 # Perform maximum likelihood fitting
273   - like = ctools.ctlike(obs)
  290 + like = ctools.ctlike(bin.obs())
274 291 like.run()
275 292  
276 293 # Get stop CPU time
... ... @@ -292,16 +309,16 @@ if __name__ == &#39;__main__&#39;:
292 309 print("*************************************")
293 310 print("* CTA analysis benchmark *")
294 311 print("*************************************")
295   - print(" Duration Unbinned Binned Cube-style ctlike-UB ctlike-B ctlike-CS")
  312 + print(" Duration Unbinned Binned Stacked ctlike-UB ctlike-B ctlike-S")
296 313  
297 314 # Initialize arrays
298 315 a_duration = []
299 316 a_unbinned = []
300 317 a_binned = []
301   - a_cube = []
  318 + a_stacked = []
302 319 c_unbinned = []
303 320 c_binned = []
304   - c_cube = []
  321 + c_stacked = []
305 322  
306 323 # Perform benchmarks
307 324 duration = 1800.0
... ... @@ -309,22 +326,22 @@ if __name__ == &#39;__main__&#39;:
309 326  
310 327 # Perform analyses
311 328 t_unbinned, ct_unbinned = unbinned_pipeline(duration)
312   - t_binned, ct_binned = binned_pipeline(duration)
313   - t_cube, ct_cube = cube_pipeline(duration)
  329 + t_binned, ct_binned = binned_pipeline(duration)
  330 + t_stacked, ct_stacked = stacked_pipeline(duration)
314 331  
315 332 # Collect results
316 333 a_duration.append(duration/3600.0)
317 334 a_unbinned.append(t_unbinned)
318 335 a_binned.append(t_binned)
319   - a_cube.append(t_cube)
  336 + a_stacked.append(t_stacked)
320 337 c_unbinned.append(ct_unbinned)
321 338 c_binned.append(ct_binned)
322   - c_cube.append(ct_cube)
  339 + c_stacked.append(ct_stacked)
323 340  
324 341 # Print results
325 342 print("%10.0f %10.4f %10.4f %10.4f %10.4f %10.4f %10.4f" % \
326   - (duration, t_unbinned, t_binned, t_cube, \
327   - ct_unbinned, ct_binned, ct_cube))
  343 + (duration, t_unbinned, t_binned, t_stacked, \
  344 + ct_unbinned, ct_binned, ct_stacked))
328 345  
329 346 # Increment duration
330 347 duration *= 2.0
... ... @@ -335,10 +352,10 @@ if __name__ == &#39;__main__&#39;:
335 352 plt.title("CTA analysis benchmark")
336 353 plt.loglog(a_duration, a_unbinned, 'ro-', label='unbinned')
337 354 plt.loglog(a_duration, a_binned, 'bo-', label='binned')
338   - plt.loglog(a_duration, a_cube, 'go-', label='cube-style')
  355 + plt.loglog(a_duration, a_stacked, 'go-', label='cube-style')
339 356 plt.loglog(a_duration, c_unbinned, 'ro--')
340 357 plt.loglog(a_duration, c_binned, 'bo--')
341   - plt.loglog(a_duration, c_cube, 'go--')
  358 + plt.loglog(a_duration, c_stacked, 'go--')
342 359 plt.xlabel("Duration (hours)")
343 360 plt.ylabel("CPU time (seconds)")
344 361 plt.legend(loc="lower right")
... ...
examples/check_models.py
... ... @@ -41,8 +41,8 @@ def pipeline(model_name):
41 41 FITS files on disk. All data is only hold in memory.
42 42 """
43 43 # Set script parameters
44   - caldb = "dummy"
45   - irf = "cta_dummy_irf"
  44 + caldb = "prod2"
  45 + irf = "South_50h"
46 46 ra = 83.63
47 47 dec = 22.01
48 48 rad_sim = 10.0
... ...
examples/make_pointings.py
1 1 #! /usr/bin/env python
2 2 # ==========================================================================
3   -# This script generated pointing patterns for CTA observations.
  3 +# This script generates pointing patterns for CTA observations.
4 4 #
5 5 # Usage:
6 6 # ./make_pointings.py
... ... @@ -124,19 +124,18 @@ def set_patch(lmin=-30.0, lmax=30.0, bmin=-1.5, bmax=+1.5, \
124 124 obs_site = site
125 125  
126 126 # Set site IRF
  127 + caldb = "prod2"
127 128 if obs_site == "North":
128   - caldb = "tenerife"
129 129 if lst:
130   - irf = "DESY20140105_50h"
  130 + irf = "North_50h"
131 131 else:
132   - irf = "DESY20140105_50h_noLST"
  132 + irf = "North_50h"
133 133 exposure_north += duration
134 134 else:
135   - caldb = "aar"
136 135 if lst:
137   - irf = "DESY20140105_50h"
  136 + irf = "South_50h"
138 137 else:
139   - irf = "DESY20140105_50h_noLST"
  138 + irf = "South_50h"
140 139 exposure_south += duration
141 140  
142 141 # Set IRF information
... ... @@ -241,6 +240,59 @@ def set_gc(lst=True):
241 240 return obsdef
242 241  
243 242  
  243 +# ============= #
  244 +# Setup LMC KSP #
  245 +# ============= #
  246 +def set_lmc(hours=250.0, lst=True):
  247 + """
  248 + Setup LMC KSP.
  249 + """
  250 + # Initialise observation definition
  251 + obsdef = []
  252 +
  253 + # Set LMC centre
  254 + centre = gammalib.GSkyDir()
  255 + centre.radec_deg(80.0, -69.0)
  256 +
  257 + # Set offset angle and number of pointings
  258 + offset = 1.0 # degrees
  259 + n_pnt = 12
  260 +
  261 + # Prepare computations
  262 + dphi = 360.0/n_pnt
  263 + duration = hours*3600.0/float(n_pnt)
  264 +
  265 + # Loop over pointings
  266 + for ipnt in range(n_pnt):
  267 +
  268 + # Compute pointing direction
  269 + pnt = centre.copy()
  270 + pnt.rotate_deg(ipnt*dphi, offset)
  271 + lon = pnt.l_deg()
  272 + lat = pnt.b_deg()
  273 +
  274 + # Set positions and duration
  275 + obs = {'lon': lon, 'lat': lat, 'duration': duration}
  276 +
  277 + # Add IRF
  278 + caldb = "prod2"
  279 + if lst:
  280 + irf = "South_50h"
  281 + else:
  282 + irf = "South_50h"
  283 + obs['caldb'] = caldb
  284 + obs['irf'] = irf
  285 +
  286 + # Append observation
  287 + obsdef.append(obs)
  288 +
  289 + # Dump statistics
  290 + print("Number of pointings: %d (%.2f sec)" % (n_pnt,duration))
  291 +
  292 + # Return observation definition
  293 + return obsdef
  294 +
  295 +
244 296 # ======================================= #
245 297 # Write observation definition dictionary #
246 298 # ======================================= #
... ... @@ -291,7 +343,6 @@ if __name__ == &#39;__main__&#39;:
291 343 need_help = False
292 344  
293 345 # Test for command line arguments
294   - #print(sys.argv[0])
295 346 if (len(sys.argv) > 1):
296 347 if sys.argv[1] == "-h":
297 348 need_help = True
... ... @@ -304,13 +355,14 @@ if __name__ == &#39;__main__&#39;:
304 355 if need_help:
305 356 print("Usage: make_pointing.py [OPTIONS]")
306 357 print(" -h Display this usage message")
307   - print(" gps Galactic plane scan (2 row scheme)")
308   - print(" gps3 Galactic plane scan (3 row scheme)")
  358 + print(" gps Galactic plane survey (2 row scheme)")
  359 + print(" gps3 Galactic plane survey (3 row scheme)")
309 360 print(" extgal Extragalactic survey")
310   - print(" gc Galactic centre")
  361 + print(" gc Galactic centre survey")
  362 + print(" lmc LMC survey")
311 363 sys.exit()
312 364  
313   - # Galactic plane scan
  365 + # Galactic plane survey
314 366 if obsname == "gps":
315 367 obsdef = set_gps(lst=True)
316 368 write_obsdef("gps.dat", obsdef)
... ... @@ -328,6 +380,11 @@ if __name__ == &#39;__main__&#39;:
328 380 obsdef = set_gc(lst=True)
329 381 write_obsdef("gc.dat", obsdef)
330 382  
  383 + # LMC
  384 + elif obsname == "lmc":
  385 + obsdef = set_lmc(lst=True)
  386 + write_obsdef("lmc.dat", obsdef)
  387 +
331 388 # Invalid pattern
332 389 else:
333 390 print("Unknown option \""+obsname+"\"")
... ...
examples/make_pull_at_sensitivity_limit.py
... ... @@ -61,8 +61,8 @@ def create_pull(loge, emin, emax, models, ntrials=100, duration=180000.0, \
61 61 pull.models(models)
62 62 pull["outfile"] = outfile
63 63 pull["ntrials"] = ntrials
64   - pull["caldb"] = "${CALDB}/data/cta/dummy/bcf"
65   - pull["irf"] = "cta_dummy_irf"
  64 + pull["caldb"] = "prod2"
  65 + pull["irf"] = "South_50h"
66 66 pull["ra"] = 83.6331
67 67 pull["dec"] = 22.0145
68 68 pull["emin"] = emin
... ...
examples/make_spectrum.py
... ... @@ -36,8 +36,8 @@ def make_spectrum():
36 36 """
37 37 # Set script parameters
38 38 model_name = "${CTOOLS}/share/models/crab.xml"
39   - caldb = "dummy"
40   - irf = "cta_dummy_irf"
  39 + caldb = "prod2"
  40 + irf = "South_50h"
41 41 ra = 83.63
42 42 dec = 22.01
43 43 rad_sim = 3.0
... ... @@ -88,7 +88,7 @@ def plot_spectrum(spectrum):
88 88 spectrum['flux']['value'], 'ro', label='Crab')
89 89 plt.errorbar(spectrum['energy']['value'], \
90 90 spectrum['flux']['value'], \
91   - spectrum['flux']['ed_value'], fmt=None, ecolor='r')
  91 + spectrum['flux']['ed_value'], ecolor='r')
92 92  
93 93 # Put labels
94 94 plt.xlabel("Energy ("+spectrum['energy']['unit']+")")
... ...
examples/make_ts_distributions.py
... ... @@ -61,21 +61,23 @@ def create_ts(loge, emin, emax, ntrials=100, duration=180000.0, \
61 61  
62 62 # Setup cstsdist tool
63 63 tsdist = cstsdist()
64   - tsdist["outfile"] = outfile
65   - tsdist["ntrials"] = ntrials
66   - tsdist["caldb"] = "${CALDB}/data/cta/dummy/bcf"
67   - tsdist["irf"] = "cta_dummy_irf"
68   - tsdist["type"] = "point"
69   - tsdist["index"] = -2.48
70   - tsdist["offset"] = 0.0
71   - tsdist["bkg"] = "${CTOOLS}/share/models/bkg_dummy.txt"
72   - tsdist["emin"] = float(emin)
73   - tsdist["emax"] = float(emax)
74   - tsdist["enumbins"] = int(enumbins)
75   - tsdist["duration"] = float(duration)
76   - tsdist["rad"] = 5.0
77   - tsdist["npix"] = 200
78   - tsdist["binsz"] = 0.05
  64 + tsdist["inmodel"].filename("$CTOOLS/share/models/crab.xml")
  65 + tsdist["srcname"].string("Crab")
  66 + tsdist["outfile"].filename(outfile)
  67 + tsdist["ntrials"].integer(ntrials)
  68 + tsdist["caldb"].string("prod2")
  69 + tsdist["irf"].string("South_50h")
  70 + tsdist["ra"].real(83.63)
  71 + tsdist["dec"].real(22.01)
  72 + tsdist["emin"].real(float(emin))
  73 + tsdist["emax"].real(float(emax))
  74 + tsdist["enumbins"].integer(int(enumbins))
  75 + tsdist["tmin"].real(0.0)
  76 + tsdist["tmax"].real(float(duration))
  77 + tsdist["rad"].real(5.0)
  78 + tsdist["npix"].integer(200)
  79 + tsdist["binsz"].real(0.05)
  80 + #tsdist["debug"].boolean(True)
79 81  
80 82 # Optionally open the log file
81 83 if log:
... ... @@ -139,14 +141,10 @@ if __name__ == &#39;__main__&#39;:
139 141 enumbins = pars[1]['value']
140 142 duration = pars[2]['value']
141 143 max_threads = pars[3]['value']
142   - #print ntrials
143   - #print enumbins
144   - #print duration
145   - #print max_threads
146 144  
147 145 # Loop over energy bands. The energy bands are those that are also
148 146 # used for sensitivity computation.
149   - for ieng in range(21):
  147 + for ieng in range(20):
150 148  
151 149 # Set energies
152 150 loge = -1.7 + ieng * 0.2
... ...
examples/pipeline_binned_disk.py
... ... @@ -36,7 +36,7 @@ from ctools import obsutils
36 36 def setup_observations(pattern="four", ra=83.63, dec=22.01, offset=1.5, \
37 37 emin=0.1, emax=100.0, rad=5.0, duration=1800.0, \
38 38 deadc=0.95, \
39   - caldb="dummy", irf="cta_dummy_irf"):
  39 + caldb="prod2", irf="South_50h"):
40 40 """
41 41 Returns an observation container.
42 42  
... ... @@ -96,7 +96,7 @@ def run_pipeline(obs, emin=0.1, emax=100.0, \
96 96 enumbins=20, nxpix=200, nypix=200, binsz=0.02, \
97 97 coordsys="CEL", proj="CAR", \
98 98 model="${CTOOLS}/share/models/crab.xml", \
99   - caldb="dummy", irf="cta_dummy_irf", \
  99 + caldb="prod2", irf="South_50h", \
100 100 debug=False):
101 101 """
102 102 Simulation and binned analysis pipeline.
... ... @@ -165,6 +165,7 @@ def run_pipeline(obs, emin=0.1, emax=100.0, \
165 165 like["outmodel"].filename("fit_results.xml")
166 166 like["expcube"].filename("NONE")
167 167 like["psfcube"].filename("NONE")
  168 + like["bkgcube"].filename("NONE")
168 169 like["caldb"].string(caldb)
169 170 like["irf"].string(irf)
170 171 like["debug"].boolean(True) # Switch this always on for results in console
... ...
examples/pipeline_binned_mem.py
... ... @@ -36,7 +36,7 @@ from ctools import obsutils
36 36 def setup_observations(pattern="four", ra=83.63, dec=22.01, offset=1.5, \
37 37 emin=0.1, emax=100.0, rad=5.0, duration=1800.0, \
38 38 deadc=0.95, \
39   - caldb="dummy", irf="cta_dummy_irf"):
  39 + caldb="prod2", irf="South_50h"):
40 40 """
41 41 Returns an observation container.
42 42  
... ...
examples/pipeline_stacked_disk.py
... ... @@ -36,7 +36,7 @@ from ctools import obsutils
36 36 def setup_observations(pattern="four", ra=83.63, dec=22.01, offset=1.5, \
37 37 emin=0.1, emax=100.0, rad=5.0, duration=1800.0, \
38 38 deadc=0.95, \
39   - caldb="dummy", irf="cta_dummy_irf"):
  39 + caldb="prod2", irf="South_50h"):
40 40 """
41 41 Returns an observation container.
42 42  
... ... @@ -96,7 +96,7 @@ def run_pipeline(obs, ra=83.63, dec=22.01, emin=0.1, emax=100.0, \
96 96 enumbins=20, nxpix=200, nypix=200, binsz=0.02, \
97 97 coordsys="CEL", proj="CAR", \
98 98 model="${CTOOLS}/share/models/crab.xml", \
99   - caldb="dummy", irf="cta_dummy_irf", \
  99 + caldb="prod2", irf="South_50h", \
100 100 debug=False):
101 101 """
102 102 Simulation and stacked analysis pipeline.
... ... @@ -210,6 +210,7 @@ def run_pipeline(obs, ra=83.63, dec=22.01, emin=0.1, emax=100.0, \
210 210 like["outmodel"].filename("fit_results.xml")
211 211 like["expcube"].filename("expcube.fits")
212 212 like["psfcube"].filename("psfcube.fits")
  213 + like["bkgcube"].filename("bkgcube.fits")
213 214 like["caldb"].string(caldb)
214 215 like["irf"].string(irf)
215 216 like["debug"].boolean(True) # Switch this always on for results in console
... ...
examples/pipeline_stacked_mem.py
... ... @@ -36,7 +36,7 @@ from ctools import obsutils
36 36 def setup_observations(pattern="four", ra=83.63, dec=22.01, offset=1.5, \
37 37 emin=0.1, emax=100.0, rad=5.0, duration=1800.0, \
38 38 deadc=0.95, \
39   - caldb="dummy", irf="cta_dummy_irf"):
  39 + caldb="prod2", irf="South_50h"):
40 40 """
41 41 Returns an observation container.
42 42  
... ... @@ -188,7 +188,7 @@ def run_pipeline(obs, ra=83.63, dec=22.01, emin=0.1, emax=100.0, \
188 188  
189 189 # Set Exposure and Psf cube for first CTA observation
190 190 # (ctbin will create an observation with a single container)
191   - bin.obs()[0].response(expcube.expcube(), psfcube.psfcube())
  191 + bin.obs()[0].response(expcube.expcube(), psfcube.psfcube(), bkgcube.bkgcube())
192 192  
193 193 # Perform maximum likelihood fitting
194 194 like = ctools.ctlike(bin.obs())
... ...
examples/pipeline_unbinned_disk.py
... ... @@ -36,7 +36,7 @@ from ctools import obsutils
36 36 def setup_observations(pattern="four", ra=83.63, dec=22.01, offset=1.5, \
37 37 emin=0.1, emax=100.0, rad=5.0, duration=1800.0, \
38 38 deadc=0.95, \
39   - caldb="dummy", irf="cta_dummy_irf"):
  39 + caldb="prod2", irf="South_50h"):
40 40 """
41 41 Returns an observation container.
42 42  
... ... @@ -96,7 +96,7 @@ def run_pipeline(obs, ra=83.63, dec=22.01, rad=3.0, \
96 96 emin=0.1, emax=100.0, \
97 97 tmin=0.0, tmax=0.0, \
98 98 model="${CTOOLS}/share/models/crab.xml", \
99   - caldb="dummy", irf="cta_dummy_irf", \
  99 + caldb="prod2", irf="South_50h", \
100 100 debug=False):
101 101 """
102 102 Simulation and unbinned analysis pipeline.
... ...
examples/pipeline_unbinned_mem.py
... ... @@ -36,7 +36,7 @@ from ctools import obsutils
36 36 def setup_observations(pattern="four", ra=83.63, dec=22.01, offset=1.5, \
37 37 emin=0.1, emax=100.0, rad=5.0, duration=1800.0, \
38 38 deadc=0.95, \
39   - caldb="dummy", irf="cta_dummy_irf"):
  39 + caldb="prod2", irf="South_50h"):
40 40 """
41 41 Returns an observation container.
42 42  
... ...
examples/simulate_events.py
... ... @@ -38,7 +38,7 @@ except:
38 38 # ======================== #
39 39 def createobs(ra=86.171648, dec=-1.4774586, rad=5.0, \
40 40 emin=0.1, emax=100.0, duration=360000.0, deadc=0.95, \
41   - irf="cta_dummy_irf", caldb="$CTOOLS/share/caldb/data/cta/dummy"):
  41 + irf="South_50h", caldb="prod2"):
42 42 """
43 43 Create CTA observation.
44 44 """
... ...
models/Makefile.am
1 1 ## Process this file with automake to produce Makefile.in
2 2  
3 3 # Background rate files to distribute
4   -bkgs = bkg_dummy.txt
5   -bkgsdir = $(datadir)/models
6   -bkgs_DATA = $(bkgs)
  4 +#bkgs = bkg_dummy.txt
  5 +#bkgsdir = $(datadir)/models
  6 +#bkgs_DATA = $(bkgs)
7 7  
8 8 # Models to distribute
9 9 models = crab.xml \
... ... @@ -16,4 +16,4 @@ modelsdir = $(datadir)/models
16 16 models_DATA = $(models)
17 17  
18 18 # Extra files to be distributed in the tar file
19   -EXTRA_DIST = $(bkgs) $(models)
  19 +EXTRA_DIST = $(models)
... ...
models/bkg_dummy.txt deleted
1   -19952.6231497 0.00888770093889
2   -31622.7766017 0.0528862764556
3   -50118.7233627 0.0584088588708
4   -79432.8234724 0.0245627698931
5   -125892.541179 0.00930817022553
6   -199526.231497 0.00117990856387
7   -316227.766017 0.000458229904465
8   -501187.233627 0.000135628482432
9   -794328.234724 8.99472876298e-05
10   -1258925.41179 1.46319988679e-05
11   -1995262.31497 2.23452132224e-05
12   -3162277.66017 4.28526605833e-06
13   -5011872.33627 3.02154407423e-06
14   -7943282.34724 8.46588074886e-07
15   -12589254.1179 1.05217831413e-06
16   -19952623.1497 4.95410035794e-07
17   -31622776.6017 3.77171043065e-07
18   -50118723.3627 4.05250267135e-07
19   -79432823.4724 1.31996926243e-07
20   -125892541.179 3.23120422483e-08
models/crab.xml
... ... @@ -11,12 +11,11 @@
11 11 <parameter name="DEC" scale="1.0" value="22.0145" min="-90" max="90" free="0"/>
12 12 </spatialModel>
13 13 </source>
14   - <source name="Background" type="RadialAcceptance" instrument="CTA">
15   - <spectrum type="FileFunction" file="$CTOOLS/share/models/bkg_dummy.txt">
16   - <parameter scale="1.0" name="Normalization" min="0.0" max="1000.0" value="1.0" free="1"/>
  14 + <source name="CTABackgroundModel" type="CTAIrfBackground" instrument="CTA">
  15 + <spectrum type="PowerLaw">
  16 + <parameter name="Prefactor" scale="1.0" value="1.0" min="1e-3" max="1e+3" free="1"/>
  17 + <parameter name="Index" scale="1.0" value="0.0" min="-5.0" max="+5.0" free="1"/>
  18 + <parameter name="Scale" scale="1e6" value="1.0" min="0.01" max="1000.0" free="0"/>
17 19 </spectrum>
18   - <radialModel type="Gaussian">
19   - <parameter name="Sigma" scale="1.0" value="3.0" min="0.01" max="10.0" free="1"/>
20   - </radialModel>
21   - </source>
  20 + </source>
22 21 </source_library>
... ...
models/disk.xml
... ... @@ -12,12 +12,11 @@
12 12 <parameter name="Radius" scale="1.0" value="0.45" min="0.01" max="10" free="1"/>
13 13 </spatialModel>
14 14 </source>
15   - <source name="Background" type="RadialAcceptance" instrument="CTA">
16   - <spectrum type="FileFunction" file="$CTOOLS/share/models/bkg_dummy.txt">
17   - <parameter scale="1.0" name="Normalization" min="0.0" max="1000.0" value="1.0" free="1"/>
  15 + <source name="CTABackgroundModel" type="CTAIrfBackground" instrument="CTA">
  16 + <spectrum type="PowerLaw">
  17 + <parameter name="Prefactor" scale="1.0" value="1.0" min="1e-3" max="1e+3" free="1"/>
  18 + <parameter name="Index" scale="1.0" value="0.0" min="-5.0" max="+5.0" free="1"/>
  19 + <parameter name="Scale" scale="1e6" value="1.0" min="0.01" max="1000.0" free="0"/>
18 20 </spectrum>
19   - <radialModel type="Gaussian">
20   - <parameter name="Sigma" scale="1.0" value="3.0" min="0.01" max="10.0" free="1"/>
21   - </radialModel>
22   - </source>
  21 + </source>
23 22 </source_library>
... ...
models/gauss.xml
... ... @@ -12,12 +12,11 @@
12 12 <parameter name="Sigma" scale="1.0" value="0.20" min="0.01" max="10" free="1"/>
13 13 </spatialModel>
14 14 </source>
15   - <source name="Background" type="RadialAcceptance" instrument="CTA">
16   - <spectrum type="FileFunction" file="$CTOOLS/share/models/bkg_dummy.txt">
17   - <parameter scale="1.0" name="Normalization" min="0.0" max="1000.0" value="1.0" free="1"/>
  15 + <source name="CTABackgroundModel" type="CTAIrfBackground" instrument="CTA">
  16 + <spectrum type="PowerLaw">
  17 + <parameter name="Prefactor" scale="1.0" value="1.0" min="1e-3" max="1e+3" free="1"/>
  18 + <parameter name="Index" scale="1.0" value="0.0" min="-5.0" max="+5.0" free="1"/>
  19 + <parameter name="Scale" scale="1e6" value="1.0" min="0.01" max="1000.0" free="0"/>
18 20 </spectrum>
19   - <radialModel type="Gaussian">
20   - <parameter name="Sigma" scale="1.0" value="3.0" min="0.01" max="10.0" free="1"/>
21   - </radialModel>
22   - </source>
  21 + </source>
23 22 </source_library>
... ...
models/shell.xml
... ... @@ -13,12 +13,11 @@
13 13 <parameter name="Width" scale="1.0" value="0.10" min="0.01" max="10" free="1"/>
14 14 </spatialModel>
15 15 </source>
16   - <source name="Background" type="RadialAcceptance" instrument="CTA">
17   - <spectrum type="FileFunction" file="$CTOOLS/share/models/bkg_dummy.txt">
18   - <parameter scale="1.0" name="Normalization" min="0.0" max="1000.0" value="1.0" free="1"/>
  16 + <source name="CTABackgroundModel" type="CTAIrfBackground" instrument="CTA">
  17 + <spectrum type="PowerLaw">
  18 + <parameter name="Prefactor" scale="1.0" value="1.0" min="1e-3" max="1e+3" free="1"/>
  19 + <parameter name="Index" scale="1.0" value="0.0" min="-5.0" max="+5.0" free="1"/>
  20 + <parameter name="Scale" scale="1e6" value="1.0" min="0.01" max="1000.0" free="0"/>
19 21 </spectrum>
20   - <radialModel type="Gaussian">
21   - <parameter name="Sigma" scale="1.0" value="3.0" min="0.01" max="10.0" free="1"/>
22   - </radialModel>
23   - </source>
  22 + </source>
24 23 </source_library>
... ...
pyext/ctbkgcube.i
... ... @@ -47,7 +47,7 @@ public:
47 47 void clear(void);
48 48 void run(void);
49 49 void save(void);
50   - const GCTACubeBackground& cube(void) const;
  50 + const GCTACubeBackground& bkgcube(void) const;
51 51 const GModels& models(void) const;
52 52 };
53 53  
... ...
pyext/ctools/obsutils.py
... ... @@ -288,7 +288,7 @@ def modmap(obs, eref=0.1, proj=&quot;TAN&quot;, coord=&quot;GAL&quot;, xval=0.0, yval=0.0, \
288 288 # ===================================== #
289 289 def set(pntdir, tstart=0.0, duration=1800.0, deadc=0.95, \
290 290 emin=0.1, emax=100.0, rad=5.0, \
291   - irf="cta_dummy_irf", caldb="dummy"):
  291 + irf="South_50h", caldb="prod2"):
292 292 """
293 293 Obsolete function, use set_obs instead.
294 294 """
... ... @@ -309,7 +309,7 @@ def set(pntdir, tstart=0.0, duration=1800.0, deadc=0.95, \
309 309 # ======================= #
310 310 def set_obs(pntdir, tstart=0.0, duration=1800.0, deadc=0.95, \
311 311 emin=0.1, emax=100.0, rad=5.0, \
312   - irf="cta_dummy_irf", caldb="dummy", id="000000", instrument="CTA"):
  312 + irf="South_50h", caldb="prod2", id="000000", instrument="CTA"):
313 313 """
314 314 Returns a single CTA observation containing an empty CTA event list.
315 315 By looping over this function you can add CTA observations to the
... ... @@ -384,7 +384,7 @@ def set_obs(pntdir, tstart=0.0, duration=1800.0, deadc=0.95, \
384 384 # ============================ #
385 385 def set_obs_list(obsdeflist, tstart=0.0, duration=1800.0, deadc=0.95, \
386 386 emin=0.1, emax=100.0, rad=5.0, \
387   - irf="cta_dummy_irf", caldb="dummy"):
  387 + irf="South_50h", caldb="prod2"):
388 388 """
389 389 Returns an observation container filled with a list of CTA observations.
390 390 The list is defined by the obsdeflist parameter which is a dictionnary
... ... @@ -584,9 +584,9 @@ def spectrum(obs, source, ebounds):
584 584  
585 585 # Clone observations and reset energy thresholds
586 586 select = ctools.ctselect(obs)
587   - select["ra"].real(-1.0)
588   - select["dec"].real(-1.0)
589   - select["rad"].real(-1.0)
  587 + select["ra"].value("UNDEF")
  588 + select["dec"].value("UNDEF")
  589 + select["rad"].value("UNDEF")
590 590 select["tmin"].real(0.0)
591 591 select["tmax"].real(0.0)
592 592 select["emin"].real(ebounds.emin(i).TeV())
... ...
scripts/cslightcrv.py
... ... @@ -105,15 +105,17 @@ class cslightcrv(ctools.cscript):
105 105 pars.append(gammalib.GApplicationPar("expcube","f","a","NONE","","","Exposure cube file (only needed for stacked analysis)"))
106 106 pars.append(gammalib.GApplicationPar("psfcube","f","a","NONE","","","PSF cube file (only needed for stacked analysis)"))
107 107 pars.append(gammalib.GApplicationPar("bkgcube","s","a","NONE","","","Background cube file (only needed for stacked analysis)"))
108   - pars.append(gammalib.GApplicationPar("caldb","s","a","dummy","","","Calibration database"))
109   - pars.append(gammalib.GApplicationPar("irf","s","a","cta_dummy_irf","","","Instrument response function"))
110   - pars.append(gammalib.GApplicationPar("tmin","r","a","51544.5","","days","Lightcurve Time start [MJD]"))
111   - pars.append(gammalib.GApplicationPar("tmax","r","a","51544.6","","days","Lightcurve Time stop [MJD]"))
112   - pars.append(gammalib.GApplicationPar("tbins","i","a","5","","","Number of time bins points"))
113   - pars.append(gammalib.GApplicationPar("tbinalg","s", "a","GTI","FILE|LIN|GTI","", "Algorithm for defining energy bins"))
114   - pars.append(gammalib.GApplicationPar("tbinfile","s", "a","tbins.fits","","", "File defining the time binning"))
115   - pars.append(gammalib.GApplicationPar("binned","b","a","no","yes|no","","Use binned analysis in each energy bin"))
116   - pars.append(gammalib.GApplicationPar("nebins","i","h","20","","","Number of energy bins per light curve point"))
  108 + pars.append(gammalib.GApplicationPar("caldb","s","a","prod2","","","Calibration database"))
  109 + pars.append(gammalib.GApplicationPar("irf","s","a","South_50h","","","Instrument response function"))
  110 + pars.append(gammalib.GApplicationPar("tbinalg","s","h","GTI","FILE|LIN|GTI","", "Algorithm for defining time bins"))
  111 + pars.append(gammalib.GApplicationPar("tmin","r","a","51544.5","","days","Lightcurve start time [MJD]"))
  112 + pars.append(gammalib.GApplicationPar("tmax","r","a","51544.6","","days","Lightcurve stop time [MJD]"))
  113 + pars.append(gammalib.GApplicationPar("tbins","i","a","5","","","Number of time bins"))
  114 + pars.append(gammalib.GApplicationPar("tbinfile","f","a","tbins.fits","","", "File defining the time binning"))
  115 + #pars.append(gammalib.GApplicationPar("binned","b","a","no","yes|no","","Use binned analysis in each time bin"))
  116 + pars.append(gammalib.GApplicationPar("enumbins","i","a","0","","","Number of energy bins per light curve bin (0=unbinned)"))
  117 + pars.append(gammalib.GApplicationPar("emin","r","a","0.1","","","Lower energy limit of events (TeV)"))
  118 + pars.append(gammalib.GApplicationPar("emax","r","a","100.0","","","Upper energy limit of events (TeV)"))
117 119 pars.append(gammalib.GApplicationPar("coordsys","s","a","CEL","CEL|GAL","","Coordinate System"))
118 120 pars.append(gammalib.GApplicationPar("proj","s","a","CAR","AIT|AZP|CAR|MER|MOL|STG|TAN","","Projection method"))
119 121 pars.append(gammalib.GApplicationPar("xref","r","a","83.63","0","360","First coordinate of image center in degrees (RA or galactic l)"))
... ... @@ -121,12 +123,10 @@ class cslightcrv(ctools.cscript):
121 123 pars.append(gammalib.GApplicationPar("nxpix","i","a","200","","","Size of the X axis in pixels"))
122 124 pars.append(gammalib.GApplicationPar("nypix","i","a","200","","","Size of the Y axis in pixels"))
123 125 pars.append(gammalib.GApplicationPar("binsz","r","a","0.02","","","Pixel size (deg/pixel)"))
124   - pars.append(gammalib.GApplicationPar("emin","r","a","0.1","","","Lower energy limit for binned analysis (TeV)"))
125   - pars.append(gammalib.GApplicationPar("emax","r","a","100.0","","","Upper energy limit for binned analysis (TeV)"))
126   - pars.append(gammalib.GApplicationPar("calc_ts","b","h","yes","yes|no","","Compute TS value in each bin"))
127   - pars.append(gammalib.GApplicationPar("calc_ulim","b","h","yes","yes|no","","Compute upper limit in each bin"))
128   - pars.append(gammalib.GApplicationPar("fix_srcs","b","h","yes","yes|no","","Fix other skymodel parameters"))
129   - pars.append(gammalib.GApplicationPar("fix_bkg","b","h","no","yes|no","","Fix background parameters"))
  126 + pars.append(gammalib.GApplicationPar("calc_ts","b","h","yes","yes|no","","Compute TS value for each bin?"))
  127 + pars.append(gammalib.GApplicationPar("calc_ulim","b","h","yes","yes|no","","Compute upper limit for each bin?"))
  128 + pars.append(gammalib.GApplicationPar("fix_srcs","b","h","yes","yes|no","","Fix other sky model parameters?"))
  129 + pars.append(gammalib.GApplicationPar("fix_bkg","b","h","no","yes|no","","Fix background model parameters?"))
130 130 pars.append_standard()
131 131 pars.append(gammalib.GApplicationPar("logfile","f","h","cslightcrv.log","","","Log filename"))
132 132 pars.save(parfile)
... ... @@ -190,22 +190,33 @@ class cslightcrv(ctools.cscript):
190 190 # Get source name
191 191 self.m_srcname = self["srcname"].string()
192 192  
193   - # Get ebounds
  193 + # Get time boundaries
194 194 self.create_tbounds()
195 195  
  196 + # Unbinned or binned analysis?
  197 + self.m_ebins = self["enumbins"].integer()
  198 + if self.m_ebins == 0:
  199 + self.m_binned = False
  200 + else:
  201 + self.m_binned = True
  202 +
  203 + # Get energy range
  204 + self.m_emin = self["emin"].real()
  205 + self.m_emax = self["emax"].real()
  206 +
196 207 # Get binning flag
197   - self.m_binned = self["binned"].boolean()
  208 + #self.m_binned = self["binned"].boolean()
198 209 if self.m_binned:
  210 + self.m_coordsys = self["coordsys"].string()
  211 + self.m_proj = self["proj"].string()
199 212 self.m_xref = self["xref"].real()
200 213 self.m_yref = self["yref"].real()
201 214 self.m_nxpix = self["nxpix"].integer()
202 215 self.m_nypix = self["nypix"].integer()
203 216 self.m_binsz = self["binsz"].real()
204   - self.m_coordsys = self["coordsys"].string()
205   - self.m_proj = self["proj"].string()
206   - self.m_ebins = self["nebins"].integer()
207   - self.m_emin = self["emin"].real()
208   - self.m_emax = self["emax"].real()
  217 + #self.m_ebins = self["enumbins"].integer()
  218 + #self.m_emin = self["emin"].real()
  219 + #self.m_emax = self["emax"].real()
209 220  
210 221 # Read other parameters
211 222 self.m_outfile = self["outfile"].filename()
... ... @@ -367,8 +378,8 @@ class cslightcrv(ctools.cscript):
367 378  
368 379 # Select events
369 380 select = ctools.ctselect(self.obs)
370   - select["emin"].value("UNDEFINED")
371   - select["emax"].value("UNDEFINED")
  381 + select["emin"].real(self.m_emin)
  382 + select["emax"].real(self.m_emax)
372 383 select["tmin"].real(tmin.convert(select.time_reference()))
373 384 select["tmax"].real(tmax.convert(select.time_reference()))
374 385 select["rad"].value("UNDEFINED")
... ... @@ -469,7 +480,7 @@ class cslightcrv(ctools.cscript):
469 480 obs = bin.obs()
470 481  
471 482 # Set precomputed binned response
472   - obs[0].response(expcube.expcube(), psfcube.psfcube(), bkgcube.cube())
  483 + obs[0].response(expcube.expcube(), psfcube.psfcube(), bkgcube.bkgcube())
473 484  
474 485 # Get new models
475 486 models = bkgcube.models()
... ...
scripts/cspull.py
... ... @@ -99,20 +99,20 @@ class cspull(ctools.cscript):
99 99 pars.append(gammalib.GApplicationPar("expcube","s","a","NONE","","","Exposure cube file (only needed for stacked analysis)"))
100 100 pars.append(gammalib.GApplicationPar("psfcube","s","a","NONE","","","PSF cube file (only needed for stacked analysis)"))
101 101 pars.append(gammalib.GApplicationPar("bkgcube","s","a","NONE","","","Background cube file (only needed for stacked analysis)"))
102   - pars.append(gammalib.GApplicationPar("caldb","s","a","dummy","","","Calibration database"))
103   - pars.append(gammalib.GApplicationPar("irf","s","a","cta_dummy_irf","","","Instrument response function"))
  102 + pars.append(gammalib.GApplicationPar("caldb","s","a","prod2","","","Calibration database"))
  103 + pars.append(gammalib.GApplicationPar("irf","s","a","South_50h","","","Instrument response function"))
  104 + pars.append(gammalib.GApplicationPar("deadc","r","h","0.95","0","1","Deadtime correction factor"))
104 105 pars.append(gammalib.GApplicationPar("edisp","b","h","no","","","Apply energy dispersion?"))
105 106 pars.append(gammalib.GApplicationPar("ntrials","i","a","10","","","Number of trials"))
106 107 pars.append(gammalib.GApplicationPar("ra","r","a","83.6331","0","360","RA of pointing (deg)"))
107 108 pars.append(gammalib.GApplicationPar("dec","r","a","22.0145","-90","90","Dec of pointing (deg)"))
108 109 pars.append(gammalib.GApplicationPar("emin","r","a","0.1","","","Lower energy limit (TeV)"))
109 110 pars.append(gammalib.GApplicationPar("emax","r","a","100.0","","","Upper energy limit (TeV)"))
  111 + pars.append(gammalib.GApplicationPar("enumbins","i","a","0","","","Number of energy bins (0=unbinned)"))
110 112 pars.append(gammalib.GApplicationPar("tmin","r","h","0.0","","","Start time (MET in s)"))
111 113 pars.append(gammalib.GApplicationPar("tmax","r","a","1800.0","","","Duration (in s)"))
112   - pars.append(gammalib.GApplicationPar("enumbins","i","a","0","","","Number of energy bins (0=unbinned)"))
113 114 pars.append(gammalib.GApplicationPar("npix","i","a","200","","","Number of pixels for binned"))
114 115 pars.append(gammalib.GApplicationPar("binsz","r","a","0.05","","","Pixel size for binned (deg/pixel)"))
115   - pars.append(gammalib.GApplicationPar("deadc","r","h","0.95","0","1","Deadtime correction factor"))
116 116 pars.append(gammalib.GApplicationPar("rad","r","h","5.0","0","180","Radius of ROI (deg)"))
117 117 pars.append(gammalib.GApplicationPar("pattern","s","h","single","","","Observation pattern (single/four)"))
118 118 pars.append(gammalib.GApplicationPar("offset","r","h","1.5","","","Observation pattern offset (deg)"))
... ...
scripts/csresmap.py
... ... @@ -103,8 +103,8 @@ class csresmap(ctools.cscript):
103 103 pars.append(gammalib.GApplicationPar("inobs","f","a","events.fits","","","Event list, counts cube, or observation definition file"))
104 104 pars.append(gammalib.GApplicationPar("inmodel","f","a","$CTOOLS/share/models/crab.xml","","","Source model"))
105 105 pars.append(gammalib.GApplicationPar("outmap","f","a","resmap.fits","","","Output residual map"))
106   - pars.append(gammalib.GApplicationPar("caldb","s","a","dummy","","","Calibration database"))
107   - pars.append(gammalib.GApplicationPar("irf","s","a","cta_dummy_irf","","","Instrument response function"))
  106 + pars.append(gammalib.GApplicationPar("caldb","s","a","prod2","","","Calibration database"))
  107 + pars.append(gammalib.GApplicationPar("irf","s","a","South_50h","","","Instrument response function"))
108 108 pars.append(gammalib.GApplicationPar("ebinalg","s","h","LOG","LIN|LOG|FILE","","Binning algorithm"))
109 109 pars.append(gammalib.GApplicationPar("emin","r","h","0.1","","","Lower energy limit (TeV)"))
110 110 pars.append(gammalib.GApplicationPar("emax","r","h","100.0","","","Upper energy limit (TeV)"))
... ...
scripts/cssens.py
... ... @@ -101,8 +101,8 @@ class cssens(ctools.cscript):
101 101 pars.append(gammalib.GApplicationPar("inmodel","f","a","$CTOOLS/share/models/crab.xml","","","Source model"))
102 102 pars.append(gammalib.GApplicationPar("srcname","s","a","Crab","","","Source name"))
103 103 pars.append(gammalib.GApplicationPar("offset","r","h","0.0","","","Source offset angle (deg)"))
104   - pars.append(gammalib.GApplicationPar("caldb","s","a","dummy","","","Calibration database"))
105   - pars.append(gammalib.GApplicationPar("irf","s","a","cta_dummy_irf","","","Instrument response function"))
  104 + pars.append(gammalib.GApplicationPar("caldb","s","a","prod2","","","Calibration database"))
  105 + pars.append(gammalib.GApplicationPar("irf","s","a","South_50h","","","Instrument response function"))
106 106 pars.append(gammalib.GApplicationPar("deadc","r","h","0.95","0","1","Deadtime correction factor"))
107 107 pars.append(gammalib.GApplicationPar("outfile","f","h","sensitivity.dat","","","Output file name"))
108 108 pars.append(gammalib.GApplicationPar("duration","r","a","180000.0","","","Effective exposure time (s)"))
... ...
scripts/csspec.py
... ... @@ -106,8 +106,8 @@ class csspec(ctools.cscript):
106 106 pars.append(gammalib.GApplicationPar("expcube","f","a","NONE","","","Exposure cube file (only needed for stacked analysis)"))
107 107 pars.append(gammalib.GApplicationPar("psfcube","f","a","NONE","","","PSF cube file (only needed for stacked analysis)"))
108 108 pars.append(gammalib.GApplicationPar("bkgcube","s","a","NONE","","","Background cube file (only needed for stacked analysis)"))
109   - pars.append(gammalib.GApplicationPar("caldb","s","a","dummy","","","Calibration database"))
110   - pars.append(gammalib.GApplicationPar("irf","s","a","cta_dummy_irf","","","Instrument response function"))
  109 + pars.append(gammalib.GApplicationPar("caldb","s","a","prod2","","","Calibration database"))
  110 + pars.append(gammalib.GApplicationPar("irf","s","a","South_50h","","","Instrument response function"))
111 111 pars.append(gammalib.GApplicationPar("emin","r","h","0.1","","","Lower energy limit for spectral points(TeV)"))
112 112 pars.append(gammalib.GApplicationPar("emax","r","h","100.0","","","Upper energy limit for spectral points(TeV)"))
113 113 pars.append(gammalib.GApplicationPar("enumbins","i","a","20","","","Number of spectral points"))
... ... @@ -424,7 +424,7 @@ class csspec(ctools.cscript):
424 424 obs = bin.obs()
425 425  
426 426 # Set precomputed binned response
427   - obs[0].response(expcube.expcube(), psfcube.psfcube(), bkgcube.cube())
  427 + obs[0].response(expcube.expcube(), psfcube.psfcube(), bkgcube.bkgcube())
428 428  
429 429 # Get new models
430 430 models = bkgcube.models()
... ...
scripts/cstsdist.py
... ... @@ -95,27 +95,29 @@ class cstsdist(ctools.cscript):
95 95 # Create default parfile
96 96 pars = gammalib.GApplicationPars()
97 97 pars.append(gammalib.GApplicationPar("inobs","f","h","NONE","","","Event list, counts cube, or observation definition file"))
98   - pars.append(gammalib.GApplicationPar("outfile","f","h","ts.dat","","","Output file name"))
  98 + pars.append(gammalib.GApplicationPar("inmodel","f","a","$CTOOLS/share/models/crab.xml","","","Source model"))
  99 + pars.append(gammalib.GApplicationPar("srcname","s","a","Crab","","","Source name"))
  100 + pars.append(gammalib.GApplicationPar("outfile","f","a","ts.dat","","","Output file name"))
99 101 pars.append(gammalib.GApplicationPar("expcube","s","a","NONE","","","Exposure cube file (only needed for stacked analysis)"))
100 102 pars.append(gammalib.GApplicationPar("psfcube","s","a","NONE","","","PSF cube file (only needed for stacked analysis)"))
101   - pars.append(gammalib.GApplicationPar("caldb","s","a","dummy","","","Calibration database"))
102   - pars.append(gammalib.GApplicationPar("irf","s","a","cta_dummy_irf","","","Instrument response function"))
103   - pars.append(gammalib.GApplicationPar("ra","r","h","83.63","0","360","RA of pointing (deg)"))
104   - pars.append(gammalib.GApplicationPar("dec","r","h","22.01","-90","90","Dec of pointing (deg)"))
  103 + pars.append(gammalib.GApplicationPar("bkgcube","s","a","NONE","","","Background cube file (only needed for stacked analysis)"))
  104 + pars.append(gammalib.GApplicationPar("caldb","s","a","prod2","","","Calibration database"))
  105 + pars.append(gammalib.GApplicationPar("irf","s","a","South_50h","","","Instrument response function"))
  106 + pars.append(gammalib.GApplicationPar("deadc","r","h","0.95","","","Deadtime correction factor"))
  107 + pars.append(gammalib.GApplicationPar("edisp","b","h","no","","","Apply energy dispersion?"))
  108 + pars.append(gammalib.GApplicationPar("ntrials","i","a","10","","","Number of trials"))
  109 + pars.append(gammalib.GApplicationPar("ra","r","a","83.63","0","360","RA of pointing (deg)"))
  110 + pars.append(gammalib.GApplicationPar("dec","r","a","22.01","-90","90","Dec of pointing (deg)"))
105 111 pars.append(gammalib.GApplicationPar("emin","r","a","0.1","","","Lower energy limit (TeV)"))
106 112 pars.append(gammalib.GApplicationPar("emax","r","a","100.0","","","Upper energy limit (TeV)"))
  113 + pars.append(gammalib.GApplicationPar("enumbins","i","a","0","","","Number of energy bins (0=unbinned)"))
107 114 pars.append(gammalib.GApplicationPar("tmin","r","h","0.0","","","Start time (MET in s)"))
108 115 pars.append(gammalib.GApplicationPar("tmax","r","a","1800.0","","","Observation duration (in s)"))
109   - pars.append(gammalib.GApplicationPar("enumbins","i","a","0","","","Number of energy bins (0=unbinned)"))
110   - pars.append(gammalib.GApplicationPar("npix","i","h","200","","","Number of pixels for binned"))
111   - pars.append(gammalib.GApplicationPar("binsz","r","h","0.05","","","Pixel size for binned (deg/pixel)"))
112   - pars.append(gammalib.GApplicationPar("deadc","r","h","0.95","","","Deadtime correction factor"))
  116 + pars.append(gammalib.GApplicationPar("npix","i","a","200","","","Number of pixels for binned"))
  117 + pars.append(gammalib.GApplicationPar("binsz","r","a","0.05","","","Pixel size for binned (deg/pixel)"))
113 118 pars.append(gammalib.GApplicationPar("rad","r","h","5.0","","","Radius of ROI (deg)"))
114   - pars.append(gammalib.GApplicationPar("ntrials","i","a","10","","","Number of trials"))
115   - pars.append(gammalib.GApplicationPar("type","s","a","point","","","Source model type (point/gauss/shell/disk)"))
116   - pars.append(gammalib.GApplicationPar("index","r","h","-2.48","","","Spectral index"))
117   - pars.append(gammalib.GApplicationPar("offset","r","a","0.0","","","Source offset angle (deg)"))
118   - pars.append(gammalib.GApplicationPar("bkg","s","a","$CTOOLS/share/models/bkg_dummy.txt","","","Background model file function"))
  119 + pars.append(gammalib.GApplicationPar("pattern","s","h","single","","","Observation pattern (single/four)"))
  120 + pars.append(gammalib.GApplicationPar("offset","r","h","1.5","","","Observation pattern offset (deg)"))
119 121 pars.append_standard()
120 122 pars.append(gammalib.GApplicationPar("logfile","f","h","cstsdist.log","","","Log filename"))
121 123 pars.save(parfile)
... ... @@ -131,6 +133,15 @@ class cstsdist(ctools.cscript):
131 133 # Set observation if not done before
132 134 if self.obs == None or self.obs.size() == 0:
133 135 self.obs = self.get_observations()
  136 +
  137 + # Check for requested pattern and use above
  138 + # observation parameters to set wobble pattern
  139 + self.m_pattern = self["pattern"].string()
  140 + if self.m_pattern == "four":
  141 + self.obs = self.set_obs()
  142 +
  143 + # Get source name
  144 + self.m_srcname = self["srcname"].string()
134 145  
135 146 # Get number of energy bins
136 147 self.m_enumbins = self["enumbins"].integer()
... ... @@ -143,36 +154,21 @@ class cstsdist(ctools.cscript):
143 154 # Set dummy values (required by obsutils)
144 155 self.m_npix = 0
145 156 self.m_binsz = 0.0
  157 +
  158 + # Set models if we have none
  159 + if self.obs.models().size() == 0:
  160 + self.obs.models(self["inmodel"].filename())
146 161  
147 162 # Get other parameters
148   - self.m_outfile = self["outfile"].filename()
149   - self.m_ntrials = self["ntrials"].integer()
150   - self.m_type = self["type"].string()
151   - self.m_index = self["index"].real()
152   - self.m_offset = self["offset"].real()
153   - self.m_bkg = self["bkg"].string()
  163 + self.m_outfile = self["outfile"].filename()
  164 + self.m_ntrials = self["ntrials"].integer()
  165 + self.m_edisp = self["edisp"].boolean()
  166 + self.m_offset = self["offset"].real()
154 167  
155 168 # Set some fixed parameters
156   - self.m_log = False # Logging in client tools
157   - self.m_debug = False # Debugging in client tools
158   -
159   - pnt = gammalib.GSkyDir()
160   - pnt.radec_deg(self["ra"].real(),self["dec"].real())
161   -
162   - # Initialise models. Note that we centre the point source at the
163   - # center of our observation, so we're onaxis.
164   - self.bkg_model = gammalib.GModels()
165   - self.full_model = gammalib.GModels()
166   - self.bkg_model.append(self.set_bkg_model())
167   - self.full_model.append(self.set_bkg_model())
168   - self.full_model.append(self.set_src_model(pnt.l_deg(), pnt.b_deg()+self.m_offset, \
169   - flux=0.010, \
170   - type=self.m_type, \
171   - index=self.m_index))
172   -
173   - # Attach background model to observation container
174   - self.obs.models(self.bkg_model)
175   -
  169 + self.m_log = False # Logging in client tools
  170 + self.m_debug = self["debug"].boolean() # Debugging in client tools
  171 +
176 172 # Return
177 173 return
178 174  
... ... @@ -211,6 +207,20 @@ class cstsdist(ctools.cscript):
211 207 if self.logTerse():
212 208 self.log_parameters()
213 209 self.log("\n")
  210 +
  211 + # Initialise models
  212 + full_model, bkg_model = self.set_models()
  213 +
  214 + # Write models into logger
  215 + if self.logTerse():
  216 + self.log("\n")
  217 + self.log.header1("Models")
  218 + self.log.header2("Background model")
  219 + self.log(str(bkg_model))
  220 + self.log("\n\n")
  221 + self.log.header2("Full model")
  222 + self.log(str(full_model))
  223 + self.log("\n")
214 224  
215 225 # Write observation into logger
216 226 if self.logTerse():
... ... @@ -235,7 +245,7 @@ class cstsdist(ctools.cscript):
235 245 for seed in range(self.m_ntrials):
236 246  
237 247 # Make a trial
238   - result = self.trial(seed)
  248 + result = self.trial(seed, full_model, bkg_model)
239 249  
240 250 # Write out result immediately
241 251 if seed == 0:
... ... @@ -251,97 +261,89 @@ class cstsdist(ctools.cscript):
251 261 # Return
252 262 return
253 263  
254   - def set_bkg_model(self, fitsigma=False):
  264 + def set_models(self, fitpos=False, fitspec=False):
255 265 """
256   - Setup CTA background model.
  266 + Set full and background model.
257 267 """
258   - # Define radial component
259   - radial = gammalib.GCTAModelRadialGauss(3.0)
260   - if fitsigma:
261   - radial["Sigma"].free()
262   - else:
263   - radial["Sigma"].fix()
264   -
265   - # Define spectral component
266   - spectrum = gammalib.GModelSpectralFunc(self.m_bkg, 1.0)
  268 + # Retrieve full model from observation container
  269 + full_model = self.obs.models().copy()
  270 +
  271 + # Get source model
  272 + model = full_model[self.m_srcname]
267 273  
268   - # Create background model
269   - model = gammalib.GCTAModelRadialAcceptance(radial, spectrum)
270   - model.name("Background")
271   - model.instruments("CTA")
272   -
273   - # Return background model
274   - return model
275   -
276   - def set_src_model(self, l, b, flux=1.0, index=-2.48, \
277   - type="point", sigma=1.0, radius=1.0, width=0.1, \
278   - fitpos=False, fitidx=False):
279   - """
280   - Returns a single source with Crab-like spectrum. The source flux
281   - can be scaled in Crab units. The Crab spectrum is based on MAGIC
282   - observations (Albert et al. 2008, ApJ, 674, 1037).
  274 + # Check that model has a Prefactor
  275 + if not model.has_par("Prefactor"):
  276 + msg = "Model \""+self.m_srcname+"\" has no parameter \"Prefactor\"."+ \
  277 + " Only spectral models with a \"Prefactor\" parameter are supported."
  278 + raise gammalib.GException.invalid_value("cssens", msg)
283 279  
284   - Parameters:
285   - l - Galactic longitude of source location [deg]
286   - b - Galactic latitude of source location [deg]
287   - Keywords:
288   - flux - Source flux [Crabs]
289   - index - Spectral index
290   - type - Source type ("point", "gauss", "disk", "shell")
291   - sigma - Gaussian sigma (for type="gauss")
292   - radius - Disk or shell inner radius [deg] (for type="disk" and type="shell")
293   - width - Shell width [deg] (for type="shell")
294   - fitpos - Fit position? (default: True)
295   - fitidx - Fit index? (default: True)
296   - """
297   - # Set source location
298   - location = gammalib.GSkyDir()
299   - location.lb_deg(l, b)
300   -
301   - # Set source spectrum
302   - spectrum = gammalib.GModelSpectralPlaw(flux*5.7e-16, index, gammalib.GEnergy(0.3, "TeV"))
303   - if fitidx:
304   - spectrum["Index"].free()
  280 + # Fit or fix spatial parameters
  281 + if fitpos:
  282 + if model.has_par("RA"):
  283 + model["RA"].free()
  284 + if model.has_par("DEC"):
  285 + model["DEC"].free()
  286 + if model.has_par("Sigma"):
  287 + model["Sigma"].free()
  288 + if model.has_par("Radius"):
  289 + model["Radius"].free()
  290 + if model.has_par("Width"):
  291 + model["Width"].free()
305 292 else:
306   - spectrum["Index"].fix()
307   -
308   - # Set source
309   - if type == "point":
310   - spatial = gammalib.GModelSpatialPointSource(location)
311   - if fitpos:
312   - spatial[0].free()
313   - spatial[1].free()
314   - elif type == "gauss":
315   - spatial = gammalib.GModelSpatialRadialGauss(location, sigma)
316   - if fitpos:
317   - spatial[0].free()
318   - spatial[1].free()
319   - elif type == "disk":
320   - spatial = gammalib.GModelSpatialRadialDisk(location, radius)
321   - if fitpos:
322   - spatial[0].free()
323   - spatial[1].free()
324   - elif type == "shell":
325   - spatial = gammalib.GModelSpatialRadialShell(location, radius, width)
326   - if fitpos:
327   - spatial[0].free()
328   - spatial[1].free()
  293 + if model.has_par("RA"):
  294 + model["RA"].fix()
  295 + if model.has_par("DEC"):
  296 + model["DEC"].fix()
  297 + if model.has_par("Sigma"):
  298 + model["Sigma"].fix()
  299 + if model.has_par("Radius"):
  300 + model["Radius"].fix()
  301 + if model.has_par("Width"):
  302 + model["Width"].fix()
  303 +
  304 + # Fit or fix spectral parameters
  305 + if fitspec:
  306 + if model.has_par("Index"):
  307 + model["Index"].free()
  308 + if model.has_par("Cutoff"):
  309 + model["Cutoff"].free()
329 310 else:
330   - self.log("ERROR: Unknown source type '"+type+"'.\n")
331   - return None
332   - source = gammalib.GModelSky(spatial, spectrum)
  311 + if model.has_par("Index"):
  312 + model["Index"].fix()
  313 + if model.has_par("Cutoff"):
  314 + model["Cutoff"].fix()
333 315  
334   - # Set source name
335   - source.name("Test")
  316 + # Create background model
  317 + bkg_model = full_model.copy()
  318 + bkg_model.remove(self.m_srcname)
  319 +
  320 + # Return models
  321 + return full_model, bkg_model
  322 +
  323 + def set_obs(self):
  324 + """
  325 + Returns an observation container with a set of CTA observations.
336 326  
337   - # Turn TS value computation off
338   - # since we compute it by hand later on
339   - source.tscalc(False)
340   -
341   - # Return source
342   - return source
  327 + Keywords:
  328 + """
  329 +
  330 + # Setup observation definition list
  331 + obsdeflist = obsutils.set_obs_patterns(self.m_pattern, \
  332 + ra=self["ra"].real(), dec=self["dec"].real(), \
  333 + offset=self["offset"].real())
  334 +
  335 + # Create list of observations
  336 + obs = obsutils.set_obs_list(obsdeflist, \
  337 + tstart=self["tmin"].real(), duration=self["tmax"].real()-self["tmin"].real(), \
  338 + deadc=self["deadc"].real(), \
  339 + emin=self["emin"].real(), emax=self["emax"].real(), \
  340 + rad=self["rad"].real(), \
  341 + irf=self["irf"].string(), caldb=self["caldb"].string())
343 342  
344   - def trial(self, seed):
  343 + # Return observation container
  344 + return obs
  345 +
  346 + def trial(self, seed, full_model, bkg_model):
345 347 """
346 348 Create the TS for a single trial.
347 349  
... ... @@ -373,9 +375,9 @@ class cstsdist(ctools.cscript):
373 375 self.log("\n")
374 376  
375 377 # Fit background only
376   - sim.models(self.bkg_model)
  378 + sim.models(bkg_model)
377 379 like_bgm = obsutils.fit(sim, log=self.m_log, debug=self.m_debug)
378   - result_bgm = like_bgm.obs().models()
  380 + result_bgm = like_bgm.obs().models().copy()
379 381 LogL_bgm = like_bgm.opt().value()
380 382 npred_bgm = like_bgm.obs().npred()
381 383  
... ... @@ -396,9 +398,9 @@ class cstsdist(ctools.cscript):
396 398 self.log(str(par)+"\n")
397 399  
398 400 # Fit background and test source
399   - sim.models(self.full_model)
  401 + sim.models(full_model)
400 402 like_all = obsutils.fit(sim, log=self.m_log, debug=self.m_debug)
401   - result_all = like_all.obs().models()
  403 + result_all = like_all.obs().models().copy()
402 404 LogL_all = like_all.opt().value()
403 405 npred_all = like_all.obs().npred()
404 406 ts = 2.0*(LogL_bgm-LogL_all)
... ... @@ -428,9 +430,9 @@ class cstsdist(ctools.cscript):
428 430 self.log("TS=")
429 431 self.log(ts)
430 432 self.log(" Prefactor=")
431   - self.log(result_all["Test"]["Prefactor"].value())
  433 + self.log(result_all[self.m_srcname]["Prefactor"].value())
432 434 self.log("+/-")
433   - self.log(result_all["Test"]["Prefactor"].error())
  435 + self.log(result_all[self.m_srcname]["Prefactor"].error())
434 436 self.log("\n")
435 437  
436 438 # Initialise results
... ...
src/ctbkgcube/ctbkgcube.hpp
... ... @@ -59,7 +59,7 @@ public:
59 59 void clear(void);
60 60 void run(void);
61 61 void save(void);
62   - const GCTACubeBackground& cube(void) const;
  62 + const GCTACubeBackground& bkgcube(void) const;
63 63 const GModels& models(void) const;
64 64  
65 65 protected:
... ... @@ -86,7 +86,7 @@ protected:
86 86 * @return Background response cube.
87 87 ***************************************************************************/
88 88 inline
89   -const GCTACubeBackground& ctbkgcube::cube(void) const
  89 +const GCTACubeBackground& ctbkgcube::bkgcube(void) const
90 90 {
91 91 // Return background cube
92 92 return (m_background);
... ...
src/ctbkgcube/ctbkgcube.par
... ... @@ -22,8 +22,8 @@ inmodel, f, a, &quot;NONE&quot;,,, &quot;Input model XML file&quot;
22 22 incube, f, a, "NONE",,, "Counts cube for background cube definition"
23 23 outcube, f, a, "bkgcube.fits",,, "Output background cube file"
24 24 outmodel, f, a, "NONE",,, "Output model XML file"
25   -caldb, s, a, "dummy",,, "Calibration database"
26   -irf, s, a, "cta_dummy_irf",,, "Instrument response function"
  25 +caldb, s, a, "prod2",,, "Calibration database"
  26 +irf, s, a, "South_50h",,, "Instrument response function"
27 27 #
28 28 # Energy binning parameters
29 29 #==========================
... ...
src/ctbutterfly/ctbutterfly.par
... ... @@ -23,8 +23,8 @@ srcname, s, a, &quot;Crab&quot;,,,&quot;Source of interest&quot;
23 23 expcube, f, a, "NONE",,, "Exposure cube file (only needed for stacked analysis)"
24 24 psfcube, f, a, "NONE",,, "PSF cube file (only needed for stacked analysis)"
25 25 bkgcube, f, a, "NONE",,, "Background cube file (only needed for stacked analysis)"
26   -caldb, s, a, "dummy",,, "Calibration database"
27   -irf, s, a, "cta_dummy_irf",,, "Instrument response function"
  26 +caldb, s, a, "prod2",,, "Calibration database"
  27 +irf, s, a, "South_50h",,, "Instrument response function"
28 28 outfile, f, a, "butterfly.txt",,, "Output ascii file"
29 29 matrix, f, h, "NONE",,, "Input covariance Matrix FITS file"
30 30  
... ...
src/ctexpcube/ctexpcube.par
... ... @@ -20,8 +20,8 @@
20 20 inobs, f, a, "NONE",,, "Event list or observation definition file"
21 21 incube, f, a, "NONE",,, "Counts cube for exposure cube definition"
22 22 outcube, f, a, "expcube.fits",,, "Output exposure cube file"
23   -caldb, s, a, "dummy",,, "Calibration database"
24   -irf, s, a, "cta_dummy_irf",,, "Instrument response function"
  23 +caldb, s, a, "prod2",,, "Calibration database"
  24 +irf, s, a, "South_50h",,, "Instrument response function"
25 25 edisp, b, h, no,,, "Apply energy dispersion?"
26 26 #
27 27 # Energy binning parameters
... ...
src/ctlike/ctlike.par
... ... @@ -22,8 +22,8 @@ inmodel, f, a, &quot;$CTOOLS/share/models/crab.xml&quot;,,, &quot;Source model&quot;
22 22 expcube, f, a, "NONE",,, "Exposure cube file (only needed for stacked analysis)"
23 23 psfcube, f, a, "NONE",,, "PSF cube file (only needed for stacked analysis)"
24 24 bkgcube, f, a, "NONE",,, "Background cube file (only needed for stacked analysis)"
25   -caldb, s, a, "dummy",,, "Calibration database"
26   -irf, s, a, "cta_dummy_irf",,, "Instrument response function"
  25 +caldb, s, a, "prod2",,, "Calibration database"
  26 +irf, s, a, "South_50h",,, "Instrument response function"
27 27 outmodel, f, a, "crab_results.xml",,, "Source model output file"
28 28 stat, s, h, "POISSON",,, "Optimization statistics"
29 29 edisp, b, h, no,,, "Apply energy dispersion?"
... ...
src/ctmodel/ctmodel.par
... ... @@ -28,8 +28,8 @@ inobs, f, a, &quot;NONE&quot;,,, &quot;Event list, counts cube or observation definition fil
28 28 expcube, f, a, "NONE",,, "Exposure cube file (only needed for stacked analysis)"
29 29 psfcube, f, a, "NONE",,, "PSF cube file (only needed for stacked analysis)"
30 30 bkgcube, f, a, "NONE",,, "Background cube file (only needed for stacked analysis)"
31   -caldb, s, a, "dummy",,, "Calibration database"
32   -irf, s, a, "cta_dummy_irf",,, "Instrument response function"
  31 +caldb, s, a, "prod2",,, "Calibration database"
  32 +irf, s, a, "South_50h",,, "Instrument response function"
33 33 ra, r, a, 83.63,0,360, "RA of pointing (degrees)"
34 34 dec, r, a, 22.01,-90,90, "Dec of pointing (degrees)"
35 35 rad, r, a, 5.0,0,180, "Radius of FOV (degrees)"
... ...
src/ctobssim/ctobssim.cpp
... ... @@ -965,7 +965,7 @@ void ctobssim::simulate_source(GCTAObservation* obs, const GModels&amp; models,
965 965 *
966 966 * @param[in] model Sky model.
967 967 * @param[in] emin Minimum energy.
968   - * @param[in] emin Maximum energy.
  968 + * @param[in] emax Maximum energy.
969 969 * @param[in] centre Centre of region for photon rate determination.
970 970 * @param[in] radius Radius of region for photon rate determination.
971 971 * @return Model flux (photons/cm2/sec).
... ...
src/ctobssim/ctobssim.par
... ... @@ -24,8 +24,8 @@ prefix, s, h, &quot;sim_events_&quot;,,, &quot;Prefix for event lists in observation definit
24 24 #
25 25 # Observation parameters
26 26 #=======================
27   -caldb, s, a, "dummy",,, "Calibration database"
28   -irf, s, a, "cta_dummy_irf",,, "Instrument response function"
  27 +caldb, s, a, "prod2",,, "Calibration database"
  28 +irf, s, a, "South_50h",,, "Instrument response function"
29 29 #
30 30 # Simulation parameters
31 31 #======================
... ...
src/ctpsfcube/ctpsfcube.par
... ... @@ -20,8 +20,8 @@
20 20 inobs, f, a, "NONE",,, "Event list or observation definition file"
21 21 incube, f, a, "NONE",,, "Counts cube for psf cube definition"
22 22 outcube, f, a, "psfcube.fits",,, "Output psf cube file"
23   -caldb, s, a, "dummy",,, "Calibration database"
24   -irf, s, a, "cta_dummy_irf",,, "Instrument response function"
  23 +caldb, s, a, "prod2",,, "Calibration database"
  24 +irf, s, a, "South_50h",,, "Instrument response function"
25 25 edisp, b, h, no,,, "Apply energy dispersion?"
26 26 #
27 27 # Energy binning parameters
... ...
src/cttsmap/cttsmap.par
... ... @@ -23,8 +23,8 @@ srcname, s, a, &quot;Crab&quot;,,, &quot;Test source&quot;
23 23 expcube, f, a, "NONE",,, "Exposure cube file (only needed for stacked analysis)"
24 24 psfcube, f, a, "NONE",,, "PSF cube file (only needed for stacked analysis)"
25 25 bkgcube, f, a, "NONE",,, "Background cube file (only needed for stacked analysis)"
26   -caldb, s, a, "dummy",,, "Calibration database"
27   -irf, s, a, "cta_dummy_irf",,, "Instrument response function"
  26 +caldb, s, a, "prod2",,, "Calibration database"
  27 +irf, s, a, "South_50h",,, "Instrument response function"
28 28 outmap, f, a, "tsmap.fits",,, "Output Test Statistic map"
29 29  
30 30 #
... ...
src/ctulimit/ctulimit.par
... ... @@ -23,8 +23,8 @@ srcname, s, a, &quot;Crab&quot;,,, &quot;Source of interest&quot;
23 23 expcube, f, a, "NONE",,, "Exposure cube file (only needed for stacked analysis)"
24 24 psfcube, f, a, "NONE",,, "PSF cube file (only needed for stacked analysis)"
25 25 bkgcube, f, a, "NONE",,, "Background cube file (only needed for stacked analysis)"
26   -caldb, s, a, "dummy",,, "Calibration database"
27   -irf, s, a, "cta_dummy_irf",,, "Instrument response function"
  26 +caldb, s, a, "prod2",,, "Calibration database"
  27 +irf, s, a, "South_50h",,, "Instrument response function"
28 28  
29 29 #
30 30 # Upper limit calculation parameters
... ...
test/test_cscripts.sh.in
... ... @@ -136,13 +136,14 @@ $ECHO &quot; ok&quot;
136 136 $ECHO -n "Test cstsdist: "
137 137 chmod +x @abs_top_srcdir@/scripts/cstsdist.py
138 138 @abs_top_srcdir@/scripts/cstsdist.py \
  139 + inmodel="data/crab.xml" \
  140 + srcname="Crab" \
139 141 outfile="ts.dat" \
140 142 ntrials="1" \
141 143 caldb="irf" \
142 144 irf="cta_dummy_irf" \
143   - type="point" \
144   - offset="0.0" \
145   - bkg="data/bkg_dummy.txt" \
  145 + ra=83.63 \
  146 + dec=22.01 \
146 147 emin=0.1 \
147 148 emax=100.0 \
148 149 enumbins=0 \
... ... @@ -160,6 +161,7 @@ else
160 161 fi
161 162 $ECHO " ok"
162 163  
  164 +
163 165 #
164 166 # Test csresmap
165 167 # =============
... ... @@ -189,6 +191,7 @@ else
189 191 fi
190 192 $ECHO " ok"
191 193  
  194 +
192 195 #
193 196 # Test csspec (unbinned)
194 197 # =====================
... ... @@ -215,6 +218,7 @@ else
215 218 fi
216 219 $ECHO " ok"
217 220  
  221 +
218 222 #
219 223 # Test csspec (binned)
220 224 # ====================
... ... @@ -249,6 +253,7 @@ else
249 253 fi
250 254 $ECHO " ok"
251 255  
  256 +
252 257 #
253 258 # Test cslightcrv (unbinned)
254 259 # ==========================
... ... @@ -257,14 +262,16 @@ chmod +x @abs_top_srcdir@/scripts/cslightcrv.py
257 262 @abs_top_srcdir@/scripts/cslightcrv.py \
258 263 inobs="data/crab_events.fits" \
259 264 inmodel="data/crab.xml" \
  265 + srcname="Crab" \
260 266 caldb="irf" \
261 267 irf="cta_dummy_irf" \
262   - tbins=3 \
  268 + tbinalg="LIN" \
263 269 tmin=51544.5 \
264 270 tmax=51544.53 \
265   - srcname="Crab" \
266   - tbinalg="LIN" \
267   - binned=no \
  271 + tbins=3 \
  272 + enumbins=0 \
  273 + emin=0.1 \
  274 + emax=100.0 \
268 275 outfile="lightcurve.fits" > cslightcrv.log
269 276 $ECHO -n "."
270 277 if [ -s "lightcurve.fits" ]
... ... @@ -276,6 +283,7 @@ else
276 283 fi
277 284 $ECHO " ok"
278 285  
  286 +
279 287 #
280 288 # Test cslightcrv (binned)
281 289 # ========================
... ... @@ -284,21 +292,20 @@ chmod +x @abs_top_srcdir@/scripts/cslightcrv.py
284 292 @abs_top_srcdir@/scripts/cslightcrv.py \
285 293 inobs="data/crab_events.fits" \
286 294 inmodel="data/crab.xml" \
  295 + srcname="Crab" \
287 296 caldb="irf" \
288 297 irf="cta_dummy_irf" \
289 298 tbinalg="GTI" \
290   - srcname="Crab" \
  299 + enumbins=2 \
291 300 emin=0.1 \
292 301 emax=100.0 \
293   - binned=yes \
294   - nxpix=10 \
295   - nypix=10 \
296   - binsz=0.1 \
297   - nebins=2 \
298 302 coordsys="CEL" \
  303 + proj="CAR" \
299 304 xref=83.63 \
300 305 yref=22.01 \
301   - proj="CAR" \
  306 + nxpix=10 \
  307 + nypix=10 \
  308 + binsz=0.1 \
302 309 outfile="lightcurve.fits" > cslightcrv.log
303 310 $ECHO -n "."
304 311 if [ -s "lightcurve.fits" ]
... ...
testall.sh
... ... @@ -33,7 +33,6 @@ cd examples
33 33  
34 34 # Create local environment
35 35 rm -rf ctools
36   -#mkdir -p ctools/share
37 36 mkdir -p ctools/share/caldb
38 37 ln -s $base/caldb ctools/share/caldb/cta
39 38 ln -s $base/models ctools/share/models
... ... @@ -52,11 +51,11 @@ export CTOOLS=$PWD/ctools
52 51  
53 52 # Run makers
54 53 ./make_survey.py
55   -./make_ts_distributions.py 2 2
  54 +./make_ts_distributions.py -n 2 -e 0 -d 1800
56 55 #./make_pull_at_sensitivity_limit.py
57 56  
58 57 # Remove local environment
59   -rm -rf gammalib
  58 +rm -rf ctools
60 59  
61 60 # Step back to base directory
62 61 cd $base
... ...