Commit 760fe293cca7b8a73e125e2886efa53ae1737f3e

Authored by Jürgen Knödlseder
2 parents 1d60a87b c9e856b3

Merge branch '1555-science-verification' into integration

Makefile.am
@@ -106,6 +106,16 @@ valgrind: @@ -106,6 +106,16 @@ valgrind:
106 echo "valgrind not found in PATH."; \ 106 echo "valgrind not found in PATH."; \
107 fi 107 fi
108 108
  109 +# Add science verification rule
  110 +science-verification:
  111 + @if type test/science_verification.py >/dev/null 2>&1; then \
  112 + cd test; \
  113 + ./science_verification.py; \
  114 + cd ..; \
  115 + else \
  116 + echo "science_verification.py not found in test."; \
  117 + fi
  118 +
109 # Add Sphinx rule 119 # Add Sphinx rule
110 sphinx: 120 sphinx:
111 @if type sphinx-build >/dev/null 2>&1; then \ 121 @if type sphinx-build >/dev/null 2>&1; then \
doc/source/_themes/sphinx13/layout.html
@@ -78,6 +78,8 @@ @@ -78,6 +78,8 @@
78 <div class=banner_part> 78 <div class=banner_part>
79 <img src="{{ pathto('_static/logo.png', 1) }}" height="64" alt="SPHINX" /> 79 <img src="{{ pathto('_static/logo.png', 1) }}" height="64" alt="SPHINX" />
80 </div> 80 </div>
  81 + <div class=banner_part></div>
  82 + <div class=banner_part></div>
81 <div class=banner_part> 83 <div class=banner_part>
82 <span id="banner_text1">CTA</span><br/> 84 <span id="banner_text1">CTA</span><br/>
83 <span id="banner_text2">Cherenkov Telescope Array Science Analysis Software</span> 85 <span id="banner_text2">Cherenkov Telescope Array Science Analysis Software</span>
doc/source/download.rst
@@ -89,13 +89,27 @@ To clone the gammalib and ctools source codes, type @@ -89,13 +89,27 @@ To clone the gammalib and ctools source codes, type
89 $ git clone https://cta-git.irap.omp.eu/gammalib 89 $ git clone https://cta-git.irap.omp.eu/gammalib
90 $ git clone https://cta-git.irap.omp.eu/ctools 90 $ git clone https://cta-git.irap.omp.eu/ctools
91 91
92 -This will create directories named gammalib and ctools under the current working  
93 -directory that will contain the gammalib and ctools source code. Before you are able  
94 -to compile the code you need to generate the configuration file using the  
95 -``autogen.sh`` script. Also make sure that you're actually on the devel branch of the git  
96 -repository. GammaLib and ctools can be compiled using the following  
97 -command sequence (the code will be installed into the ``/usr/local/gamma``  
98 -directory): 92 +This will create directories named gammalib and ctools under the current
  93 +working directory that will contain the gammalib and ctools source code.
  94 +In case that the cloning does not work you may try adding
  95 +
  96 +.. code-block:: bash
  97 +
  98 + $ export GIT_SSL_NO_VERIFY=true
  99 +
  100 +or
  101 +
  102 +.. code-block:: bash
  103 +
  104 + $ git config --global http.sslverify "false"
  105 +
  106 +before retrieving the code.
  107 +Before you will be able to compile the code you need to generate the
  108 +configuration file using the ``autogen.sh`` script.
  109 +Also make sure that you're actually on the devel branch of the git
  110 +repository. GammaLib and ctools can be compiled and configured using
  111 +the following command sequence (the code will be installed into the
  112 +``/usr/local/gamma`` directory):
99 113
100 .. code-block:: bash 114 .. code-block:: bash
101 115
@@ -108,8 +122,7 @@ directory): @@ -108,8 +122,7 @@ directory):
108 $ sudo make install 122 $ sudo make install
109 $ export GAMMALIB=/usr/local/gamma 123 $ export GAMMALIB=/usr/local/gamma
110 $ source $GAMMALIB/bin/gammalib-init.sh 124 $ source $GAMMALIB/bin/gammalib-init.sh
111 - $ cd ..  
112 - $ cd ctools 125 + $ cd ../ctools
113 $ git checkout devel 126 $ git checkout devel
114 $ ./autogen.sh 127 $ ./autogen.sh
115 $ ./configure 128 $ ./configure
doc/source/issues.rst
@@ -5,22 +5,23 @@ Known issues @@ -5,22 +5,23 @@ Known issues
5 5
6 Below you will find a list of known issues. 6 Below you will find a list of known issues.
7 7
8 -- :ref:`Broken power law has unreliable errors <issues_bplaw>`  
9 -- :ref:`Errors become unreliable when fitting the pivot energy <issues_pivot>`  
10 -- :ref:`Binned analysis is biased when using coarse binning <issues_binned>` 8 +- :ref:`Broken power law has unreliable errors <issue_bplaw>`
  9 +- :ref:`Errors become unreliable when fitting the pivot energy <issue_pivot>`
  10 +- :ref:`Binned analysis is biased when using coarse binning <issue_binned>`
  11 +- :ref:`Shell model is biased when width is comparable to angular resolution <issue_shell>`
11 12
12 13
13 -.. _issues_bplaw: 14 +.. _issue_bplaw:
14 15
15 .. topic:: Broken power law has unreliable errors 16 .. topic:: Broken power law has unreliable errors
16 17
17 The broken power law spectral model has unreliable errors, specifically 18 The broken power law spectral model has unreliable errors, specifically
18 for the prefactor and the break value. Errors are in general too large, 19 for the prefactor and the break value. Errors are in general too large,
19 - and this is related to the fact that the law's gradient is discontinous 20 + and this is related to the fact that the law's gradient is discontinuous
20 in energy. There is not very much we can do about it, it's inherent in 21 in energy. There is not very much we can do about it, it's inherent in
21 the law. 22 the law.
22 23
23 -.. _issues_pivot: 24 +.. _issue_pivot:
24 25
25 .. topic:: Errors become unreliable when fitting the pivot energy 26 .. topic:: Errors become unreliable when fitting the pivot energy
26 27
@@ -34,7 +35,7 @@ Below you will find a list of known issues. @@ -34,7 +35,7 @@ Below you will find a list of known issues.
34 parameters of the model to assure non-degeneracy of the free 35 parameters of the model to assure non-degeneracy of the free
35 parameters. 36 parameters.
36 37
37 -.. _issues_binned: 38 +.. _issue_binned:
38 39
39 .. topic:: Binned analysis is biased when using coarse binning 40 .. topic:: Binned analysis is biased when using coarse binning
40 41
@@ -45,3 +46,14 @@ Below you will find a list of known issues. @@ -45,3 +46,14 @@ Below you will find a list of known issues.
45 per pixel for the spatial binning and 10 bins per decade for the 46 per pixel for the spatial binning and 10 bins per decade for the
46 spectral binning. If the binning is too coarse, the spectral parameters 47 spectral binning. If the binning is too coarse, the spectral parameters
47 that are fitted will be biased. 48 that are fitted will be biased.
  49 +
  50 +.. _issue_shell:
  51 +
  52 +.. topic:: Shell model is biased when width is comparable to angular resolution
  53 +
  54 + When the width of the shell model becomes comparable to or smaller
  55 + than the angular resolution, the shell width tends to be overestimated
  56 + while the shell radius tends to be underestimated.
  57 + The fitted shell width and radius should thus not be overinterpreted
  58 + when the width is close to the angular resolution of CTA.
  59 +
examples/show_pull_evolution.py 0 → 100755
  1 +#! /usr/bin/env python
  2 +# ==========================================================================
  3 +# This script displays the evolution of the pull distributions as function
  4 +# of the number of samples. The pull distributions are generated using the
  5 +# cspull script. The pull is defined by
  6 +#
  7 +# (fitted value - simulated value) / estimated error
  8 +#
  9 +# and the pull histogram allows to assess possible biases in the fit
  10 +# parameters and errors.
  11 +#
  12 +# Required 3rd party modules:
  13 +# - matplotlib
  14 +# - numpy
  15 +#
  16 +# Copyright (C) 2015 Juergen Knoedlseder
  17 +#
  18 +# This program is free software: you can redistribute it and/or modify
  19 +# it under the terms of the GNU General Public License as published by
  20 +# the Free Software Foundation, either version 3 of the License, or
  21 +# (at your option) any later version.
  22 +#
  23 +# This program is distributed in the hope that it will be useful,
  24 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
  25 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  26 +# GNU General Public License for more details.
  27 +#
  28 +# You should have received a copy of the GNU General Public License
  29 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
  30 +#
  31 +# ==========================================================================
  32 +import matplotlib.pyplot as plt
  33 +import numpy as np
  34 +import sys
  35 +import csv
  36 +
  37 +
  38 +# ====================== #
  39 +# Read pull distribution #
  40 +# ====================== #
  41 +def read_pull(filename, parname):
  42 + """
  43 + Read pull distribution.
  44 + """
  45 + # Initialise list
  46 + values = []
  47 +
  48 + # Open reader
  49 + reader = csv.reader(open(filename, 'r'), delimiter=',')
  50 +
  51 + # Read rows
  52 + first = True
  53 + index = -1
  54 + for row in reader:
  55 +
  56 + # Get column index if first row
  57 + if first:
  58 + try:
  59 + index = row.index(parname)
  60 + except:
  61 + sys.stdout.write('ERROR: Parameter "'+parname+'" not found in list:\n')
  62 + for p in row:
  63 + sys.stdout.write(' "'+p+'"\n')
  64 + raise NameError(parname)
  65 +
  66 + # Handle data rows
  67 + else:
  68 + values.append(float(row[index]))
  69 +
  70 + # Flag that first row has been passed
  71 + first = False
  72 +
  73 + # Create numpy array
  74 + a = np.array(values)
  75 +
  76 + # Return array
  77 + return a
  78 +
  79 +
  80 +# ======================== #
  81 +# Main routine entry point #
  82 +# ======================== #
  83 +if __name__ == '__main__':
  84 + """
  85 + Display pull evolution generated by cspull using matplotlib.
  86 + """
  87 + # Print usage information
  88 + usage = "Usage: show_pull_evolution filename parname"
  89 + if len(sys.argv) < 3:
  90 + sys.stdout.write(usage+"\n")
  91 + sys.exit()
  92 +
  93 + # Extract parameters
  94 + filename = sys.argv[1]
  95 + parname = sys.argv[2]
  96 +
  97 + # Read values from CSV file
  98 + values = read_pull(filename, parname)
  99 +
  100 + # Compute mean and rms
  101 + nsamples = len(values)
  102 + samples = []
  103 + mean = []
  104 + rms = []
  105 + for i in range(1,nsamples):
  106 + samples.append(float(i+1))
  107 + mean.append(np.mean(values[0:i]))
  108 + rms.append(np.std(values[0:i]))
  109 +
  110 + # Plot mean and rms evolution
  111 + plt.semilogx(samples, mean, 'r-', label="Mean")
  112 + plt.semilogx(samples, rms, 'b-', label="Std. deviation")
  113 +
  114 + # Set plot
  115 + plt.xlabel("Samples")
  116 + plt.ylabel("Value")
  117 + plt.title(parname)
  118 + plt.grid(True)
  119 +
  120 + # Set legend
  121 + plt.legend(loc="upper left")
  122 +
  123 + # Show histogram
  124 + plt.show()
test/data/sciver/cena_lobes_parkes.fits 0 → 100644
No preview for this file type
test/data/sciver/crab_edisk.xml 0 → 100644
  1 +<?xml version="1.0" standalone="no"?>
  2 +<source_library title="source library">
  3 + <source name="Crab" type="ExtendedSource">
  4 + <spectrum type="PowerLaw">
  5 + <parameter name="Prefactor" scale="1e-16" value="5.7" min="1e-07" max="1000.0" free="1"/>
  6 + <parameter name="Index" scale="-1" value="2.48" min="0.0" max="+5.0" free="1"/>
  7 + <parameter name="Scale" scale="1e6" value="0.3" min="0.01" max="1000.0" free="0"/>
  8 + </spectrum>
  9 + <spatialModel type="EllipticalDisk">
  10 + <parameter name="RA" scale="1.0" value="83.6331" min="-360" max="360" free="1"/>
  11 + <parameter name="DEC" scale="1.0" value="22.0145" min="-90" max="90" free="1"/>
  12 + <parameter name="PA" scale="1.0" value="45.0" min="-360" max="360" free="1"/>
  13 + <parameter name="MinorRadius" scale="1.0" value="0.2" min="0.001" max="10" free="1"/>
  14 + <parameter name="MajorRadius" scale="1.0" value="0.4" min="0.001" max="10" free="1"/>
  15 + </spatialModel>
  16 + </source>
  17 + <source name="Background" type="CTAIrfBackground" instrument="CTA">
  18 + <spectrum type="PowerLaw">
  19 + <parameter name="Prefactor" scale="1.0" value="1.0" min="1e-3" max="1e3" free="1"/>
  20 + <parameter name="Index" scale="1.0" value="0.0" min="-5.0" max="+5.0" free="1"/>
  21 + <parameter name="Scale" scale="1e6" value="1.0" min="0.01" max="1000.0" free="0"/>
  22 + </spectrum>
  23 + </source>
  24 +</source_library>
test/data/sciver/crab_egauss.xml 0 → 100644
  1 +<?xml version="1.0" standalone="no"?>
  2 +<source_library title="source library">
  3 + <source name="Crab" type="ExtendedSource">
  4 + <spectrum type="PowerLaw">
  5 + <parameter name="Prefactor" scale="1e-16" value="5.7" min="1e-07" max="1000.0" free="1"/>
  6 + <parameter name="Index" scale="-1" value="2.48" min="0.0" max="+5.0" free="1"/>
  7 + <parameter name="Scale" scale="1e6" value="0.3" min="0.01" max="1000.0" free="0"/>
  8 + </spectrum>
  9 + <spatialModel type="EllipticalGauss">
  10 + <parameter name="RA" scale="1.0" value="83.6331" min="-360" max="360" free="1"/>
  11 + <parameter name="DEC" scale="1.0" value="22.0145" min="-90" max="90" free="1"/>
  12 + <parameter name="PA" scale="1.0" value="45.0" min="-360" max="360" free="1"/>
  13 + <parameter name="MinorRadius" scale="1.0" value="0.2" min="0.001" max="10" free="1"/>
  14 + <parameter name="MajorRadius" scale="1.0" value="0.4" min="0.001" max="10" free="1"/>
  15 + </spatialModel>
  16 + </source>
  17 + <source name="Background" type="CTAIrfBackground" instrument="CTA">
  18 + <spectrum type="PowerLaw">
  19 + <parameter name="Prefactor" scale="1.0" value="1.0" min="1e-3" max="1e3" free="1"/>
  20 + <parameter name="Index" scale="1.0" value="0.0" min="-5.0" max="+5.0" free="1"/>
  21 + <parameter name="Scale" scale="1e6" value="1.0" min="0.01" max="1000.0" free="0"/>
  22 + </spectrum>
  23 + </source>
  24 +</source_library>
test/data/sciver/crab_eplaw.xml 0 → 100644
  1 +<?xml version="1.0" standalone="no"?>
  2 +<source_library title="source library">
  3 + <source name="Crab" type="PointSource">
  4 + <spectrum type="ExpCutoff">
  5 + <parameter name="Prefactor" scale="1e-15" value="2.0" min="1e-07" max="1000.0" free="1"/>
  6 + <parameter name="Index" scale="-1" value="2.1" min="0.0" max="+5.0" free="1"/>
  7 + <parameter name="Cutoff" scale="1e6" value="1.0" min="0.01" max="1000.0" free="1"/>
  8 + <parameter name="Scale" scale="1e6" value="0.3" min="0.01" max="1000.0" free="0"/>
  9 + </spectrum>
  10 + <spatialModel type="SkyDirFunction">
  11 + <parameter name="RA" scale="1.0" value="83.6331" min="-360" max="360" free="0"/>
  12 + <parameter name="DEC" scale="1.0" value="22.0145" min="-90" max="90" free="0"/>
  13 + </spatialModel>
  14 + </source>
  15 + <source name="Background" type="CTAIrfBackground" instrument="CTA">
  16 + <spectrum type="PowerLaw">
  17 + <parameter name="Prefactor" scale="1.0" value="1.0" min="1e-3" max="1e3" 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"/>
  20 + </spectrum>
  21 + </source>
  22 +</source_library>
test/data/sciver/crab_filefct.xml 0 → 100644
  1 +<?xml version="1.0" standalone="no"?>
  2 +<source_library title="source library">
  3 + <source name="Crab" type="PointSource">
  4 + <spectrum type="FileFunction" file="data/sciver/filefunction.txt">
  5 + <parameter scale="1.0" name="Normalization" min="0.0" max="1000.0" value="1.0" free="1"/>
  6 + </spectrum>
  7 + <spatialModel type="SkyDirFunction">
  8 + <parameter name="RA" scale="1.0" value="83.6331" min="-360" max="360" free="0"/>
  9 + <parameter name="DEC" scale="1.0" value="22.0145" min="-90" max="90" free="0"/>
  10 + </spatialModel>
  11 + </source>
  12 + <source name="Background" type="CTAIrfBackground" instrument="CTA">
  13 + <spectrum type="PowerLaw">
  14 + <parameter name="Prefactor" scale="1.0" value="1.0" min="1e-3" max="1e3" free="1"/>
  15 + <parameter name="Index" scale="1.0" value="0.0" min="-5.0" max="+5.0" free="1"/>
  16 + <parameter name="Scale" scale="1e6" value="1.0" min="0.01" max="1000.0" free="0"/>
  17 + </spectrum>
  18 + </source>
  19 +</source_library>
test/data/sciver/crab_gauss.xml 0 → 100644
  1 +<?xml version="1.0" standalone="no"?>
  2 +<source_library title="source library">
  3 + <source name="Crab" type="PointSource">
  4 + <spectrum type="Gaussian">
  5 + <parameter name="Normalization" scale="1e-10" value="1.0" min="1e-07" max="1000.0" free="1"/>
  6 + <parameter name="Mean" scale="1e6" value="5.0" min="0.01" max="100.0" free="1"/>
  7 + <parameter name="Sigma" scale="1e6" value="1.0" min="0.01" max="100.0" free="1"/>
  8 + </spectrum>
  9 + <spatialModel type="SkyDirFunction">
  10 + <parameter name="RA" scale="1.0" value="83.6331" min="-360" max="360" free="0"/>
  11 + <parameter name="DEC" scale="1.0" value="22.0145" min="-90" max="90" free="0"/>
  12 + </spatialModel>
  13 + </source>
  14 + <source name="Background" type="CTAIrfBackground" instrument="CTA">
  15 + <spectrum type="PowerLaw">
  16 + <parameter name="Prefactor" scale="1.0" value="1.0" min="1e-3" max="1e3" 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"/>
  19 + </spectrum>
  20 + </source>
  21 +</source_library>
test/data/sciver/crab_logparabola.xml 0 → 100644
  1 +<?xml version="1.0" standalone="no"?>
  2 +<source_library title="source library">
  3 + <source name="Crab" type="PointSource">
  4 + <spectrum type="LogParabola">
  5 + <parameter name="Prefactor" scale="1e-16" value="5.878" min="1e-07" max="1000.0" free="1"/>
  6 + <parameter name="Index" scale="-1" value="2.325" min="0.0" max="+5.0" free="1"/>
  7 + <parameter name="Curvature" scale="-1" value="0.074" min="0.01" max="1000.0" free="1"/>
  8 + <parameter name="Scale" scale="1e6" value="1.0" min="0.01" max="1000.0" free="0"/>
  9 + </spectrum>
  10 + <spatialModel type="SkyDirFunction">
  11 + <parameter name="RA" scale="1.0" value="83.6331" min="-360" max="360" free="0"/>
  12 + <parameter name="DEC" scale="1.0" value="22.0145" min="-90" max="90" free="0"/>
  13 + </spatialModel>
  14 + </source>
  15 + <source name="Background" type="CTAIrfBackground" instrument="CTA">
  16 + <spectrum type="PowerLaw">
  17 + <parameter name="Prefactor" scale="1.0" value="1.0" min="1e-3" max="1e3" 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"/>
  20 + </spectrum>
  21 + </source>
  22 +</source_library>
test/data/sciver/crab_map.xml 0 → 100644
  1 +<?xml version="1.0" standalone="no"?>
  2 +<source_library title="source library">
  3 + <source name="Crab" type="DiffuseSource">
  4 + <spectrum type="PowerLaw">
  5 + <parameter name="Prefactor" scale="1e-16" value="5.7" min="1e-07" max="1000.0" free="1"/>
  6 + <parameter name="Index" scale="-1" value="2.48" min="0.0" max="+5.0" free="1"/>
  7 + <parameter name="Scale" scale="1e6" value="0.3" min="0.01" max="1000.0" free="0"/>
  8 + </spectrum>
  9 + <spatialModel type="SpatialMap" file="data/sciver/cena_lobes_parkes.fits">
  10 + <parameter scale="1" name="Prefactor" min="0.001" max="1000.0" value="1" free="0"/>
  11 + </spatialModel>
  12 + </source>
  13 + <source name="Background" type="CTAIrfBackground" instrument="CTA">
  14 + <spectrum type="PowerLaw">
  15 + <parameter name="Prefactor" scale="1.0" value="1.0" min="1e-3" max="1e3" free="1"/>
  16 + <parameter name="Index" scale="1.0" value="0.0" min="-5.0" max="+5.0" free="1"/>
  17 + <parameter name="Scale" scale="1e6" value="1.0" min="0.01" max="1000.0" free="0"/>
  18 + </spectrum>
  19 + </source>
  20 +</source_library>
test/data/sciver/crab_nodes.xml 0 → 100644
  1 +<?xml version="1.0" standalone="no"?>
  2 +<source_library title="source library">
  3 + <source name="Crab" type="PointSource">
  4 + <spectrum type="NodeFunction">
  5 + <node>
  6 + <parameter scale="1.0e5" name="Energy" min="0.1" max="1.0e20" value="1.0" free="0"/>
  7 + <parameter scale="1e-15" name="Intensity" min="1e-07" max="1000.0" value="2.0" free="1"/>
  8 + </node>
  9 + <node>
  10 + <parameter scale="1.0e6" name="Energy" min="0.1" max="1.0e20" value="1.0" free="0"/>
  11 + <parameter scale="1e-17" name="Intensity" min="1e-07" max="1000.0" value="4.0" free="1"/>
  12 + </node>
  13 + <node>
  14 + <parameter scale="1.0e7" name="Energy" min="0.1" max="1.0e20" value="1.0" free="0"/>
  15 + <parameter scale="1e-19" name="Intensity" min="1e-07" max="1000.0" value="2.0" free="1"/>
  16 + </node>
  17 + <node>
  18 + <parameter scale="1.0e8" name="Energy" min="0.1" max="1.0e20" value="1.0" free="0"/>
  19 + <parameter scale="1e-22" name="Intensity" min="1e-07" max="1000.0" value="8.0" free="1"/>
  20 + </node>
  21 + </spectrum>
  22 + <spatialModel type="SkyDirFunction">
  23 + <parameter name="RA" scale="1.0" value="83.6331" min="-360" max="360" free="0"/>
  24 + <parameter name="DEC" scale="1.0" value="22.0145" min="-90" max="90" free="0"/>
  25 + </spatialModel>
  26 + </source>
  27 + <source name="Background" type="CTAIrfBackground" instrument="CTA">
  28 + <spectrum type="PowerLaw">
  29 + <parameter name="Prefactor" scale="1.0" value="1.0" min="1e-3" max="1e3" free="1"/>
  30 + <parameter name="Index" scale="1.0" value="0.0" min="-5.0" max="+5.0" free="1"/>
  31 + <parameter name="Scale" scale="1e6" value="1.0" min="0.01" max="1000.0" free="0"/>
  32 + </spectrum>
  33 + </source>
  34 +</source_library>
test/data/sciver/crab_plaw.xml 0 → 100644
  1 +<?xml version="1.0" standalone="no"?>
  2 +<source_library title="source library">
  3 + <source name="Crab" type="PointSource">
  4 + <spectrum type="PowerLaw">
  5 + <parameter name="Prefactor" scale="1e-16" value="5.7" min="1e-07" max="1000.0" free="1"/>
  6 + <parameter name="Index" scale="-1" value="2.48" min="0.0" max="+5.0" free="1"/>
  7 + <parameter name="Scale" scale="1e6" value="0.3" min="0.01" max="1000.0" free="0"/>
  8 + </spectrum>
  9 + <spatialModel type="SkyDirFunction">
  10 + <parameter name="RA" scale="1.0" value="83.6331" min="-360" max="360" free="0"/>
  11 + <parameter name="DEC" scale="1.0" value="22.0145" min="-90" max="90" free="0"/>
  12 + </spatialModel>
  13 + </source>
  14 + <source name="Background" type="CTAIrfBackground" instrument="CTA">
  15 + <spectrum type="PowerLaw">
  16 + <parameter name="Prefactor" scale="1.0" value="1.0" min="1e-3" max="1e3" 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"/>
  19 + </spectrum>
  20 + </source>
  21 +</source_library>
test/data/sciver/crab_plaw2.xml 0 → 100644
  1 +<?xml version="1.0" standalone="no"?>
  2 +<source_library title="source library">
  3 + <source name="Crab" type="PointSource">
  4 + <spectrum type="PowerLaw2">
  5 + <parameter name="Integral" scale="1e-5" value="1.617" min="1e-07" max="1000.0" free="1"/>
  6 + <parameter name="Index" scale="-1.0" value="2.48" min="-5.0" max="+5.0" free="1"/>
  7 + <parameter name="LowerLimit" scale="1.0" value="100.0" min="10.0" max="1000000.0" free="0"/>
  8 + <parameter name="UpperLimit" scale="1.0" value="500000.0" min="10.0" max="1000000.0" free="0"/>
  9 + </spectrum>
  10 + <spatialModel type="SkyDirFunction">
  11 + <parameter name="RA" scale="1.0" value="83.6331" min="-360" max="360" free="0"/>
  12 + <parameter name="DEC" scale="1.0" value="22.0145" min="-90" max="90" free="0"/>
  13 + </spatialModel>
  14 + </source>
  15 + <source name="Background" type="CTAIrfBackground" instrument="CTA">
  16 + <spectrum type="PowerLaw">
  17 + <parameter name="Prefactor" scale="1.0" value="1.0" min="1e-3" max="1e3" 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"/>
  20 + </spectrum>
  21 + </source>
  22 +</source_library>
test/data/sciver/crab_ptsrc.xml 0 → 100644
  1 +<?xml version="1.0" standalone="no"?>
  2 +<source_library title="source library">
  3 + <source name="Crab" type="PointSource">
  4 + <spectrum type="PowerLaw">
  5 + <parameter name="Prefactor" scale="1e-16" value="5.7" min="1e-07" max="1000.0" free="1"/>
  6 + <parameter name="Index" scale="-1" value="2.48" min="0.0" max="+5.0" free="1"/>
  7 + <parameter name="Scale" scale="1e6" value="0.3" min="0.01" max="1000.0" free="0"/>
  8 + </spectrum>
  9 + <spatialModel type="SkyDirFunction">
  10 + <parameter name="RA" scale="1.0" value="83.6331" min="-360" max="360" free="1"/>
  11 + <parameter name="DEC" scale="1.0" value="22.0145" min="-90" max="90" free="1"/>
  12 + </spatialModel>
  13 + </source>
  14 + <source name="Background" type="CTAIrfBackground" instrument="CTA">
  15 + <spectrum type="PowerLaw">
  16 + <parameter name="Prefactor" scale="1.0" value="1.0" min="1e-3" max="1e3" 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"/>
  19 + </spectrum>
  20 + </source>
  21 +</source_library>
test/data/sciver/crab_rdisk.xml 0 → 100644
  1 +<?xml version="1.0" standalone="no"?>
  2 +<source_library title="source library">
  3 + <source name="Crab" type="ExtendedSource">
  4 + <spectrum type="PowerLaw">
  5 + <parameter name="Prefactor" scale="1e-16" value="5.7" min="1e-07" max="1000.0" free="1"/>
  6 + <parameter name="Index" scale="-1" value="2.48" min="0.0" max="+5.0" free="1"/>
  7 + <parameter name="Scale" scale="1e6" value="0.3" min="0.01" max="1000.0" free="0"/>
  8 + </spectrum>
  9 + <spatialModel type="DiskFunction">
  10 + <parameter name="RA" scale="1.0" value="83.6331" min="-360" max="360" free="1"/>
  11 + <parameter name="DEC" scale="1.0" value="22.0145" min="-90" max="90" free="1"/>
  12 + <parameter name="Radius" scale="1.0" value="0.2" min="0.01" max="10" free="1"/>
  13 + </spatialModel>
  14 + </source>
  15 + <source name="Background" type="CTAIrfBackground" instrument="CTA">
  16 + <spectrum type="PowerLaw">
  17 + <parameter name="Prefactor" scale="1.0" value="1.0" min="1e-3" max="1e3" 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"/>
  20 + </spectrum>
  21 + </source>
  22 +</source_library>
test/data/sciver/crab_rgauss.xml 0 → 100644
  1 +<?xml version="1.0" standalone="no"?>
  2 +<source_library title="source library">
  3 + <source name="Crab" type="ExtendedSource">
  4 + <spectrum type="PowerLaw">
  5 + <parameter name="Prefactor" scale="1e-16" value="5.7" min="1e-07" max="1000.0" free="1"/>
  6 + <parameter name="Index" scale="-1" value="2.48" min="0.0" max="+5.0" free="1"/>
  7 + <parameter name="Scale" scale="1e6" value="0.3" min="0.01" max="1000.0" free="0"/>
  8 + </spectrum>
  9 + <spatialModel type="GaussFunction">
  10 + <parameter name="RA" scale="1.0" value="83.6331" min="-360" max="360" free="1"/>
  11 + <parameter name="DEC" scale="1.0" value="22.0145" min="-90" max="90" free="1"/>
  12 + <parameter name="Sigma" scale="1.0" value="0.20" min="0.01" max="10" free="1"/>
  13 + </spatialModel>
  14 + </source>
  15 + <source name="Background" type="CTAIrfBackground" instrument="CTA">
  16 + <spectrum type="PowerLaw">
  17 + <parameter name="Prefactor" scale="1.0" value="1.0" min="1e-3" max="1e3" 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"/>
  20 + </spectrum>
  21 + </source>
  22 +</source_library>
test/data/sciver/crab_rshell.xml 0 → 100644
  1 +<?xml version="1.0" standalone="no"?>
  2 +<source_library title="source library">
  3 + <source name="Crab" type="ExtendedSource">
  4 + <spectrum type="PowerLaw">
  5 + <parameter name="Prefactor" scale="1e-16" value="5.7" min="1e-07" max="1000.0" free="1"/>
  6 + <parameter name="Index" scale="-1" value="2.48" min="0.0" max="+5.0" free="1"/>
  7 + <parameter name="Scale" scale="1e6" value="0.3" min="0.01" max="1000.0" free="0"/>
  8 + </spectrum>
  9 + <spatialModel type="ShellFunction">
  10 + <parameter name="RA" scale="1.0" value="83.6331" min="-360" max="360" free="1"/>
  11 + <parameter name="DEC" scale="1.0" value="22.0145" min="-90" max="90" free="1"/>
  12 + <parameter name="Radius" scale="1.0" value="0.30" min="0.01" max="10" free="1"/>
  13 + <parameter name="Width" scale="1.0" value="0.10" min="0.01" max="10" free="1"/>
  14 + </spatialModel>
  15 + </source>
  16 + <source name="Background" type="CTAIrfBackground" instrument="CTA">
  17 + <spectrum type="PowerLaw">
  18 + <parameter name="Prefactor" scale="1.0" value="1.0" min="1e-3" max="1e3" 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"/>
  21 + </spectrum>
  22 + </source>
  23 +</source_library>
test/data/sciver/crab_supeplaw.xml 0 → 100644
  1 +<?xml version="1.0" standalone="no"?>
  2 +<source_library title="source library">
  3 + <source name="Crab" type="PointSource">
  4 + <spectrum type="PLSuperExpCutoff">
  5 + <parameter name="Prefactor" scale="1e-16" value="5.7" min="1e-07" max="1000.0" free="1"/>
  6 + <parameter name="Index1" scale="-1" value="2.48" min="0.0" max="+5.0" free="1"/>
  7 + <parameter name="Cutoff" scale="1e6" value="1.0" min="0.01" max="1000.0" free="1"/>
  8 + <parameter name="Scale" scale="1e6" value="1.0" min="0.01" max="1000.0" free="0"/>
  9 + <parameter name="Index2" scale="1.0" value="1.5" min="0.1" max="5.0" free="1"/>
  10 + </spectrum>
  11 + <spatialModel type="SkyDirFunction">
  12 + <parameter name="RA" scale="1.0" value="83.6331" min="-360" max="360" free="0"/>
  13 + <parameter name="DEC" scale="1.0" value="22.0145" min="-90" max="90" free="0"/>
  14 + </spatialModel>
  15 + </source>
  16 + <source name="Background" type="CTAIrfBackground" instrument="CTA">
  17 + <spectrum type="PowerLaw">
  18 + <parameter name="Prefactor" scale="1.0" value="1.0" min="1e-3" max="1e3" 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"/>
  21 + </spectrum>
  22 + </source>
  23 +</source_library>
test/data/sciver/filefunction.txt 0 → 100644
  1 +100000.0 8.69231722336e-15
  2 +215443.469003 1.29559391832e-15
  3 +464158.883361 1.9310887512e-16
  4 +1000000.0 2.87829675045e-17
  5 +2154434.69003 4.2901146716e-18
  6 +4641588.83361 6.39443583867e-19
  7 +10000000.0 9.53093630938e-20
  8 +21544346.9003 1.42059048249e-20
  9 +46415888.3361 2.11739671051e-21
  10 +100000000.0 3.1559896289e-22
test/science_verification.py 0 → 100755
  1 +#! /usr/bin/env python
  2 +# ==========================================================================
  3 +# This script performs the ctools science verification. It creates and
  4 +# analyses the pull distributions for a variety of model in unbinned
  5 +# analysis mode. At the end the script produces a JUnit compliant
  6 +# science verification report.
  7 +#
  8 +# Usage:
  9 +# ./science_verification.py
  10 +#
  11 +# --------------------------------------------------------------------------
  12 +#
  13 +# Copyright (C) 2015 Juergen Knoedlseder
  14 +#
  15 +# This program is free software: you can redistribute it and/or modify
  16 +# it under the terms of the GNU General Public License as published by
  17 +# the Free Software Foundation, either version 3 of the License, or
  18 +# (at your option) any later version.
  19 +#
  20 +# This program is distributed in the hope that it will be useful,
  21 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
  22 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23 +# GNU General Public License for more details.
  24 +#
  25 +# You should have received a copy of the GNU General Public License
  26 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
  27 +#
  28 +# ==========================================================================
  29 +import gammalib
  30 +import ctools
  31 +import cscripts
  32 +import os
  33 +import csv
  34 +import math
  35 +import sys
  36 +
  37 +
  38 +# ========================== #
  39 +# Generate pull distribution #
  40 +# ========================== #
  41 +def generate_pull_distribution(model, trials=100, \
  42 + caldb="prod2", irf="South_50h", \
  43 + deadc=0.95, edisp=False, \
  44 + ra=83.63, dec=22.01, rad=5.0, \
  45 + emin=0.1, emax=100.0, enumbins=0, \
  46 + duration=1800.0, \
  47 + npix=200, binsz=0.02, \
  48 + coordsys="CEL", proj="TAN", \
  49 + pattern="single", offset=1.5, \
  50 + debug=False, chatter=2):
  51 + """
  52 + Generates pull distribution for a given model.
  53 +
  54 + Parameters:
  55 + model - Model XML filename (without .xml extension)
  56 + """
  57 + # Derive parameters
  58 + head, tail = os.path.split(model)
  59 + inmodel = model + ".xml"
  60 + outfile = "cspull_" + tail + ".dat"
  61 +
  62 + # Setup pull distribution generation
  63 + pull = cscripts.cspull()
  64 + pull["inobs"] = "NONE"
  65 + pull["inmodel"] = inmodel
  66 + pull["outfile"] = outfile
  67 + pull["caldb"] = caldb
  68 + pull["irf"] = irf
  69 + pull["edisp"] = edisp
  70 + pull["ra"] = ra
  71 + pull["dec"] = dec
  72 + pull["rad"] = rad
  73 + pull["emin"] = emin
  74 + pull["emax"] = emax
  75 + pull["tmin"] = 0.0
  76 + pull["tmax"] = duration
  77 + pull["enumbins"] = enumbins
  78 + pull["npix"] = npix
  79 + pull["binsz"] = binsz
  80 + pull["coordsys"] = coordsys
  81 + pull["proj"] = proj
  82 + pull["deadc"] = deadc
  83 + pull["rad"] = rad
  84 + pull["pattern"] = pattern
  85 + pull["offset"] = offset
  86 + pull["ntrials"] = trials
  87 + pull["debug"] = debug
  88 + pull["chatter"] = chatter
  89 +
  90 + # Generate pull distributions
  91 + pull.run()
  92 +
  93 + # Return
  94 + return outfile
  95 +
  96 +
  97 +# ========================= #
  98 +# Analyse pull distribution #
  99 +# ========================= #
  100 +def analyse_pull_distribution(filename):
  101 + """
  102 + Compute mean and standard deviation of pull distribution.
  103 +
  104 + Parameter:
  105 + filename - Pull distribution ASCII file to analyse.
  106 + """
  107 + # Initialise column names, means and standard deviations
  108 + colnames = []
  109 + means = []
  110 + stds = []
  111 +
  112 + # Open reader
  113 + reader = csv.reader(open(filename, 'r'), delimiter=',')
  114 +
  115 + # Read rows
  116 + first = True
  117 + index = -1
  118 + samples = 0.0
  119 + for row in reader:
  120 +
  121 + # Get column names if first row
  122 + if first:
  123 + for element in row:
  124 + colnames.append(element)
  125 + means.append(0.0)
  126 + stds.append(0.0)
  127 +
  128 + # Handle data rows
  129 + else:
  130 + for i, element in enumerate(row):
  131 + means[i] += float(element)
  132 + stds[i] += float(element)*float(element)
  133 + samples += 1.0
  134 +
  135 + # Flag that first row has been passed
  136 + first = False
  137 +
  138 + # Compute mean and standard deviations
  139 + for i in range(len(stds)):
  140 + std = math.sqrt(stds[i]/samples -
  141 + means[i]*means[i]/(samples*samples))
  142 + stds[i] = std
  143 + means[i] /= samples
  144 +
  145 + # Setup results
  146 + results = {}
  147 + for i in range(len(colnames)):
  148 + results[colnames[i]] = {'mean': means[i], 'std': stds[i]}
  149 +
  150 + # Return results
  151 + return results
  152 +
  153 +
  154 +# =================================== #
  155 +# Test class for science verification #
  156 +# =================================== #
  157 +class sciver(gammalib.GPythonTestSuite):
  158 + """
  159 + Test class for science verification
  160 + """
  161 + # Constructor
  162 + def __init__(self):
  163 + """
  164 + Constructor.
  165 + """
  166 + # Call base class constructor
  167 + gammalib.GPythonTestSuite.__init__(self)
  168 +
  169 + # Initialise results
  170 + self.results = None
  171 +
  172 + # Return
  173 + return
  174 +
  175 + # Set test functions
  176 + def set(self):
  177 + """
  178 + Set all test functions.
  179 + """
  180 + # Set test name
  181 + self.name("Science Verification")
  182 +
  183 + # Append spectral tests
  184 + self.append(self.spec_plaw, "Test power law model")
  185 + self.append(self.spec_plaw2, "Test power law 2 model")
  186 + self.append(self.spec_eplaw, "Test exponentially cut off power law model")
  187 + self.append(self.spec_supeplaw, "Test super exponentially cut off power law model")
  188 + self.append(self.spec_logparabola, "Test log parabola model")
  189 + self.append(self.spec_gauss, "Test Gaussian model")
  190 + self.append(self.spec_filefct, "Test file function model")
  191 + self.append(self.spec_nodes, "Test nodes model")
  192 +
  193 + # Append spatial tests
  194 + self.append(self.spec_ptsrc, "Test point source model")
  195 + self.append(self.spec_rdisk, "Test radial disk model")
  196 + self.append(self.spec_rgauss, "Test radial Gaussian model")
  197 + self.append(self.spec_rshell, "Test radial shell model")
  198 + self.append(self.spec_edisk, "Test elliptical disk model")
  199 + self.append(self.spec_egauss, "Test elliptical Gaussian model")
  200 + self.append(self.spec_map, "Test elliptical Gaussian model")
  201 +
  202 + # Return
  203 + return
  204 +
  205 + # Generate and analyse pull distributions
  206 + def pull(self, model, trials=100):
  207 + """
  208 + Generate and analyse pull distributions.
  209 + """
  210 + # Generate pull distribution
  211 + outfile = generate_pull_distribution(model, trials=trials)
  212 +
  213 + # Analyse pull distribution
  214 + self.results = analyse_pull_distribution(outfile)
  215 +
  216 + # Return
  217 + return
  218 +
  219 +
  220 + # Test parameter result
  221 + def test(self, name):
  222 + """
  223 + Test one parameter.
  224 + """
  225 + # Test mean
  226 + mean = self.results[name]["mean"]
  227 + valid = (mean >= -0.40) and (mean <= +0.40)
  228 + text = "Mean %.5f of %s should be within [-0.4,0.4] range" % (mean, name)
  229 + self.test_assert(valid, text)
  230 +
  231 + # Test standard deviation
  232 + std = self.results[name]["std"]
  233 + valid = (std >= 0.80) and (std <= 1.20)
  234 + text = "Standard deviation %.5f of %s should be within [0.8,1.2] range" % (std, name)
  235 + self.test_assert(valid, text)
  236 +
  237 + # Return
  238 + return
  239 +
  240 + # Test power law model
  241 + def spec_plaw(self):
  242 + """
  243 + Test power law model.
  244 + """
  245 + self.pull("data/sciver/crab_plaw")
  246 + self.test("Pull_Crab_Prefactor")
  247 + self.test("Pull_Crab_Index")
  248 + self.test("Pull_Background_Prefactor")
  249 + self.test("Pull_Background_Index")
  250 + return
  251 +
  252 + # Test power law 2 model
  253 + def spec_plaw2(self):
  254 + """
  255 + Test power law 2 model.
  256 + """
  257 + self.pull("data/sciver/crab_plaw2")
  258 + self.test("Pull_Crab_Integral")
  259 + self.test("Pull_Crab_Index")
  260 + self.test("Pull_Background_Prefactor")
  261 + self.test("Pull_Background_Index")
  262 + return
  263 +
  264 + # Test exponentially cut off power law model
  265 + def spec_eplaw(self):
  266 + """
  267 + Test exponentially cut off power law model.
  268 + """
  269 + self.pull("data/sciver/crab_eplaw")
  270 + self.test("Pull_Crab_Prefactor")
  271 + self.test("Pull_Crab_Index")
  272 + self.test("Pull_Crab_Cutoff")
  273 + self.test("Pull_Background_Prefactor")
  274 + self.test("Pull_Background_Index")
  275 + return
  276 +
  277 + # Test super exponentially cut off power law model
  278 + def spec_supeplaw(self):
  279 + """
  280 + Test super exponentially cut off power law model.
  281 + """
  282 + self.pull("data/sciver/crab_supeplaw")
  283 + self.test("Pull_Crab_Prefactor")
  284 + self.test("Pull_Crab_Index1")
  285 + self.test("Pull_Crab_Index2")
  286 + self.test("Pull_Crab_Cutoff")
  287 + self.test("Pull_Background_Prefactor")
  288 + self.test("Pull_Background_Index")
  289 + return
  290 +
  291 + # Test log parabola model
  292 + def spec_logparabola(self):
  293 + """
  294 + Test log parabola model.
  295 + """
  296 + self.pull("data/sciver/crab_logparabola")
  297 + self.test("Pull_Crab_Prefactor")
  298 + self.test("Pull_Crab_Index")
  299 + self.test("Pull_Crab_Curvature")
  300 + self.test("Pull_Background_Prefactor")
  301 + self.test("Pull_Background_Index")
  302 + return
  303 +
  304 + # Test Gaussian model
  305 + def spec_gauss(self):
  306 + """
  307 + Test Gaussian model.
  308 + """
  309 + self.pull("data/sciver/crab_gauss")
  310 + self.test("Pull_Crab_Normalization")
  311 + self.test("Pull_Crab_Mean")
  312 + self.test("Pull_Crab_Sigma")
  313 + self.test("Pull_Background_Prefactor")
  314 + self.test("Pull_Background_Index")
  315 + return
  316 +
  317 + # Test file function model
  318 + def spec_filefct(self):
  319 + """
  320 + Test file function model.
  321 + """
  322 + self.pull("data/sciver/crab_filefct")
  323 + self.test("Pull_Crab_Normalization")
  324 + self.test("Pull_Background_Prefactor")
  325 + self.test("Pull_Background_Index")
  326 + return
  327 +
  328 + # Test nodes model
  329 + def spec_nodes(self):
  330 + """
  331 + Test nodes model.
  332 + """
  333 + self.pull("data/sciver/crab_nodes")
  334 + self.test("Pull_Crab_Intensity0")
  335 + self.test("Pull_Crab_Intensity1")
  336 + self.test("Pull_Crab_Intensity2")
  337 + self.test("Pull_Crab_Intensity3")
  338 + self.test("Pull_Background_Prefactor")
  339 + self.test("Pull_Background_Index")
  340 + return
  341 +
  342 + # Test point source model
  343 + def spec_ptsrc(self):
  344 + """
  345 + Test point source model.
  346 + """
  347 + self.pull("data/sciver/crab_ptsrc")
  348 + self.test("Pull_Crab_Prefactor")
  349 + self.test("Pull_Crab_Index")
  350 + self.test("Pull_Crab_RA")
  351 + self.test("Pull_Crab_DEC")
  352 + self.test("Pull_Background_Prefactor")
  353 + self.test("Pull_Background_Index")
  354 + return
  355 +
  356 + # Test radial disk model
  357 + def spec_rdisk(self):
  358 + """
  359 + Test radial disk model.
  360 + """
  361 + self.pull("data/sciver/crab_rdisk")
  362 + self.test("Pull_Crab_Prefactor")
  363 + self.test("Pull_Crab_Index")
  364 + self.test("Pull_Crab_RA")
  365 + self.test("Pull_Crab_DEC")
  366 + self.test("Pull_Crab_Radius")
  367 + self.test("Pull_Background_Prefactor")
  368 + self.test("Pull_Background_Index")
  369 + return
  370 +
  371 + # Test radial Gaussian model
  372 + def spec_rgauss(self):
  373 + """
  374 + Test radial Gaussian model.
  375 + """
  376 + self.pull("data/sciver/crab_rgauss")
  377 + self.test("Pull_Crab_Prefactor")
  378 + self.test("Pull_Crab_Index")
  379 + self.test("Pull_Crab_RA")
  380 + self.test("Pull_Crab_DEC")
  381 + self.test("Pull_Crab_Sigma")
  382 + self.test("Pull_Background_Prefactor")
  383 + self.test("Pull_Background_Index")
  384 + return
  385 +
  386 + # Test radial shell model
  387 + def spec_rshell(self):
  388 + """
  389 + Test radial shell model.
  390 + """
  391 + self.pull("data/sciver/crab_rshell")
  392 + self.test("Pull_Crab_Prefactor")
  393 + self.test("Pull_Crab_Index")
  394 + self.test("Pull_Crab_RA")
  395 + self.test("Pull_Crab_DEC")
  396 + self.test("Pull_Crab_Radius")
  397 + self.test("Pull_Crab_Width")
  398 + self.test("Pull_Background_Prefactor")
  399 + self.test("Pull_Background_Index")
  400 + return
  401 +
  402 + # Test elliptical disk model
  403 + def spec_edisk(self):
  404 + """
  405 + Test elliptical disk model.
  406 + """
  407 + self.pull("data/sciver/crab_edisk")
  408 + self.test("Pull_Crab_Prefactor")
  409 + self.test("Pull_Crab_Index")
  410 + self.test("Pull_Crab_RA")
  411 + self.test("Pull_Crab_DEC")
  412 + self.test("Pull_Crab_PA")
  413 + self.test("Pull_Crab_MinorRadius")
  414 + self.test("Pull_Crab_MajorRadius")
  415 + self.test("Pull_Background_Prefactor")
  416 + self.test("Pull_Background_Index")
  417 + return
  418 +
  419 + # Test elliptical Gaussian model
  420 + def spec_egauss(self):
  421 + """
  422 + Test elliptical Gaussian model.
  423 + """
  424 + self.pull("data/sciver/crab_egauss")
  425 + self.test("Pull_Crab_Prefactor")
  426 + self.test("Pull_Crab_Index")
  427 + self.test("Pull_Crab_RA")
  428 + self.test("Pull_Crab_DEC")
  429 + self.test("Pull_Crab_PA")
  430 + self.test("Pull_Crab_MinorRadius")
  431 + self.test("Pull_Crab_MajorRadius")
  432 + self.test("Pull_Background_Prefactor")
  433 + self.test("Pull_Background_Index")
  434 + return
  435 +
  436 + # Test diffuse map model
  437 + def spec_map(self):
  438 + """
  439 + Test diffuse map model.
  440 + """
  441 + self.pull("data/sciver/crab_map")
  442 + self.test("Pull_Crab_Prefactor")
  443 + self.test("Pull_Crab_Index")
  444 + self.test("Pull_Background_Prefactor")
  445 + self.test("Pull_Background_Index")
  446 + return
  447 +
  448 +
  449 +# ======================== #
  450 +# Main routine entry point #
  451 +# ======================== #
  452 +if __name__ == '__main__':
  453 + """
  454 + Perform ctools science verification
  455 + """
  456 + # Allocate test suite container
  457 + suites = gammalib.GTestSuites("ctools science verification")
  458 +
  459 + # Allocate test suite and append it to the container
  460 + suite_sciver = sciver()
  461 +
  462 + # Setup test suit
  463 + suite_sciver.set()
  464 +
  465 + # Append test suite to container
  466 + suites.append(suite_sciver)
  467 +
  468 + # Set PFILES environment variable
  469 + try:
  470 + os.mkdir("pfiles")
  471 + except:
  472 + pass
  473 + os.system("cp -r ../src/*/*.par pfiles/")
  474 + os.environ['PFILES'] = "pfiles"
  475 +
  476 + # Run test suite
  477 + success = suites.run()
  478 +
  479 + # Save test results
  480 + suites.save("reports/sciver.xml")
  481 +
  482 + # Set return code
  483 + if success:
  484 + rc = 0
  485 + else:
  486 + rc = 1
  487 +
  488 + # Exit with return code
  489 + sys.exit(rc)