Commit 80cbc54c135c58e69b80256c630412060afeefa9

Authored by Jürgen Knödlseder
1 parent 27649b93

Support out of source builds

Showing 99 changed files with 1678 additions and 2182 deletions
ChangeLog
1   -2016-07-01 Juergen Knoedlseder <jurgen.knodlseder@irap.omp.eu>
  1 +2016-07-09 Juergen Knoedlseder <jurgen.knodlseder@irap.omp.eu>
2 2  
3 3 * Version 1.1.0 released
4 4 ========================
... ... @@ -24,6 +24,7 @@
24 24 Add documentation for IACT analysis (#1646)
25 25 ctselect allows usage of non-default events and GTI extensions (#1598)
26 26 Add csworkflow workflow manager script (#1508)
  27 + Support out of source builds (#1484)
27 28  
28 29  
29 30 2016-01-27 Juergen Knoedlseder <jurgen.knodlseder@irap.omp.eu>
... ...
Makefile.am
1   -## Process this file with automake to produce Makefile.in
  1 +#############################################################################
  2 +# Makefile for ctools package #
  3 +# ------------------------------------------------------------------------- #
  4 +# Copyright (C) 2016 Juergen Knoedlseder #
  5 +# ------------------------------------------------------------------------- #
  6 +# #
  7 +# This program is free software: you can redistribute it and/or modify #
  8 +# it under the terms of the GNU General Public License as published by #
  9 +# the Free Software Foundation, either version 3 of the License, or #
  10 +# (at your option) any later version. #
  11 +# #
  12 +# This program is distributed in the hope that it will be useful, #
  13 +# but WITHOUT ANY WARRANTY; without even the implied warranty of #
  14 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
  15 +# GNU General Public License for more details. #
  16 +# #
  17 +# You should have received a copy of the GNU General Public License #
  18 +# along with this program. If not, see <http://www.gnu.org/licenses/>. #
  19 +# #
  20 +#############################################################################
2 21  
3 22 # Include M4 macros
4 23 ACLOCAL_AMFLAGS = -I m4
... ... @@ -25,6 +44,10 @@ doc_DATA = \
25 44 README.md
26 45 docdir = ${datadir}/doc/${PACKAGE}
27 46  
  47 +# Extra files to be distributed in the tar file
  48 +EXTRA_DIST = README.md \
  49 + doc/Doxyfile doc/source
  50 +
28 51 #install-data-local: $(HTML_INSTALL_DATA_TARGETS)
29 52 #uninstall-local: $(HTML_UNINSTALL_DATA_TARGETS)
30 53  
... ...
1 1 New Features and Important Changes in ctools 1.1.0
2 2  
3   -1 July 2016
  3 +9 July 2016
4 4  
5 5  
6 6 Introduction
... ... @@ -11,7 +11,7 @@ ctools release with respect to the precedent release.
11 11  
12 12 Configuration
13 13 -------------
14   -None
  14 +The package now supports out of source builds (#1484).
15 15  
16 16  
17 17 Python interface
... ...
caldb/Makefile.am
1   -## Process this file with automake to produce Makefile.in
  1 +#############################################################################
  2 +# Makefile.am for calibration database #
  3 +# ------------------------------------------------------------------------- #
  4 +# Copyright (C) 2016 Juergen Knoedlseder #
  5 +# ------------------------------------------------------------------------- #
  6 +# #
  7 +# This program is free software: you can redistribute it and/or modify #
  8 +# it under the terms of the GNU General Public License as published by #
  9 +# the Free Software Foundation, either version 3 of the License, or #
  10 +# (at your option) any later version. #
  11 +# #
  12 +# This program is distributed in the hope that it will be useful, #
  13 +# but WITHOUT ANY WARRANTY; without even the implied warranty of #
  14 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
  15 +# GNU General Public License for more details. #
  16 +# #
  17 +# You should have received a copy of the GNU General Public License #
  18 +# along with this program. If not, see <http://www.gnu.org/licenses/>. #
  19 +# #
  20 +#############################################################################
2 21  
3   -# Calibration files to distribute
  22 +# Calibration files to install
4 23 caldb_prod2_indxdir = $(datadir)/caldb/data/cta/prod2
5   -caldb_prod2_indx_DATA = data/cta/prod2/caldb.indx
  24 +caldb_prod2_indx_DATA = $(srcdir)/data/cta/prod2/caldb.indx
  25 +#
6 26 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
  27 +caldb_prod2_north1_DATA = $(srcdir)/data/cta/prod2/bcf/North_0.5h/irf_file.fits.gz
8 28 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
  29 +caldb_prod2_north2_DATA = $(srcdir)/data/cta/prod2/bcf/North_5h/irf_file.fits.gz
10 30 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
  31 +caldb_prod2_north3_DATA = $(srcdir)/data/cta/prod2/bcf/North_50h/irf_file.fits.gz
12 32 #
13 33 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
  34 +caldb_prod2_south1_DATA = $(srcdir)/data/cta/prod2/bcf/South_0.5h/irf_file.fits.gz
15 35 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
  36 +caldb_prod2_south2_DATA = $(srcdir)/data/cta/prod2/bcf/South_5h/irf_file.fits.gz
17 37 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
  38 +caldb_prod2_south3_DATA = $(srcdir)/data/cta/prod2/bcf/South_50h/irf_file.fits.gz
  39 +
  40 +# Calibration files to be distributed in the tar file
  41 +EXTRA_DIST = $(caldb_prod2_indx_DATA) \
  42 + $(caldb_prod2_north1_DATA) \
  43 + $(caldb_prod2_north2_DATA) \
  44 + $(caldb_prod2_north3_DATA) \
  45 + $(caldb_prod2_south1_DATA) \
  46 + $(caldb_prod2_south2_DATA) \
  47 + $(caldb_prod2_south3_DATA)
... ...
configure.ac
1 1 #############################################################################
2   -# Configuration for ctools - a set of tools for science analysis of CTA #
3   -# data #
  2 +# Configuration for ctools - tools for science analysis of CTA data #
4 3 # ------------------------------------------------------------------------- #
5 4 # Copyright (C) 2011-2016 Juergen Knoedlseder #
6 5 # ------------------------------------------------------------------------- #
... ... @@ -33,8 +32,8 @@ AC_INIT([ctools], [1.1.0.dev1], [jurgen.knodlseder@irap.omp.eu], [ctools])
33 32 AC_CONFIG_SRCDIR([src/ctselect/ctselect.cpp])
34 33 AC_CONFIG_MACRO_DIR([m4])
35 34 #AM_INIT_AUTOMAKE([gnu no-dependencies foreign])
36   -AM_INIT_AUTOMAKE([gnu -Wno-portability foreign])
37   -#AM_INIT_AUTOMAKE([gnu -Wno-portability serial-tests foreign])
  35 +#AM_INIT_AUTOMAKE([gnu -Wno-portability foreign])
  36 +AM_INIT_AUTOMAKE([gnu -Wno-portability foreign serial-tests])
38 37 AC_CONFIG_HEADER([config.h])
39 38  
40 39  
... ... @@ -609,8 +608,9 @@ AC_C_INLINE
609 608 # Python binding requires Python and either the files tools_wrap.cpp and #
610 609 # tools.py or swig to create these files. The following conditionals are #
611 610 # set: #
612   -# WITH_PYTHON - Python bindings will be built #
613   -# HAVE_SWIG - swig is available #
  611 +# WITH_PYTHON - Python bindings will be built #
  612 +# HAVE_SWIG - swig is available #
  613 +# HAVE_WRAPPERS - wrappers are available #
614 614 #############################################################################
615 615 # Initialise flags
616 616 enable_python="no"
... ... @@ -618,6 +618,7 @@ has_python=&quot;no&quot;
618 618 has_python_h="no"
619 619 has_swig="no"
620 620 has_wrappers="no"
  621 +build_wrappers="no"
621 622  
622 623 # Python binding enabled?
623 624 AC_ARG_ENABLE([python-binding],
... ... @@ -734,12 +735,18 @@ else
734 735  
735 736 # Do we have wrappers (tools_wrap.cpp and tools.py)?
736 737 has_wrappers="yes"
737   - AC_CHECK_FILES([pyext/ctools/tools_wrap.cpp pyext/ctools/tools.py],,
  738 + AC_CHECK_FILES([$srcdir/pyext/ctools/tools_wrap.cpp
  739 + $srcdir/pyext/ctools/tools.py],,
738 740 [has_wrappers="no"])
739 741 if test "x$has_wrappers" = "xno"; then
740 742 AC_MSG_WARN([Python wrapper missing. Requires swig for wrapper generation.])
741 743 fi
742 744  
  745 + # Don't we have wrappers but we have swig
  746 + if [test "x$has_wrappers" = "xno" -a "x$has_swig" = "xyes"]; then
  747 + build_wrappers="yes"
  748 + fi
  749 +
743 750 # Signal if Python is enabled
744 751 if test "x$ac_enable_python_binding" = "xyes" -a "x$has_python" = "xyes" -a "x$has_python_h" = "xyes"; then
745 752 if test "x$has_swig" = "xyes" -o "x$has_wrappers" = "xyes"; then
... ... @@ -748,8 +755,10 @@ else
748 755 fi
749 756  
750 757 fi
751   -AM_CONDITIONAL(HAVE_SWIG, test "x$has_swig" = "xyes")
752 758 AM_CONDITIONAL(WITH_PYTHON, test "x$enable_python" = "xyes")
  759 +AM_CONDITIONAL(HAVE_SWIG, test "x$has_swig" = "xyes")
  760 +AM_CONDITIONAL(HAVE_WRAPPERS, test "x$has_wrappers" = "xyes")
  761 +AM_CONDITIONAL(BUILD_WRAPPERS, test "x$build_wrappers" = "xyes")
753 762  
754 763 # Set Python environment
755 764 if test "x$enable_python" = "xyes"; then
... ... @@ -1022,7 +1031,6 @@ AC_CONFIG_FILES([Makefile
1022 1031 src/support/Makefile
1023 1032 src/ctools-setup
1024 1033 test/Makefile
1025   - test/test_cscripts.sh
1026 1034 test/test_python_ctools.sh
1027 1035 test/test_python_cscripts.sh
1028 1036 test/test_examples.py
... ... @@ -1036,8 +1044,7 @@ AC_CONFIG_FILES([Makefile
1036 1044 examples/Makefile
1037 1045 ctools.pc
1038 1046 testconf.sh],
1039   - [if test -f test/test_cscripts.sh; then chmod +x test/test_cscripts.sh; fi;
1040   - if test -f test/test_python_ctools.sh; then chmod +x test/test_python_ctools.sh; fi;
  1047 + [if test -f test/test_python_ctools.sh; then chmod +x test/test_python_ctools.sh; fi;
1041 1048 if test -f test/test_python_cscripts.sh; then chmod +x test/test_python_cscripts.sh; fi;
1042 1049 if test -f test/test_examples.py; then chmod +x test/test_examples.py; fi;
1043 1050 if test -f testconf.sh; then chmod +x testconf.sh; fi])
... ...
cscripts/Makefile.am
1   -## Process this file with automake to produce Makefile.in
  1 +#############################################################################
  2 +# Makefile for cscripts scripts #
  3 +# ------------------------------------------------------------------------- #
  4 +# Copyright (C) 2016 Juergen Knoedlseder #
  5 +# ------------------------------------------------------------------------- #
  6 +# #
  7 +# This program is free software: you can redistribute it and/or modify #
  8 +# it under the terms of the GNU General Public License as published by #
  9 +# the Free Software Foundation, either version 3 of the License, or #
  10 +# (at your option) any later version. #
  11 +# #
  12 +# This program is distributed in the hope that it will be useful, #
  13 +# but WITHOUT ANY WARRANTY; without even the implied warranty of #
  14 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
  15 +# GNU General Public License for more details. #
  16 +# #
  17 +# You should have received a copy of the GNU General Public License #
  18 +# along with this program. If not, see <http://www.gnu.org/licenses/>. #
  19 +# #
  20 +#############################################################################
2 21  
3 22 # Scripts to be distributed in $(pyexecdir)/cscripts
4   -pythonscripts = __init__.py \
5   - cscaldb.py \
6   - csinfo.py \
7   - cslightcrv.py \
8   - csmodelinfo.py \
9   - csmodelmerge.py \
10   - csobs2caldb.py \
11   - csobsdef.py \
12   - csobsinfo.py \
13   - cspull.py \
14   - csresmap.py \
15   - csroot2caldb.py \
16   - cssens.py \
17   - csspec.py \
18   - cstsdist.py \
19   - cstsmapmerge.py \
20   - cstsmapsplit.py \
21   - csworkflow.py \
22   - csfindobs.py \
23   - csiactcopy.py \
24   - csiactdata.py \
25   - csiactobs.py \
26   - obsutils.py
  23 +pythonscripts = $(builddir)/__init__.py \
  24 + $(srcdir)/cscaldb.py \
  25 + $(srcdir)/csinfo.py \
  26 + $(srcdir)/cslightcrv.py \
  27 + $(srcdir)/csmodelinfo.py \
  28 + $(srcdir)/csmodelmerge.py \
  29 + $(srcdir)/csobs2caldb.py \
  30 + $(srcdir)/csobsdef.py \
  31 + $(srcdir)/csobsinfo.py \
  32 + $(srcdir)/cspull.py \
  33 + $(srcdir)/csresmap.py \
  34 + $(srcdir)/csroot2caldb.py \
  35 + $(srcdir)/cssens.py \
  36 + $(srcdir)/csspec.py \
  37 + $(srcdir)/cstsdist.py \
  38 + $(srcdir)/cstsmapmerge.py \
  39 + $(srcdir)/cstsmapsplit.py \
  40 + $(srcdir)/csworkflow.py \
  41 + $(srcdir)/csfindobs.py \
  42 + $(srcdir)/csiactcopy.py \
  43 + $(srcdir)/csiactdata.py \
  44 + $(srcdir)/csiactobs.py \
  45 + $(srcdir)/obsutils.py
27 46  
28 47 # Parfiles to be distributed in $(prefix)/syspfiles
29   -parfiles = cscaldb.par \
30   - cslightcrv.par \
31   - csmodelinfo.par \
32   - csmodelmerge.par \
33   - csobs2caldb.par \
34   - csobsdef.par \
35   - csobsinfo.par \
36   - cspull.par \
37   - csresmap.par \
38   - csroot2caldb.par \
39   - cssens.par \
40   - csspec.par \
41   - cstsdist.par \
42   - cstsmapmerge.par \
43   - cstsmapsplit.par \
44   - csworkflow.par \
45   - csfindobs.par \
46   - csiactcopy.par \
47   - csiactdata.par \
48   - csiactobs.par
  48 +parfiles = $(srcdir)/cscaldb.par \
  49 + $(srcdir)/cslightcrv.par \
  50 + $(srcdir)/csmodelinfo.par \
  51 + $(srcdir)/csmodelmerge.par \
  52 + $(srcdir)/csobs2caldb.par \
  53 + $(srcdir)/csobsdef.par \
  54 + $(srcdir)/csobsinfo.par \
  55 + $(srcdir)/cspull.par \
  56 + $(srcdir)/csresmap.par \
  57 + $(srcdir)/csroot2caldb.par \
  58 + $(srcdir)/cssens.par \
  59 + $(srcdir)/csspec.par \
  60 + $(srcdir)/cstsdist.par \
  61 + $(srcdir)/cstsmapmerge.par \
  62 + $(srcdir)/cstsmapsplit.par \
  63 + $(srcdir)/csworkflow.par \
  64 + $(srcdir)/csfindobs.par \
  65 + $(srcdir)/csiactcopy.par \
  66 + $(srcdir)/csiactdata.par \
  67 + $(srcdir)/csiactobs.par
49 68  
50 69 # Scripts for which symbolic links will be created in bindir
51 70 linkscripts = cscaldb \
... ... @@ -71,64 +90,70 @@ linkscripts = cscaldb \
71 90 csiactobs
72 91  
73 92 # Test scripts to be distributed in $(pyexecdir)/cscripts/tests
74   -testscripts = tests/__init__.py \
75   - ../test/testing.py \
76   - ../test/test_python_cscripts.py \
77   - ../test/test_cscaldb.py \
78   - ../test/test_csmodelinfo.py \
79   - ../test/test_csmodelmerge.py \
80   - ../test/test_csobs2caldb.py \
81   - ../test/test_csobsdef.py \
82   - ../test/test_csobsinfo.py \
83   - ../test/test_cslightcrv.py \
84   - ../test/test_cspull.py \
85   - ../test/test_csresmap.py \
86   - ../test/test_csroot2caldb.py \
87   - ../test/test_cssens.py \
88   - ../test/test_csspec.py \
89   - ../test/test_cstsdist.py \
90   - ../test/test_cstsmapmerge.py \
91   - ../test/test_cstsmapsplit.py \
92   - ../test/test_csworkflow.py \
93   - ../test/test_csfindobs.py \
94   - ../test/test_csiactcopy.py \
95   - ../test/test_csiactdata.py \
96   - ../test/test_csiactobs.py
  93 +testscripts = $(srcdir)/tests/__init__.py \
  94 + $(top_srcdir)/test/testing.py \
  95 + $(top_srcdir)/test/test_python_cscripts.py \
  96 + $(top_srcdir)/test/test_cscaldb.py \
  97 + $(top_srcdir)/test/test_csmodelinfo.py \
  98 + $(top_srcdir)/test/test_csmodelmerge.py \
  99 + $(top_srcdir)/test/test_csobs2caldb.py \
  100 + $(top_srcdir)/test/test_csobsdef.py \
  101 + $(top_srcdir)/test/test_csobsinfo.py \
  102 + $(top_srcdir)/test/test_cslightcrv.py \
  103 + $(top_srcdir)/test/test_cspull.py \
  104 + $(top_srcdir)/test/test_csresmap.py \
  105 + $(top_srcdir)/test/test_csroot2caldb.py \
  106 + $(top_srcdir)/test/test_cssens.py \
  107 + $(top_srcdir)/test/test_csspec.py \
  108 + $(top_srcdir)/test/test_cstsdist.py \
  109 + $(top_srcdir)/test/test_cstsmapmerge.py \
  110 + $(top_srcdir)/test/test_cstsmapsplit.py \
  111 + $(top_srcdir)/test/test_csworkflow.py \
  112 + $(top_srcdir)/test/test_csfindobs.py \
  113 + $(top_srcdir)/test/test_csiactcopy.py \
  114 + $(top_srcdir)/test/test_csiactdata.py \
  115 + $(top_srcdir)/test/test_csiactobs.py
97 116  
98 117 # Test data to be distributed in $(pyexecdir)/cscripts/tests/data
99   -testdata = ../test/data/crab.xml \
100   - ../test/data/obs_unbinned.xml \
101   - ../test/data/obs_stacked.xml \
102   - ../test/data/crab_events.fits.gz \
103   - ../test/data/crab_cntmap.fits.gz \
104   - ../test/data/crab_cntmap_small.fits.gz \
105   - ../test/data/crab_expcube.fits.gz \
106   - ../test/data/crab_psfcube.fits.gz \
107   - ../test/data/crab_edispcube.fits.gz \
108   - ../test/data/crab_bkgcube.fits.gz \
109   - ../test/data/tsmap_0.fits \
110   - ../test/data/tsmap_1.fits \
111   - ../test/data/exclusion.reg \
112   - ../test/data/pntdef.dat \
113   - ../test/data/models.txt \
114   - ../test/data/tsmaps.txt \
115   - ../test/data/model_cube_background.xml \
116   - ../test/data/model_cube_background2.xml \
117   - ../test/data/crab_bkgcube.xml \
118   - ../test/data/irf.root \
119   - ../test/data/workflow.xml
  118 +testdata = $(top_srcdir)/test/data/crab.xml \
  119 + $(top_srcdir)/test/data/obs_unbinned.xml \
  120 + $(top_srcdir)/test/data/obs_stacked.xml \
  121 + $(top_srcdir)/test/data/crab_events.fits.gz \
  122 + $(top_srcdir)/test/data/crab_cntmap.fits.gz \
  123 + $(top_srcdir)/test/data/crab_cntmap_small.fits.gz \
  124 + $(top_srcdir)/test/data/crab_expcube.fits.gz \
  125 + $(top_srcdir)/test/data/crab_psfcube.fits.gz \
  126 + $(top_srcdir)/test/data/crab_edispcube.fits.gz \
  127 + $(top_srcdir)/test/data/crab_bkgcube.fits.gz \
  128 + $(top_srcdir)/test/data/tsmap_0.fits \
  129 + $(top_srcdir)/test/data/tsmap_1.fits \
  130 + $(top_srcdir)/test/data/exclusion.reg \
  131 + $(top_srcdir)/test/data/pntdef.dat \
  132 + $(top_srcdir)/test/data/models.txt \
  133 + $(top_srcdir)/test/data/tsmaps.txt \
  134 + $(top_srcdir)/test/data/model_cube_background.xml \
  135 + $(top_srcdir)/test/data/model_cube_background2.xml \
  136 + $(top_srcdir)/test/data/crab_bkgcube.xml \
  137 + $(top_srcdir)/test/data/irf.root \
  138 + $(top_srcdir)/test/data/irf_file.fits.gz \
  139 + $(top_srcdir)/test/data/workflow.xml \
  140 + $(top_srcdir)/test/data/butterfly.txt \
  141 + $(top_srcdir)/test/data/pha.fits \
  142 + $(top_srcdir)/test/data/pull.dat \
  143 + $(top_srcdir)/test/data/sensitivity.dat \
  144 + $(top_srcdir)/test/data/spectrum.fits \
  145 + $(top_srcdir)/test/data/ts.dat
120 146  
121   -# Test data to be distributed in $(pyexecdir)/cscripts/tests/iactdata
122   -testiactdata = ../test/iactdata/hdu-index.fits.gz \
123   - ../test/iactdata/master.json \
124   - ../test/iactdata/obs-index.fits.gz
  147 +# Test data to be distributed in $(pyexecdir)/cscripts/tests/data/iactdata
  148 +testiactdata = $(top_srcdir)/test/data/iactdata/hdu-index.fits.gz \
  149 + $(top_srcdir)/test/data/iactdata/master.json \
  150 + $(top_srcdir)/test/data/iactdata/obs-index.fits.gz \
  151 + $(top_srcdir)/test/data/iactdata/irf_file.fits.gz \
  152 + $(top_srcdir)/test/data/iactdata/events.fits.gz
125 153  
126   -# Test IRFs to be distributed in $(pyexecdir)/cscripts/tests/irf
127   -testirf = ../test/irf/irf_file.fits.gz \
128   - ../test/irf/cta_dummy_irf.dat
129   -
130   -# Distribute scripts and parfiles
131   -EXTRA_DIST = $(binscripts) $(pythonscripts)
  154 +# Install scripts, parfiles, test scripts and test data. Note that we don't
  155 +# need to prepend $(DESTDIR) here (not fully clear why, but that's the way
  156 +# it is)
132 157 binscriptsdir = $(bindir)
133 158 binscripts_DATA = $(binscripts)
134 159 pythonscriptsdir = $(pyexecdir)/cscripts
... ... @@ -139,12 +164,14 @@ testscriptsdir = $(pyexecdir)/cscripts/tests
139 164 testscripts_DATA = $(testscripts)
140 165 testdatadir = $(pyexecdir)/cscripts/tests/data
141 166 testdata_DATA = $(testdata)
142   -testiactdatadir = $(pyexecdir)/cscripts/tests/iactdata
  167 +testiactdatadir = $(pyexecdir)/cscripts/tests/data/iactdata
143 168 testiactdata_DATA = $(testiactdata)
144   -testirfdir = $(pyexecdir)/cscripts/tests/irf
145   -testirf_DATA = $(testirf)
146 169  
147   -# Add hook rule to create symbolic links for cscripts
  170 +# Files to be distributed in the tar file
  171 +EXTRA_DIST = $(binscripts) $(pythonscripts) $(parfiles) \
  172 + $(testscripts) $(testdata) $(testiactdata)
  173 +
  174 +# Add install hook rule to create symbolic links for cscripts
148 175 install-data-hook:
149 176 @binlist='$(binscripts)';\
150 177 for p in $$binlist; do \
... ... @@ -156,4 +183,17 @@ install-data-hook:
156 183 ln -s "$(DESTDIR)$(pyexecdir)/cscripts/$$p.py" "$(DESTDIR)$(bindir)/$$p"; \
157 184 chmod +x "$(DESTDIR)$(pyexecdir)/cscripts/$$p.py"; \
158 185 done
159   -
  186 +
  187 +# Files to be removed in build directory
  188 +clean-local:
  189 + rm -rf $(builddir)/cs*.py
  190 + rm -rf $(builddir)/obsutils.py
  191 + rm -rf $(builddir)/*.pyc
  192 + rm -rf $(builddir)/*.par
  193 +
  194 +# Uninstall the cscripts Python module
  195 +uninstall-local:
  196 + rm -rf $(DESTDIR)$(pyexecdir)/cscripts/*.pyc
  197 + rm -rf $(DESTDIR)$(pyexecdir)/cscripts/__pycache__
  198 + rm -rf $(DESTDIR)$(pyexecdir)/cscripts/tests/*.pyc
  199 + rm -rf $(DESTDIR)$(pyexecdir)/cscripts/tests/__pycache__
... ...
cscripts/csiactcopy.py
... ... @@ -18,8 +18,8 @@
18 18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 19 #
20 20 # ==========================================================================
21   -import sys
22 21 import os
  22 +import sys
23 23 import json
24 24 import shutil
25 25 import gammalib
... ... @@ -694,7 +694,11 @@ class csiactcopy(ctools.cscript):
694 694 self._log('Adding "'+str(newdict['name'])+'"')
695 695 self._log('\n')
696 696  
697   - # Write new json master file
  697 + # Write new json master file. Make sure that we have write permission
  698 + # before writing the file. This is needed as the original master file
  699 + # may be read-only, and the shutil.copy2 function copies over the
  700 + # access permissions.
  701 + os.chmod(localmaster, 0644)
698 702 f = open(localmaster, 'w')
699 703 data['datasets'] = newconfigs
700 704 json.dump(data, f, indent=2)
... ...
cscripts/csmodelmerge.py
... ... @@ -18,6 +18,7 @@
18 18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 19 #
20 20 # ==========================================================================
  21 +import os
21 22 import sys
22 23 import glob
23 24 import gammalib
... ... @@ -64,10 +65,22 @@ class csmodelmerge(ctools.cscript):
64 65 # Get input models string
65 66 inmodels = self['inmodels'].string()
66 67  
67   - # Handle ascii files
  68 + # Handle ASCII files. If the file names given in the ASCII are
  69 + # relative filenames it is assumed that the filename is given
  70 + # relative to the location of the file.
68 71 if '@' == inmodels[0]:
69   - self._files = open(inmodels.replace('@','')).read().splitlines()
70   -
  72 + filename = inmodels.replace('@','')
  73 + self._files = open(filename).read().splitlines()
  74 + dirname = os.path.dirname(filename)
  75 + files = []
  76 + for f in self._files:
  77 + if f[0] != '/':
  78 + fname = dirname + '/' + f
  79 + else:
  80 + fname = f
  81 + files.append(fname)
  82 + self._files = files
  83 +
71 84 # Handle wild card strings
72 85 elif '*' in inmodels:
73 86 self._files = glob.glob(inmodels)
... ... @@ -124,10 +137,10 @@ class csmodelmerge(ctools.cscript):
124 137 self._models = gammalib.GModels()
125 138  
126 139 # Loop over model files
127   - for file_ in self._files:
  140 + for f in self._files:
128 141  
129 142 # Construct container from XML file
130   - models = gammalib.GModels(file_)
  143 + models = gammalib.GModels(f)
131 144  
132 145 # Log number of models to add
133 146 if self._logTerse():
... ... @@ -139,7 +152,7 @@ class csmodelmerge(ctools.cscript):
139 152 else:
140 153 self._log(gammalib.parformat('Add %d models from file' %
141 154 nmodels))
142   - self._log(file_)
  155 + self._log(f)
143 156 self._log('\n')
144 157  
145 158 # Extend model container by adding all models in the model file
... ...
cscripts/csobs2caldb.py
... ... @@ -46,17 +46,17 @@ class csobs2caldb(ctools.cscript):
46 46 Constructor.
47 47 """
48 48 # Set name and version
49   - self._name = "csobs2caldb"
50   - self._version = "1.1.0"
  49 + self._name = 'csobs2caldb'
  50 + self._version = '1.1.0'
51 51  
52 52 # Initialise members
53 53 self._observation = gammalib.GCTAObservation()
54   - self._mission = "cta"
55   - self._caldb = "cta"
56   - self._outfile = gammalib.GFilename("irf_file.fits")
57   - self._base_dir = ""
58   - self._cal_dir = ""
59   - self._rsp_dir = ""
  54 + self._mission = 'cta'
  55 + self._caldb = 'cta'
  56 + self._outfile = gammalib.GFilename('irf_file.fits')
  57 + self._base_dir = ''
  58 + self._cal_dir = ''
  59 + self._rsp_dir = ''
60 60 self._caldb_inx = gammalib.GFits()
61 61 self._irf_fits = gammalib.GFits()
62 62  
... ... @@ -73,7 +73,7 @@ class csobs2caldb(ctools.cscript):
73 73 # Private methods
74 74 def _get_parameters(self):
75 75 """
76   - Get parameters from parfile.
  76 + Get parameters from parfile
77 77  
78 78 Raises:
79 79 ValueError, IndexError, & RuntimeError.
... ... @@ -81,7 +81,7 @@ class csobs2caldb(ctools.cscript):
81 81 # Load observation container from "inobs" parameter in case that
82 82 # the observation container is still empty.
83 83 if self._obs.is_empty():
84   - self._obs = gammalib.GObservations(self["inobs"].filename())
  84 + self._obs = gammalib.GObservations(self['inobs'].filename())
85 85  
86 86 # Raise an exception if the observation container is empty
87 87 if self._obs.is_empty():
... ... @@ -89,7 +89,7 @@ class csobs2caldb(ctools.cscript):
89 89 'parameter "inobs".')
90 90  
91 91 # Get index of observation to be used
92   - index = self["index"].integer()
  92 + index = self['index'].integer()
93 93  
94 94 # Raise an exception if the index is not valid
95 95 if index < 0 or index >= self._obs.size():
... ... @@ -100,37 +100,37 @@ class csobs2caldb(ctools.cscript):
100 100 self._observation = self._obs[index]
101 101  
102 102 # Make sure we have a CTA observation
103   - if not self._observation.classname() == "GCTAObservation":
  103 + if not self._observation.classname() == 'GCTAObservation':
104 104 raise RuntimeError('Input observation not of type '
105 105 '"GCTAObservation".')
106 106  
107 107 # Make sure we have an IRF response associated with the CTA
108 108 # observation
109   - if not self._observation.response().classname() == "GCTAResponseIrf":
  109 + if not self._observation.response().classname() == 'GCTAResponseIrf':
110 110 raise RuntimeError('Response of input observation not of '
111 111 'type "GCTAResponseIrf".')
112 112  
113 113 # Get calibration database name. If the "caldb" parameter is "NONE"
114 114 # or empty then use the instrument name from the observation as
115 115 # calibration database name.
116   - self._caldb = self["caldb"].string()
117   - if (self._caldb == "NONE" or len(self._caldb) == 0):
  116 + self._caldb = self['caldb'].string()
  117 + if (self._caldb == 'NONE' or len(self._caldb) == 0):
118 118 self._caldb = self._observation.instrument().lower()
119 119  
120 120 # Get instrument response function file name
121   - self._outfile = self["outfile"].filename()
  121 + self._outfile = self['outfile'].filename()
122 122  
123 123 # Make sure that remaining user parameters are queried now. We
124 124 # do not store the actual parameter values as we do not want
125 125 # too many instance attributes with enhances the maintenance
126 126 # costs.
127   - self["irf"].string()
128   - self["rootdir"].string()
  127 + self['irf'].string()
  128 + self['rootdir'].string()
129 129  
130 130 # Write input parameters and header into logger
131 131 if self._logTerse():
132 132 self._log_parameters()
133   - self._log("\n")
  133 + self._log('\n')
134 134  
135 135 # Return
136 136 return
... ...
cscripts/cstsmapmerge.py
... ... @@ -68,11 +68,23 @@ class cstsmapmerge(ctools.cscript):
68 68 """
69 69 # Get input maps string
70 70 inmaps = self['inmaps'].string()
71   -
72   - # Handle ascii files
  71 +
  72 + # Handle ASCII files. If the file names given in the ASCII are
  73 + # relative filenames it is assumed that the filename is given
  74 + # relative to the location of the file.
73 75 if '@' == inmaps[0]:
74   - self._files = open(inmaps.replace('@','')).read().splitlines()
75   -
  76 + filename = inmaps.replace('@','')
  77 + self._files = open(filename).read().splitlines()
  78 + dirname = os.path.dirname(filename)
  79 + files = []
  80 + for f in self._files:
  81 + if f[0] != '/':
  82 + fname = dirname + '/' + f
  83 + else:
  84 + fname = f
  85 + files.append(fname)
  86 + self._files = files
  87 +
76 88 # Handle wild card strings
77 89 elif '*' in inmaps:
78 90 self._files = glob.glob(inmaps)
... ...
examples/Makefile.am
1   -## Process this file with automake to produce Makefile.in
  1 +#############################################################################
  2 +# Makefile for ctools examples #
  3 +# ------------------------------------------------------------------------- #
  4 +# Copyright (C) 2016 Juergen Knoedlseder #
  5 +# ------------------------------------------------------------------------- #
  6 +# #
  7 +# This program is free software: you can redistribute it and/or modify #
  8 +# it under the terms of the GNU General Public License as published by #
  9 +# the Free Software Foundation, either version 3 of the License, or #
  10 +# (at your option) any later version. #
  11 +# #
  12 +# This program is distributed in the hope that it will be useful, #
  13 +# but WITHOUT ANY WARRANTY; without even the implied warranty of #
  14 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
  15 +# GNU General Public License for more details. #
  16 +# #
  17 +# You should have received a copy of the GNU General Public License #
  18 +# along with this program. If not, see <http://www.gnu.org/licenses/>. #
  19 +# #
  20 +#############################################################################
2 21  
3   -# Scripts to be distributed
  22 +# Scripts to be install
4 23 scripts = README.md \
  24 + generate_prod3_irfs.py \
5 25 make_pointings.py \
6 26 make_spectrum.py \
7 27 make_ts_distributions.py \
... ... @@ -19,13 +39,14 @@ scripts = README.md \
19 39 show_response.py \
20 40 show_sensitivity.py \
21 41 show_spectrum.py \
22   - show_ts_distribution.py
  42 + show_ts_distribution.py \
  43 + show_obs.py
23 44  
24   -# Set directories
25   -scriptsdir = $(datadir)/examples/python
26   -scripts_DATA = $(scripts)
  45 +# Set install directories
  46 +scriptsdir = $(datadir)/examples/python
  47 +scripts_DATA = $(scripts)
27 48  
28   -# Extra files to be distributed in the tar file
  49 +# Files to be distributed in the tar file
29 50 EXTRA_DIST = $(scripts)
30 51  
31 52 # Add hook rule to make the examples executable
... ...
examples/generate_prod3_irfs.py
... ... @@ -18,6 +18,7 @@
18 18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 19 #
20 20 # ==========================================================================
  21 +import sys
21 22 import gammalib
22 23 import cscripts
23 24  
... ... @@ -25,7 +26,7 @@ import cscripts
25 26 # ======================= #
26 27 # Set Prod3 DESY database #
27 28 # ======================= #
28   -def set_prod3_desy():
  29 +def set_prod3_desy(datadir):
29 30 """
30 31 Set Prod3 DESY database
31 32  
... ... @@ -33,11 +34,19 @@ def set_prod3_desy():
33 34 the db list a number of calibrations can be defined for which IRFs
34 35 should be generated. All calibrations will be added to the calibration
35 36 database.
  37 +
  38 + Parameters
  39 + ----------
  40 + datadir : str
  41 + Data directory
  42 +
  43 + Returns
  44 + -------
  45 + db : list of dict
  46 + Database
36 47 """
37 48 # Set database attributes
38   - #path = '/project-data/cta/performance/prod3'
39   - #file = 'DESY.d20160304.V5.ID0NIM2.prod3-paranalp05-NN.S.3HB1-ND-3.180000s.root'
40   - path = 'data'
  49 + path = datadir
41 50 file = 'irf.root'
42 51 psftype = 'Gauss'
43 52 oversample = 3
... ... @@ -62,8 +71,14 @@ def set_prod3_desy():
62 71 # ======================== #
63 72 if __name__ == '__main__':
64 73  
  74 + # Get optional argument
  75 + if len(sys.argv) == 2:
  76 + datadir = sys.argv[1]
  77 + else:
  78 + datadir = 'data'
  79 +
65 80 # Get database
66   - entries = set_prod3_desy()
  81 + entries = set_prod3_desy(datadir)
67 82  
68 83 # Loop over entries
69 84 for entry in entries:
... ...
examples/make_spectrum.py
... ... @@ -33,17 +33,17 @@ except:
33 33 # =============== #
34 34 # Make a spectrum #
35 35 # =============== #
36   -def make_spectrum():
  36 +def make_spectrum(datadir):
37 37 """
38 38 Simulate events and generate a source spectrum
39 39  
40 40 Returns
41 41 -------
42   - spectrum : `~gammalib.GFits`
43   - Spectrum FITS file
  42 + datadir : str
  43 + Data directory
44 44 """
45 45 # Set script parameters
46   - model_name = 'data/crab.xml'
  46 + model_name = datadir+'/crab.xml'
47 47 caldb = 'prod2'
48 48 irf = 'South_0.5h'
49 49 ra = 83.63
... ... @@ -183,15 +183,18 @@ def plot_spectrum(spectrum, file=False):
183 183 # ======================== #
184 184 if __name__ == '__main__':
185 185  
186   - # Initialise option
187   - file = False
188   -
189   - # Get any command line arguments
190   - if (len(sys.argv) > 1):
  186 + # Get optional arguments
  187 + if len(sys.argv) >= 2:
  188 + datadir = sys.argv[1]
  189 + else:
  190 + datadir = 'data'
  191 + if len(sys.argv) >= 3:
191 192 file = True
  193 + else:
  194 + file = False
192 195  
193 196 # Generate spectrum
194   - spectrum = make_spectrum()
  197 + spectrum = make_spectrum(datadir)
195 198  
196 199 # If matplotlib is installed then plot spectrum
197 200 if has_matplotlib:
... ...
examples/make_ts_distributions.py
... ... @@ -22,24 +22,19 @@ import sys
22 22 import time
23 23 import cscripts
24 24  
25   -# Optionally import processing module
26   -try:
27   - import processing
28   - has_processing = True
29   -except:
30   - has_processing = False
31   -
32 25  
33 26 # ====================== #
34 27 # Create TS distribution #
35 28 # ====================== #
36   -def create_ts(loge, emin, emax, ntrials=100, duration=180000.0,
37   - enumbins=0, log=False):
  29 +def create_ts(datadir, loge, emin, emax, ntrials=100, duration=180000.0,
  30 + enumbins=0, log=False):
38 31 """
39 32 Create TS distribution.
40 33  
41 34 Parameters
42 35 ----------
  36 + datadir : str
  37 + Data directory
43 38 loge : float
44 39 Logarithm of mean energy (TeV)
45 40 emin : float
... ... @@ -60,7 +55,7 @@ def create_ts(loge, emin, emax, ntrials=100, duration=180000.0,
60 55  
61 56 # Setup cstsdist tool
62 57 tsdist = cscripts.cstsdist()
63   - tsdist['inmodel'] = 'data/crab.xml'
  58 + tsdist['inmodel'] = datadir+'/crab.xml'
64 59 tsdist['srcname'] = 'Crab'
65 60 tsdist['outfile'] = outfile
66 61 tsdist['ntrials'] = ntrials
... ... @@ -104,12 +99,14 @@ if __name__ == &#39;__main__&#39;:
104 99 enumbins = 0
105 100 duration = 180000.0
106 101 max_threads = 1
  102 + datadir = 'data'
107 103  
108 104 # Parameter dictionnary
109 105 pars = [{'option': '-n', 'value': ntrials},
110 106 {'option': '-e', 'value': enumbins},
111 107 {'option': '-d', 'value': duration},
112   - {'option': '-m', 'value': max_threads}]
  108 + {'option': '-m', 'value': max_threads},
  109 + {'option': '-p', 'value': datadir}]
113 110  
114 111 # Gather parameters from command line
115 112 i = 1
... ... @@ -137,6 +134,7 @@ if __name__ == &#39;__main__&#39;:
137 134 enumbins = pars[1]['value']
138 135 duration = pars[2]['value']
139 136 max_threads = pars[3]['value']
  137 + datadir = pars[4]['value']
140 138  
141 139 # Loop over energy bands. The energy bands are those that are also
142 140 # used for sensitivity computation.
... ... @@ -152,33 +150,6 @@ if __name__ == &#39;__main__&#39;:
152 150 else:
153 151 loge = 'p'+str(abs(loge))
154 152  
155   - # If processing support is available then start max_threads processes
156   - # in parallel
157   - if has_processing:
158   -
159   - # Wait until one thread has finished
160   - while len(processing.activeChildren()) >= max_threads:
161   - time.sleep(10)
162   -
163   - # Set arguments
164   - args = (loge, emin, emax)
165   - kwargs = {'ntrials': ntrials, 'enumbins': enumbins,
166   - 'duration': duration}
167   -
168   - # Generate pull distribution
169   - p = processing.Process(target=create_ts, args=args, kwargs=kwargs)
170   - p.start()
171   - print('Process emin=%.4f emax=%.4f started.' % (emin, emax))
172   -
173   - # Wait a short time to allow process to start
174   - time.sleep(1)
175   -
176   - # ... otherwise simply start a single process
177   - else:
178   - create_ts(loge, emin, emax, ntrials=ntrials, enumbins=enumbins,
179   - duration=duration)
180   -
181   - # If processing support is available then wait until all threads finished
182   - if has_processing:
183   - while len(processing.activeChildren()) > 0:
184   - time.sleep(10)
  153 + # Create TS
  154 + create_ts(datadir, loge, emin, emax, ntrials=ntrials, enumbins=enumbins,
  155 + duration=duration)
... ...
examples/pipeline_binned_disk.py
... ... @@ -18,6 +18,7 @@
18 18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 19 #
20 20 # ==========================================================================
  21 +import sys
21 22 import gammalib
22 23 import ctools
23 24 from cscripts import obsutils
... ... @@ -218,11 +219,17 @@ if __name__ == &#39;__main__&#39;:
218 219 print('* CTA binned analysis pipeline *')
219 220 print('********************************************')
220 221  
  222 + # Get optional arguments
  223 + if len(sys.argv) == 2:
  224 + datadir = sys.argv[1]
  225 + else:
  226 + datadir = 'data'
  227 +
221 228 # Setup observations
222 229 obs = setup_observations()
223 230  
224 231 # Setup model
225   - obs = setup_model(obs)
  232 + obs = setup_model(obs, model=datadir+'/crab.xml')
226 233  
227 234 # Run analysis pipeline
228   - run_pipeline(obs)
  235 + run_pipeline(obs, model=datadir+'/crab.xml')
... ...
examples/pipeline_binned_mem.py
... ... @@ -18,6 +18,7 @@
18 18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 19 #
20 20 # ==========================================================================
  21 +import sys
21 22 import gammalib
22 23 import ctools
23 24 from cscripts import obsutils
... ... @@ -189,11 +190,17 @@ if __name__ == &#39;__main__&#39;:
189 190 print('* CTA binned analysis pipeline *')
190 191 print('********************************************')
191 192  
  193 + # Get optional arguments
  194 + if len(sys.argv) == 2:
  195 + datadir = sys.argv[1]
  196 + else:
  197 + datadir = 'data'
  198 +
192 199 # Setup observations
193 200 obs = setup_observations()
194 201  
195 202 # Setup model
196   - obs = setup_model(obs)
  203 + obs = setup_model(obs, model=datadir+'/crab.xml')
197 204  
198 205 # Run analysis pipeline
199 206 run_pipeline(obs)
... ...
examples/pipeline_stacked_disk.py
... ... @@ -18,6 +18,7 @@
18 18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 19 #
20 20 # ==========================================================================
  21 +import sys
21 22 import gammalib
22 23 import ctools
23 24 from cscripts import obsutils
... ... @@ -268,11 +269,17 @@ if __name__ == &#39;__main__&#39;:
268 269 print('* CTA stacked analysis pipeline *')
269 270 print('********************************************')
270 271  
  272 + # Get optional arguments
  273 + if len(sys.argv) == 2:
  274 + datadir = sys.argv[1]
  275 + else:
  276 + datadir = 'data'
  277 +
271 278 # Setup observations
272 279 obs = setup_observations()
273 280  
274 281 # Setup model
275   - obs = setup_model(obs)
  282 + obs = setup_model(obs, model=datadir+'/crab.xml')
276 283  
277 284 # Run analysis pipeline
278   - run_pipeline(obs)
  285 + run_pipeline(obs, model=datadir+'/crab.xml')
... ...
examples/pipeline_stacked_mem.py
... ... @@ -18,6 +18,7 @@
18 18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 19 #
20 20 # ==========================================================================
  21 +import sys
21 22 import gammalib
22 23 import ctools
23 24 from cscripts import obsutils
... ... @@ -241,11 +242,17 @@ if __name__ == &#39;__main__&#39;:
241 242 print('* CTA stacked analysis pipeline *')
242 243 print('********************************************')
243 244  
  245 + # Get optional arguments
  246 + if len(sys.argv) == 2:
  247 + datadir = sys.argv[1]
  248 + else:
  249 + datadir = 'data'
  250 +
244 251 # Setup observations
245 252 obs = setup_observations()
246 253  
247 254 # Setup model
248   - obs = setup_model(obs)
  255 + obs = setup_model(obs, model=datadir+'/crab.xml')
249 256  
250 257 # Run analysis pipeline
251 258 run_pipeline(obs)
... ...
examples/pipeline_unbinned_disk.py
... ... @@ -18,6 +18,7 @@
18 18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 19 #
20 20 # ==========================================================================
  21 +import sys
21 22 import gammalib
22 23 import ctools
23 24 from cscripts import obsutils
... ... @@ -192,11 +193,17 @@ if __name__ == &#39;__main__&#39;:
192 193 print('* CTA unbinned analysis pipeline *')
193 194 print('********************************************')
194 195  
  196 + # Get optional arguments
  197 + if len(sys.argv) == 2:
  198 + datadir = sys.argv[1]
  199 + else:
  200 + datadir = 'data'
  201 +
195 202 # Setup observations
196 203 obs = setup_observations()
197 204  
198 205 # Setup model
199   - obs = setup_model(obs)
  206 + obs = setup_model(obs, model=datadir+'/crab.xml')
200 207  
201 208 # Run analysis pipeline
202   - run_pipeline(obs)
  209 + run_pipeline(obs, model=datadir+'/crab.xml')
... ...
examples/pipeline_unbinned_mem.py
... ... @@ -18,6 +18,7 @@
18 18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 19 #
20 20 # ==========================================================================
  21 +import sys
21 22 import gammalib
22 23 import ctools
23 24 from cscripts import obsutils
... ... @@ -174,11 +175,17 @@ if __name__ == &#39;__main__&#39;:
174 175 print('* CTA unbinned analysis pipeline *')
175 176 print('********************************************')
176 177  
  178 + # Get optional arguments
  179 + if len(sys.argv) == 2:
  180 + datadir = sys.argv[1]
  181 + else:
  182 + datadir = 'data'
  183 +
177 184 # Setup observations
178 185 obs = setup_observations()
179 186  
180 187 # Setup model
181   - obs = setup_model(obs)
  188 + obs = setup_model(obs, model=datadir+'/crab.xml')
182 189  
183 190 # Run analysis pipeline
184 191 run_pipeline(obs)
... ...
examples/show_response.py
... ... @@ -339,13 +339,13 @@ if __name__ == &#39;__main__&#39;:
339 339  
340 340 # Set response dictionary
341 341 rsps = [
342   - {'dbname': 'irf',
343   - 'rspname': 'cta_dummy_irf.dat',
344   - 'name': 'Prod1 (Array E, MPIK)',
  342 + {'dbname': 'prod2',
  343 + 'rspname': 'South_0.5h',
  344 + 'name': 'Prod2 (30 min)',
345 345 'color': 'b'},
346   - {'dbname': 'irf',
347   - 'rspname': 'irf_file.fits',
348   - 'name': 'Prod2 (Aar, IFAE)',
  346 + {'dbname': 'prod2',
  347 + 'rspname': 'South_50h',
  348 + 'name': 'Prod2 (50 h)',
349 349 'color': 'r'}
350 350 ]
351 351  
... ...
models/Makefile.am
1   -## Process this file with automake to produce Makefile.in
  1 +#############################################################################
  2 +# Makefile for models #
  3 +# ------------------------------------------------------------------------- #
  4 +# Copyright (C) 2016 Juergen Knoedlseder #
  5 +# ------------------------------------------------------------------------- #
  6 +# #
  7 +# This program is free software: you can redistribute it and/or modify #
  8 +# it under the terms of the GNU General Public License as published by #
  9 +# the Free Software Foundation, either version 3 of the License, or #
  10 +# (at your option) any later version. #
  11 +# #
  12 +# This program is distributed in the hope that it will be useful, #
  13 +# but WITHOUT ANY WARRANTY; without even the implied warranty of #
  14 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
  15 +# GNU General Public License for more details. #
  16 +# #
  17 +# You should have received a copy of the GNU General Public License #
  18 +# along with this program. If not, see <http://www.gnu.org/licenses/>. #
  19 +# #
  20 +#############################################################################
2 21  
3   -# Background rate files to distribute
4   -#bkgs = bkg_dummy.txt
5   -#bkgsdir = $(datadir)/models
6   -#bkgs_DATA = $(bkgs)
  22 +# Models to install
  23 +models = crab.xml \
  24 + crab_poly.xml \
  25 + crab_profile.xml \
  26 + disk.xml \
  27 + gauss.xml \
  28 + shell.xml
7 29  
8   -# Models to distribute
9   -models = crab.xml \
10   - crab_poly.xml \
11   - crab_profile.xml \
12   - disk.xml \
13   - gauss.xml \
14   - shell.xml
  30 +# Install models
15 31 modelsdir = $(datadir)/models
16 32 models_DATA = $(models)
17 33  
... ...
pyext/Makefile.am
... ... @@ -29,96 +29,140 @@
29 29 # Works only if Python is available
30 30 if WITH_PYTHON
31 31  
  32 +# Set wrapper directory depending on the whether the wrappers were actually
  33 +# shipped with the distribution of whether the wrappers have to be build
  34 +# using swig
  35 +if BUILD_WRAPPERS
  36 + wrapperdir = $(builddir)
  37 +else
  38 + wrapperdir = $(srcdir)
  39 +endif
  40 +
32 41 # Test scripts to be distributed in $(pyexecdir)/ctools/tests
33 42 testscripts = ctools/tests/__init__.py \
34   - ../test/testing.py \
35   - ../test/test_python_ctools.py \
36   - ../test/test_ctobssim.py \
37   - ../test/test_ctselect.py \
38   - ../test/test_ctbin.py \
39   - ../test/test_ctlike.py \
40   - ../test/test_cttsmap.py \
41   - ../test/test_ctmodel.py \
42   - ../test/test_ctskymap.py \
43   - ../test/test_ctexpcube.py \
44   - ../test/test_ctpsfcube.py \
45   - ../test/test_ctedispcube.py \
46   - ../test/test_ctbkgcube.py \
47   - ../test/test_ctmapcube.py \
48   - ../test/test_ctcubemask.py \
49   - ../test/test_ctbutterfly.py \
50   - ../test/test_ctulimit.py \
51   - ../test/test_cterror.py \
52   - ../test/test_pipelines.py
53   -testdata = ../test/data/crab.xml \
54   - ../test/data/crab_events.fits.gz \
55   - ../test/data/crab_cntmap.fits.gz \
56   - ../test/data/exclusion.reg
57   -testirf = ../test/irf/cta_dummy_irf.dat
58   -
59   -# Distribute scripts
60   -EXTRA_DIST = $(testscripts) $(testdata) $(testirf)
  43 + $(top_srcdir)/test/testing.py \
  44 + $(top_srcdir)/test/test_python_ctools.py \
  45 + $(top_srcdir)/test/test_ctobssim.py \
  46 + $(top_srcdir)/test/test_ctselect.py \
  47 + $(top_srcdir)/test/test_ctbin.py \
  48 + $(top_srcdir)/test/test_ctlike.py \
  49 + $(top_srcdir)/test/test_cttsmap.py \
  50 + $(top_srcdir)/test/test_ctmodel.py \
  51 + $(top_srcdir)/test/test_ctskymap.py \
  52 + $(top_srcdir)/test/test_ctexpcube.py \
  53 + $(top_srcdir)/test/test_ctpsfcube.py \
  54 + $(top_srcdir)/test/test_ctedispcube.py \
  55 + $(top_srcdir)/test/test_ctbkgcube.py \
  56 + $(top_srcdir)/test/test_ctmapcube.py \
  57 + $(top_srcdir)/test/test_ctcubemask.py \
  58 + $(top_srcdir)/test/test_ctbutterfly.py \
  59 + $(top_srcdir)/test/test_ctulimit.py \
  60 + $(top_srcdir)/test/test_cterror.py \
  61 + $(top_srcdir)/test/test_pipelines.py
  62 +
  63 +# Test data to be distributed in $(pyexecdir)/ctools/tests/data
  64 +testdata = $(top_srcdir)/test/data/crab.xml \
  65 + $(top_srcdir)/test/data/crab_events.fits.gz \
  66 + $(top_srcdir)/test/data/crab_cntmap.fits.gz \
  67 + $(top_srcdir)/test/data/exclusion.reg
  68 +
  69 +# Install test scripts and test data. Note that we don't need to prepend
  70 +# $(DESTDIR) here (not fully clear why, but that's the way it is)
  71 +
61 72 testscriptsdir = $(pyexecdir)/ctools/tests
62 73 testscripts_DATA = $(testscripts)
63 74 testdatadir = $(pyexecdir)/ctools/tests/data
64 75 testdata_DATA = $(testdata)
65   -testirfdir = $(pyexecdir)/ctools/tests/irf
66   -testirf_DATA = $(testirf)
67 76  
68   -# Set SWIG interface filename
69   -SWIG_INTERFACE = ctools/tools.i
  77 +# If building of Python wrappers was requested then add them to the build
  78 +# source
  79 +if BUILD_WRAPPERS
70 80  
71   -# Dependencies. Obtain the list of dependencies by executing ls.
72   -DEPFILES = $(shell ls *.Pi 2> /dev/null)
73   -include $(DEPFILES)
  81 +# Set SWIG compile command
  82 +SWIGCOMPILE = $(SWIG) -c++ -python -Wall \
  83 + -I$(DESTDIR)$(prefix)/share/gammalib/swig \
  84 + -I$(GAMMALIB)/share/gammalib/swig \
  85 + -I$(top_srcdir)/pyext
74 86  
75   -# Define the targets that should be built before anything else.
76   -# These are honored by 'make all', 'make check' and 'make install'.
77   -if HAVE_SWIG
78   - BUILT_SOURCES = ctools/tools_wrap.cpp ctools/tools.py
79   -endif
  87 +# Sources that are required for the build. All targets in the list will be
  88 +# built before anything. These are honored by 'make all', 'make check' and
  89 +# 'make install'. We use this here to make sure that all these targets are
  90 +# build by swig before we start compiling the Python modules.
  91 +BUILT_SOURCES = $(wrapperdir)/ctools/tools_wrap.cpp \
  92 + $(wrapperdir)/ctools/tools.py
80 93  
81   -# Set files to be removed in clean. We remove only the SWIG interface files
82   -# if SWIG is available to rebuild them.
83   -if HAVE_SWIG
84   - CLEAN_FILES = $(BUILT_SOURCES)
85   -endif
86   -CLEANFILES = $(CLEAN_FILES) $(DEPFILES)
  94 +# Add the wrappers to the files that will be deleted in a 'make clean'
  95 +CLEAN_FILES = $(BUILT_SOURCES)
87 96  
88   -# Set SWIG compile command
89   -SWIGCOMPILE = $(SWIG) -c++ -python -Wall -I$(prefix)/share/gammalib/swig -I$(GAMMALIB)/share/gammalib/swig
  97 +# Rule to build SWIG wrappers
  98 +swig: $(BUILT_SOURCES)
  99 +
  100 +# Rule for building Python wrappers using SWIG.
  101 +ctools/tools.py: ctools/tools_wrap.cpp
  102 +ctools/tools_wrap.cpp: ctools/tools.i
  103 + if $(SWIGCOMPILE) -MMD -MF "tools.Tpi" -o ctools/tools_wrap.cpp $<; \
  104 + then mv -f "tools.Tpi" "tools.Pi"; else rm -f "tools.Tpi"; exit 1; fi
  105 +
  106 +# ... otherwise, if building of Python wrappers has not been required then
  107 +# they are located in the source directory and we don't have to build them
  108 +# using swig
  109 +else
  110 +CLEAN_FILES =
  111 +BUILT_SOURCES =
  112 +endif # BUILD_WRAPPERS
  113 +
  114 +# Extra files to be distributed in the tar file
  115 +EXTRA_DIST = ctools/tests \
  116 + $(wrapperdir)/ctools/tools_wrap.cpp \
  117 + $(wrapperdir)/ctools/tools.py \
  118 + $(testscripts) \
  119 + $(testdata) \
  120 + $(testirf)
  121 +
  122 +# Dependencies. Obtain the list of dependencies by executing ls.
  123 +DEPFILES = $(shell ls *.Pi 2> /dev/null)
  124 +include $(DEPFILES)
90 125  
  126 +# Things we want to do when 'make' is invoked.
91 127 all-local: build
92 128  
93   -# We build the python extension twice since the install step needs the result
94   -# in a specific directory and the test make check has no access to the name
95   -# of this specific directory. So we build one instance for checking, the other
96   -# for installation. If we could get the name built by distutils we could avoid
97   -# this.
98   -build: ctools/tools_wrap.cpp ctools/tools.py
  129 +# Build the ctools extension module
  130 +build: $(BUILT_SOURCES)
99 131 $(PYTHON) setup.py build
100 132 if IS_ELCAPITAN
101 133 -for f in build/ctools/ctools/_*.so; do \
102 134 echo "Post process module "$$f; \
103 135 install_name_tool -change $(libdir)/libctools.1.dylib @rpath/libctools.1.dylib $$f; \
104   - install_name_tool -change $(libdir)/libgamma.1.dylib @rpath/libgamma.1.dylib $$f; \
  136 + install_name_tool -change $(libdir)/libgamma.2.dylib @rpath/libgamma.2.dylib $$f; \
105 137 install_name_tool -add_rpath $(libdir) $$f; \
106   - install_name_tool -add_rpath $(abs_top_srcdir)/src/.libs $$f; \
  138 + install_name_tool -add_rpath $(abs_top_builddir)/src/.libs $$f; \
107 139 done
108 140 endif
109 141  
  142 +# Install the ctools Python module
110 143 install-exec-local:
111   - $(PYTHON) setup.py install --prefix=$(prefix)
  144 + $(PYTHON) setup.py install --prefix=$(DESTDIR)$(prefix)
112 145  
113   -clean-local:
114   - rm -rf build _tools.so
  146 +# Uninstall the ctools Python module
  147 +uninstall-local:
  148 + rm -rf $(DESTDIR)$(pyexecdir)/ctools/*.py
  149 + rm -rf $(DESTDIR)$(pyexecdir)/ctools/*.pyc
  150 + rm -rf $(DESTDIR)$(pyexecdir)/ctools/*.so
  151 + rm -rf $(DESTDIR)$(pyexecdir)/ctools/__pycache__
  152 + rm -rf $(DESTDIR)$(pyexecdir)/ctools/tests/*.pyc
  153 + rm -rf $(DESTDIR)$(pyexecdir)/ctools/tests/__pycache__
  154 + rm -rf $(DESTDIR)$(pyexecdir)/ctools-@VERSION@*.egg-info
115 155  
116   -# Rule for building Python wrappers using SWIG.
117   -if HAVE_SWIG
118   -ctools/tools.py: ctools/tools_wrap.cpp
119   -ctools/tools_wrap.cpp: $(SWIG_INTERFACE)
120   - if $(SWIGCOMPILE) -MMD -MF "tools.Tpi" -o ctools/tools_wrap.cpp $<; \
121   - then mv -f "tools.Tpi" "tools.Pi"; else rm -f "tools.Tpi"; exit 1; fi
122   -endif # HAVE_SWIG
  156 +# Set files to be removed in 'make clean'
  157 +CLEANFILES = $(CLEAN_FILES) $(DEPFILES)
  158 +
  159 +# Files to be removed in build directory
  160 +clean-local:
  161 + rm -rf build
  162 + rm -rf $(builddir)/ctools/*.py
  163 + rm -rf $(builddir)/ctools/*.pyc
  164 + rm -rf $(builddir)/ctools/*_wrap.cpp
  165 + rm -rf $(builddir)/ctools/_tools.so
  166 + rm -rf $(builddir)/ctools/__pycache__
123 167  
124 168 endif # WITH_PYTHON
... ...
pyext/setup.py.in
... ... @@ -24,15 +24,25 @@ import glob
24 24 import os
25 25 import sys
26 26  
  27 +# Define package name
  28 +pkg_name = 'ctools'
  29 +
27 30 # Detect execution mode
28 31 is_build = True
29 32 if (len(sys.argv) >= 2):
30 33 if (sys.argv[1] == 'install'):
31 34 is_build = False
32 35 if is_build:
33   - sys.stdout.write("Python extension module building:\n")
  36 + print('Python extension module building:')
34 37 else:
35   - sys.stdout.write("Python extension module installation:\n")
  38 + print('Python extension module installation:')
  39 +
  40 +# Set prefix
  41 +prefix = '@prefix@'
  42 +if (len(sys.argv) >= 3):
  43 + if (sys.argv[2].find('--prefix') != -1):
  44 + start = sys.argv[2].find('=') + 1
  45 + prefix = sys.argv[2][start:]
36 46  
37 47 # Darwin MacPorts kluge: Remove -L/opt/local/lib path from LDSHARED as this
38 48 # overrides the GammaLib settings. Otherwise, MacPorts libraries would be
... ... @@ -52,33 +62,33 @@ if sys.platform.lower().startswith(&quot;darwin&quot;):
52 62 else:
53 63 ldshared_rm += option + ' '
54 64 if (len(ldshared_rm) > 0):
55   - sys.stdout.write("Removed following option(s) from LDSHARED: "+ldshared_rm+"\n")
  65 + print('Removed following option(s) from LDSHARED: %s' % (ldshared_rm))
56 66  
57 67 # Set LDSHARED
58 68 cvars['LDSHARED'] = ldshared_new
59 69  
60 70 # Set default include directories and data files
61   -include_dirs = ['@prefix@/include/gammalib']
  71 +include_dirs = [prefix+'/include/gammalib']
62 72 install_files = glob.glob('@top_srcdir@/pyext/*.i')
63 73 library_dirs = ['../src/.libs']
64 74 runtime_library_dirs = ['../src/.libs']
65 75 libraries = ['ctools','gamma']
66 76  
67 77 # Add install directory to runtime library path
68   -if os.path.exists('@prefix@/lib'):
69   - library_dirs.append('@prefix@/lib')
70   - runtime_library_dirs.append('@prefix@/lib')
  78 +if os.path.exists(prefix+'/lib'):
  79 + library_dirs.append(prefix+'/lib')
  80 + runtime_library_dirs.append(prefix+'/lib')
71 81  
72 82 # Add application include files. The method we use here is not very
73 83 # intelligent as it simple will add all names that start with 'ct'
74 84 # in the src directory. Once we added the ctools script we had to
75 85 # add an explicit filter to avoid appending those.
76   -dirs = glob.glob('../src/ct*')
  86 +dirs = glob.glob('@top_srcdir@/src/ct*')
77 87 for dir in dirs:
78 88 if len(dir) > 0 and 'ctools' not in dir:
79 89 path = os.path.abspath(dir)
80 90 include_dirs.append(path)
81   -include_dirs.append(os.path.abspath('../src/support'))
  91 +include_dirs.append(os.path.abspath('@top_srcdir@/src/support'))
82 92  
83 93 # Add extra libraries
84 94 extra_libs = ('@PYTHON_EXTRA_LIBS@').split(',')
... ... @@ -104,7 +114,7 @@ for extra_include_dir in extra_include_dirs:
104 114 include_dirs.append(dir)
105 115  
106 116 # Set data files to install.
107   -data_files=[('@prefix@/share/ctools/swig', install_files)]
  117 +data_files=[(prefix+'/share/ctools/swig', install_files)]
108 118  
109 119 # Optionally enable OpenMP
110 120 if '@OPENMP_TRUE@' != '#':
... ... @@ -123,6 +133,24 @@ if len(&#39;@COVERAGE_CXXFLAGS@&#39;) &gt; 0:
123 133 if '@IS_ELCAPITAN_TRUE@' != '#':
124 134 extra_link_args.append('-headerpad_max_install_names')
125 135  
  136 +# If this is a build then we may need to copy over a bunch of files
  137 +if is_build:
  138 +
  139 + # In case that wrappers were not built then copy the module wrapper files
  140 + # from the source to the build directory
  141 + if '@BUILD_WRAPPERS_FALSE@' != '#':
  142 + py_file = pkg_name+'/tools.py'
  143 + cpp_file = pkg_name+'/tools_wrap.cpp'
  144 + os.system('cp %s %s' % ('@srcdir@/'+cpp_file, '@builddir@/'+cpp_file))
  145 + os.system('cp %s %s' % ('@srcdir@/'+py_file, '@builddir@/'+py_file))
  146 +
  147 + # In case that the build directory is different from the source directory
  148 + # then copy all cscripts and parfiles from the source directory to the
  149 + # build directory
  150 + if '@top_srcdir@' != '@top_builddir@':
  151 + os.system('cp %s/cscripts/*.py %s/cscripts' % ('@top_srcdir@', '@top_builddir@'))
  152 + os.system('cp %s/cscripts/*.par %s/cscripts' % ('@top_srcdir@', '@top_builddir@'))
  153 +
126 154 # Setup
127 155 setup(name='@PACKAGE_NAME@',
128 156 version='@PACKAGE_VERSION@',
... ... @@ -130,7 +158,6 @@ setup(name=&#39;@PACKAGE_NAME@&#39;,
130 158 author='Juergen Knoedlseder',
131 159 author_email='@PACKAGE_BUGREPORT@',
132 160 url='http://cta.irap.omp.eu/ctools/',
133   - py_modules=['ctools.tools'],
134 161 ext_modules=[Extension('ctools._tools', ['ctools/tools_wrap.cpp'],
135 162 include_dirs=include_dirs,
136 163 library_dirs=library_dirs,
... ... @@ -138,10 +165,11 @@ setup(name=&#39;@PACKAGE_NAME@&#39;,
138 165 runtime_library_dirs=runtime_library_dirs,
139 166 extra_compile_args=extra_compile_args,
140 167 extra_link_args=extra_link_args)],
  168 + py_modules=['ctools.tools'],
141 169 data_files=data_files,
142 170 license="GNU GPL v3",
143 171 long_description="CTA science analysis tools",
144   - platforms=["Linux", "Solaris", "Mac OS-X", "Unix", "BSD"],
  172 + platforms=['Linux', 'Solaris', 'Mac OS-X', 'Unix', 'BSD'],
145 173 )
146 174  
147 175 # Post-processing. A symbolic link is created to the directory containing the
... ... @@ -151,12 +179,12 @@ if is_build:
151 179 try:
152 180 os.chdir('build')
153 181 os.remove('ctools')
154   - sys.stdout.write("Removed symbolic link build/ctools.\n")
  182 + print('Removed symbolic link build/ctools.')
155 183 except:
156 184 pass
157 185 try:
158 186 path = glob.glob('lib.*')
159 187 os.symlink(path[0], 'ctools')
160   - sys.stdout.write("Created symbolic link build/ctools.\n")
  188 + print('Created symbolic link build/ctools.')
161 189 except:
162   - sys.stdout.write("WARNING: Failed to create symbolic link build/ctools.\n")
  190 + print('WARNING: Failed to create symbolic link build/ctools.')
... ...
src/Makefile.am
1   -## Process this file with automake to produce Makefile.in
  1 +#############################################################################
  2 +# Makefile.am for ctools module #
  3 +# ------------------------------------------------------------------------- #
  4 +# Copyright (C) 2016 Juergen Knoedlseder #
  5 +# ------------------------------------------------------------------------- #
  6 +# #
  7 +# This program is free software: you can redistribute it and/or modify #
  8 +# it under the terms of the GNU General Public License as published by #
  9 +# the Free Software Foundation, either version 3 of the License, or #
  10 +# (at your option) any later version. #
  11 +# #
  12 +# This program is distributed in the hope that it will be useful, #
  13 +# but WITHOUT ANY WARRANTY; without even the implied warranty of #
  14 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
  15 +# GNU General Public License for more details. #
  16 +# #
  17 +# You should have received a copy of the GNU General Public License #
  18 +# along with this program. If not, see <http://www.gnu.org/licenses/>. #
  19 +# #
  20 +#############################################################################
2 21  
3 22 # Darwin support
4 23 MACOSX_DEPLOYMENT_TARGET=@CONFIGURE_MACOSX_DEPLOYMENT_TARGET@
... ... @@ -60,10 +79,13 @@ scripts_DATA = $(scripts)
60 79 # Things to install
61 80 install-data-local: help-install
62 81  
  82 +# Things to uninstall
  83 +uninstall-local: help-uninstall
  84 +
63 85 # Install help files
64 86 help-install:
65 87 @$(mkinstalldirs) $(DESTDIR)$(datadir)/help && \
66   - for file in $(top_srcdir)/doc/source/reference_manual/c*.rst ; do \
  88 + for file in $(top_srcdir)/doc/source/users/reference_manual/c*.rst ; do \
67 89 filename="$${file##*/}" ; \
68 90 basename="$${filename%%.*}" ; \
69 91 helpname="$$basename.txt" ; \
... ... @@ -75,6 +97,10 @@ help-install:
75 97 rm -rf $(DESTDIR)$(datadir)/help/"$$helpname".bak ; \
76 98 done
77 99  
  100 +# Uninstall help files
  101 +help-uninstall:
  102 + rm -rf $(DESTDIR)$(datadir)/help
  103 +
78 104 # Add hook rule to make scripts executable
79 105 install-data-hook:
80 106 @list='$(scripts_DATA)';\
... ...
src/ctbin/Makefile.am
1   -## Process this file with automake to produce Makefile.in
  1 +#############################################################################
  2 +# Makefile.am for ctbin tool #
  3 +# ------------------------------------------------------------------------- #
  4 +# Copyright (C) 2016 Juergen Knoedlseder #
  5 +# ------------------------------------------------------------------------- #
  6 +# #
  7 +# This program is free software: you can redistribute it and/or modify #
  8 +# it under the terms of the GNU General Public License as published by #
  9 +# the Free Software Foundation, either version 3 of the License, or #
  10 +# (at your option) any later version. #
  11 +# #
  12 +# This program is distributed in the hope that it will be useful, #
  13 +# but WITHOUT ANY WARRANTY; without even the implied warranty of #
  14 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
  15 +# GNU General Public License for more details. #
  16 +# #
  17 +# You should have received a copy of the GNU General Public License #
  18 +# along with this program. If not, see <http://www.gnu.org/licenses/>. #
  19 +# #
  20 +#############################################################################
2 21  
3 22 # Set include directories
4 23 INCLUDES = -I$(top_srcdir)/src/support
... ... @@ -7,7 +26,7 @@ INCLUDES = -I$(top_srcdir)/src/support
7 26 bin_PROGRAMS = ctbin
8 27  
9 28 # Sources
10   -sources = ctbin.cpp
  29 +sources = ctbin.cpp ctbin.hpp
11 30  
12 31 # Libtool library
13 32 noinst_LTLIBRARIES = libctbin.la
... ... @@ -18,8 +37,11 @@ libctbin_la_LDFLAGS = @OPENMP_LIB_LDFLAGS@
18 37 ctbin_SOURCES = main.cpp
19 38 ctbin_LDFLAGS = $(LIB_LINK_OPTION) @LDFLAGS@
20 39 ctbin_CPPFLAGS = @CPPFLAGS@
21   -ctbin_LDADD = libctbin.la $(top_srcdir)/src/support/libsupport.la
  40 +ctbin_LDADD = libctbin.la $(top_builddir)/src/support/libsupport.la
22 41  
23 42 # Parameter files
24 43 pfilesdir = $(prefix)/syspfiles
25   -pfiles_DATA = ctbin.par
  44 +pfiles_DATA = $(srcdir)/ctbin.par
  45 +
  46 +# Extra files to be distributed in the tar file
  47 +EXTRA_DIST = $(pfiles_DATA)
... ...
src/ctbkgcube/Makefile.am
1   -## Process this file with automake to produce Makefile.in
  1 +#############################################################################
  2 +# Makefile.am for ctbkgcube tool #
  3 +# ------------------------------------------------------------------------- #
  4 +# Copyright (C) 2016 Juergen Knoedlseder #
  5 +# ------------------------------------------------------------------------- #
  6 +# #
  7 +# This program is free software: you can redistribute it and/or modify #
  8 +# it under the terms of the GNU General Public License as published by #
  9 +# the Free Software Foundation, either version 3 of the License, or #
  10 +# (at your option) any later version. #
  11 +# #
  12 +# This program is distributed in the hope that it will be useful, #
  13 +# but WITHOUT ANY WARRANTY; without even the implied warranty of #
  14 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
  15 +# GNU General Public License for more details. #
  16 +# #
  17 +# You should have received a copy of the GNU General Public License #
  18 +# along with this program. If not, see <http://www.gnu.org/licenses/>. #
  19 +# #
  20 +#############################################################################
2 21  
3 22 # Set include directories
4 23 INCLUDES = -I$(top_srcdir)/src/support
... ... @@ -7,7 +26,7 @@ INCLUDES = -I$(top_srcdir)/src/support
7 26 bin_PROGRAMS = ctbkgcube
8 27  
9 28 # Sources
10   -sources = ctbkgcube.cpp
  29 +sources = ctbkgcube.cpp ctbkgcube.hpp
11 30  
12 31 # Libtool library
13 32 noinst_LTLIBRARIES = libctbkgcube.la
... ... @@ -18,8 +37,11 @@ libctbkgcube_la_LDFLAGS = @OPENMP_LIB_LDFLAGS@
18 37 ctbkgcube_SOURCES = main.cpp
19 38 ctbkgcube_LDFLAGS = $(LIB_LINK_OPTION) @LDFLAGS@
20 39 ctbkgcube_CPPFLAGS = @CPPFLAGS@
21   -ctbkgcube_LDADD = libctbkgcube.la $(top_srcdir)/src/support/libsupport.la
  40 +ctbkgcube_LDADD = libctbkgcube.la $(top_builddir)/src/support/libsupport.la
22 41  
23 42 # Parameter files
24 43 pfilesdir = $(prefix)/syspfiles
25   -pfiles_DATA = ctbkgcube.par
  44 +pfiles_DATA = $(srcdir)/ctbkgcube.par
  45 +
  46 +# Extra files to be distributed in the tar file
  47 +EXTRA_DIST = $(pfiles_DATA)
... ...
src/ctbutterfly/Makefile.am
1   -## Process this file with automake to produce Makefile.in
  1 +#############################################################################
  2 +# Makefile.am for ctbutterfly tool #
  3 +# ------------------------------------------------------------------------- #
  4 +# Copyright (C) 2016 Juergen Knoedlseder #
  5 +# ------------------------------------------------------------------------- #
  6 +# #
  7 +# This program is free software: you can redistribute it and/or modify #
  8 +# it under the terms of the GNU General Public License as published by #
  9 +# the Free Software Foundation, either version 3 of the License, or #
  10 +# (at your option) any later version. #
  11 +# #
  12 +# This program is distributed in the hope that it will be useful, #
  13 +# but WITHOUT ANY WARRANTY; without even the implied warranty of #
  14 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
  15 +# GNU General Public License for more details. #
  16 +# #
  17 +# You should have received a copy of the GNU General Public License #
  18 +# along with this program. If not, see <http://www.gnu.org/licenses/>. #
  19 +# #
  20 +#############################################################################
2 21  
3 22 # Set include directories
4 23 INCLUDES = -I$(top_srcdir)/src/support
... ... @@ -7,7 +26,7 @@ INCLUDES = -I$(top_srcdir)/src/support
7 26 bin_PROGRAMS = ctbutterfly
8 27  
9 28 # Sources
10   -sources = ctbutterfly.cpp
  29 +sources = ctbutterfly.cpp ctbutterfly.hpp
11 30  
12 31 # Libtool library
13 32 noinst_LTLIBRARIES = libctbutterfly.la
... ... @@ -18,8 +37,11 @@ libctbutterfly_la_LDFLAGS = @OPENMP_LIB_LDFLAGS@
18 37 ctbutterfly_SOURCES = main.cpp
19 38 ctbutterfly_LDFLAGS = $(LIB_LINK_OPTION) @LDFLAGS@
20 39 ctbutterfly_CPPFLAGS = @CPPFLAGS@
21   -ctbutterfly_LDADD = libctbutterfly.la $(top_srcdir)/src/support/libsupport.la
  40 +ctbutterfly_LDADD = libctbutterfly.la $(top_builddir)/src/support/libsupport.la
22 41  
23 42 # Parameter files
24 43 pfilesdir = $(prefix)/syspfiles
25   -pfiles_DATA = ctbutterfly.par
  44 +pfiles_DATA = $(srcdir)/ctbutterfly.par
  45 +
  46 +# Extra files to be distributed in the tar file
  47 +EXTRA_DIST = $(pfiles_DATA)
... ...
src/ctcubemask/Makefile.am
1   -## Process this file with automake to produce Makefile.in
  1 +#############################################################################
  2 +# Makefile.am for ctcubemask tool #
  3 +# ------------------------------------------------------------------------- #
  4 +# Copyright (C) 2016 Juergen Knoedlseder #
  5 +# ------------------------------------------------------------------------- #
  6 +# #
  7 +# This program is free software: you can redistribute it and/or modify #
  8 +# it under the terms of the GNU General Public License as published by #
  9 +# the Free Software Foundation, either version 3 of the License, or #
  10 +# (at your option) any later version. #
  11 +# #
  12 +# This program is distributed in the hope that it will be useful, #
  13 +# but WITHOUT ANY WARRANTY; without even the implied warranty of #
  14 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
  15 +# GNU General Public License for more details. #
  16 +# #
  17 +# You should have received a copy of the GNU General Public License #
  18 +# along with this program. If not, see <http://www.gnu.org/licenses/>. #
  19 +# #
  20 +#############################################################################
2 21  
3 22 # Set include directories
4 23 INCLUDES = -I$(top_srcdir)/src/support
... ... @@ -7,7 +26,7 @@ INCLUDES = -I$(top_srcdir)/src/support
7 26 bin_PROGRAMS = ctcubemask
8 27  
9 28 # Sources
10   -sources = ctcubemask.cpp
  29 +sources = ctcubemask.cpp ctcubemask.hpp
11 30  
12 31 # Libtool library (only needed for python bindings)
13 32 noinst_LTLIBRARIES = libctcubemask.la
... ... @@ -18,8 +37,11 @@ libctcubemask_la_LDFLAGS = @OPENMP_LIB_LDFLAGS@
18 37 ctcubemask_SOURCES = main.cpp
19 38 ctcubemask_LDFLAGS = $(LIB_LINK_OPTION) @LDFLAGS@
20 39 ctcubemask_CPPFLAGS = @CPPFLAGS@
21   -ctcubemask_LDADD = libctcubemask.la $(top_srcdir)/src/support/libsupport.la
  40 +ctcubemask_LDADD = libctcubemask.la $(top_builddir)/src/support/libsupport.la
22 41  
23 42 # Parameter files
24 43 pfilesdir = $(prefix)/syspfiles
25   -pfiles_DATA = ctcubemask.par
  44 +pfiles_DATA = $(srcdir)/ctcubemask.par
  45 +
  46 +# Extra files to be distributed in the tar file
  47 +EXTRA_DIST = $(pfiles_DATA)
... ...
src/ctedispcube/Makefile.am
1   -## Process this file with automake to produce Makefile.in
  1 +#############################################################################
  2 +# Makefile.am for ctedispcube tool #
  3 +# ------------------------------------------------------------------------- #
  4 +# Copyright (C) 2016 Juergen Knoedlseder #
  5 +# ------------------------------------------------------------------------- #
  6 +# #
  7 +# This program is free software: you can redistribute it and/or modify #
  8 +# it under the terms of the GNU General Public License as published by #
  9 +# the Free Software Foundation, either version 3 of the License, or #
  10 +# (at your option) any later version. #
  11 +# #
  12 +# This program is distributed in the hope that it will be useful, #
  13 +# but WITHOUT ANY WARRANTY; without even the implied warranty of #
  14 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
  15 +# GNU General Public License for more details. #
  16 +# #
  17 +# You should have received a copy of the GNU General Public License #
  18 +# along with this program. If not, see <http://www.gnu.org/licenses/>. #
  19 +# #
  20 +#############################################################################
2 21  
3 22 # Set include directories
4 23 INCLUDES = -I$(top_srcdir)/src/support
... ... @@ -7,7 +26,7 @@ INCLUDES = -I$(top_srcdir)/src/support
7 26 bin_PROGRAMS = ctedispcube
8 27  
9 28 # Sources
10   -sources = ctedispcube.cpp
  29 +sources = ctedispcube.cpp ctedispcube.hpp
11 30  
12 31 # Libtool library
13 32 noinst_LTLIBRARIES = libctedispcube.la
... ... @@ -18,8 +37,11 @@ libctedispcube_la_LDFLAGS = @OPENMP_LIB_LDFLAGS@
18 37 ctedispcube_SOURCES = main.cpp
19 38 ctedispcube_LDFLAGS = $(LIB_LINK_OPTION) @LDFLAGS@
20 39 ctedispcube_CPPFLAGS = @CPPFLAGS@
21   -ctedispcube_LDADD = libctedispcube.la $(top_srcdir)/src/support/libsupport.la
  40 +ctedispcube_LDADD = libctedispcube.la $(top_builddir)/src/support/libsupport.la
22 41  
23 42 # Parameter files
24 43 pfilesdir = $(prefix)/syspfiles
25   -pfiles_DATA = ctedispcube.par
  44 +pfiles_DATA = $(srcdir)/ctedispcube.par
  45 +
  46 +# Extra files to be distributed in the tar file
  47 +EXTRA_DIST = $(pfiles_DATA)
... ...
src/cterror/Makefile.am
1   -## Process this file with automake to produce Makefile.in
  1 +#############################################################################
  2 +# Makefile.am for cterror tool #
  3 +# ------------------------------------------------------------------------- #
  4 +# Copyright (C) 2016 Juergen Knoedlseder #
  5 +# ------------------------------------------------------------------------- #
  6 +# #
  7 +# This program is free software: you can redistribute it and/or modify #
  8 +# it under the terms of the GNU General Public License as published by #
  9 +# the Free Software Foundation, either version 3 of the License, or #
  10 +# (at your option) any later version. #
  11 +# #
  12 +# This program is distributed in the hope that it will be useful, #
  13 +# but WITHOUT ANY WARRANTY; without even the implied warranty of #
  14 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
  15 +# GNU General Public License for more details. #
  16 +# #
  17 +# You should have received a copy of the GNU General Public License #
  18 +# along with this program. If not, see <http://www.gnu.org/licenses/>. #
  19 +# #
  20 +#############################################################################
2 21  
3 22 # Set include directories
4 23 INCLUDES = -I$(top_srcdir)/src/support
... ... @@ -7,7 +26,7 @@ INCLUDES = -I$(top_srcdir)/src/support
7 26 bin_PROGRAMS = cterror
8 27  
9 28 # Sources
10   -sources = cterror.cpp
  29 +sources = cterror.cpp cterror.hpp
11 30  
12 31 # Libtool library
13 32 noinst_LTLIBRARIES = libcterror.la
... ... @@ -18,8 +37,11 @@ libcterror_la_LDFLAGS = @OPENMP_LIB_LDFLAGS@
18 37 cterror_SOURCES = main.cpp
19 38 cterror_LDFLAGS = $(LIB_LINK_OPTION) @LDFLAGS@
20 39 cterror_CPPFLAGS = @CPPFLAGS@
21   -cterror_LDADD = libcterror.la $(top_srcdir)/src/support/libsupport.la
  40 +cterror_LDADD = libcterror.la $(top_builddir)/src/support/libsupport.la
22 41  
23 42 # Parameter files
24 43 pfilesdir = $(prefix)/syspfiles
25   -pfiles_DATA = cterror.par
  44 +pfiles_DATA = $(srcdir)/cterror.par
  45 +
  46 +# Extra files to be distributed in the tar file
  47 +EXTRA_DIST = $(pfiles_DATA)
... ...
src/ctexpcube/Makefile.am
1   -## Process this file with automake to produce Makefile.in
  1 +#############################################################################
  2 +# Makefile.am for ctexpcube tool #
  3 +# ------------------------------------------------------------------------- #
  4 +# Copyright (C) 2016 Juergen Knoedlseder #
  5 +# ------------------------------------------------------------------------- #
  6 +# #
  7 +# This program is free software: you can redistribute it and/or modify #
  8 +# it under the terms of the GNU General Public License as published by #
  9 +# the Free Software Foundation, either version 3 of the License, or #
  10 +# (at your option) any later version. #
  11 +# #
  12 +# This program is distributed in the hope that it will be useful, #
  13 +# but WITHOUT ANY WARRANTY; without even the implied warranty of #
  14 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
  15 +# GNU General Public License for more details. #
  16 +# #
  17 +# You should have received a copy of the GNU General Public License #
  18 +# along with this program. If not, see <http://www.gnu.org/licenses/>. #
  19 +# #
  20 +#############################################################################
2 21  
3 22 # Set include directories
4 23 INCLUDES = -I$(top_srcdir)/src/support
... ... @@ -7,7 +26,7 @@ INCLUDES = -I$(top_srcdir)/src/support
7 26 bin_PROGRAMS = ctexpcube
8 27  
9 28 # Sources
10   -sources = ctexpcube.cpp
  29 +sources = ctexpcube.cpp ctexpcube.hpp
11 30  
12 31 # Libtool library
13 32 noinst_LTLIBRARIES = libctexpcube.la
... ... @@ -18,8 +37,11 @@ libctexpcube_la_LDFLAGS = @OPENMP_LIB_LDFLAGS@
18 37 ctexpcube_SOURCES = main.cpp
19 38 ctexpcube_LDFLAGS = $(LIB_LINK_OPTION) @LDFLAGS@
20 39 ctexpcube_CPPFLAGS = @CPPFLAGS@
21   -ctexpcube_LDADD = libctexpcube.la $(top_srcdir)/src/support/libsupport.la
  40 +ctexpcube_LDADD = libctexpcube.la $(top_builddir)/src/support/libsupport.la
22 41  
23 42 # Parameter files
24 43 pfilesdir = $(prefix)/syspfiles
25   -pfiles_DATA = ctexpcube.par
  44 +pfiles_DATA = $(srcdir)/ctexpcube.par
  45 +
  46 +# Extra files to be distributed in the tar file
  47 +EXTRA_DIST = $(pfiles_DATA)
... ...
src/ctlike/Makefile.am
1   -## Process this file with automake to produce Makefile.in
  1 +#############################################################################
  2 +# Makefile.am for ctlike tool #
  3 +# ------------------------------------------------------------------------- #
  4 +# Copyright (C) 2016 Juergen Knoedlseder #
  5 +# ------------------------------------------------------------------------- #
  6 +# #
  7 +# This program is free software: you can redistribute it and/or modify #
  8 +# it under the terms of the GNU General Public License as published by #
  9 +# the Free Software Foundation, either version 3 of the License, or #
  10 +# (at your option) any later version. #
  11 +# #
  12 +# This program is distributed in the hope that it will be useful, #
  13 +# but WITHOUT ANY WARRANTY; without even the implied warranty of #
  14 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
  15 +# GNU General Public License for more details. #
  16 +# #
  17 +# You should have received a copy of the GNU General Public License #
  18 +# along with this program. If not, see <http://www.gnu.org/licenses/>. #
  19 +# #
  20 +#############################################################################
2 21  
3 22 # Set include directories
4 23 INCLUDES = -I$(top_srcdir)/src/support
... ... @@ -7,7 +26,7 @@ INCLUDES = -I$(top_srcdir)/src/support
7 26 bin_PROGRAMS = ctlike
8 27  
9 28 # Sources
10   -sources = ctlike.cpp
  29 +sources = ctlike.cpp ctlike.hpp
11 30  
12 31 # Libtool library
13 32 noinst_LTLIBRARIES = libctlike.la
... ... @@ -18,8 +37,11 @@ libctlike_la_LDFLAGS = @OPENMP_LIB_LDFLAGS@
18 37 ctlike_SOURCES = main.cpp
19 38 ctlike_LDFLAGS = $(LIB_LINK_OPTION) @LDFLAGS@
20 39 ctlike_CPPFLAGS = @CPPFLAGS@
21   -ctlike_LDADD = libctlike.la $(top_srcdir)/src/support/libsupport.la
  40 +ctlike_LDADD = libctlike.la $(top_builddir)/src/support/libsupport.la
22 41  
23 42 # Parameter files
24 43 pfilesdir = $(prefix)/syspfiles
25   -pfiles_DATA = ctlike.par
  44 +pfiles_DATA = $(srcdir)/ctlike.par
  45 +
  46 +# Extra files to be distributed in the tar file
  47 +EXTRA_DIST = $(pfiles_DATA)
... ...
src/ctmapcube/Makefile.am
1   -## Process this file with automake to produce Makefile.in
  1 +#############################################################################
  2 +# Makefile.am for ctmapcube tool #
  3 +# ------------------------------------------------------------------------- #
  4 +# Copyright (C) 2016 Juergen Knoedlseder #
  5 +# ------------------------------------------------------------------------- #
  6 +# #
  7 +# This program is free software: you can redistribute it and/or modify #
  8 +# it under the terms of the GNU General Public License as published by #
  9 +# the Free Software Foundation, either version 3 of the License, or #
  10 +# (at your option) any later version. #
  11 +# #
  12 +# This program is distributed in the hope that it will be useful, #
  13 +# but WITHOUT ANY WARRANTY; without even the implied warranty of #
  14 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
  15 +# GNU General Public License for more details. #
  16 +# #
  17 +# You should have received a copy of the GNU General Public License #
  18 +# along with this program. If not, see <http://www.gnu.org/licenses/>. #
  19 +# #
  20 +#############################################################################
2 21  
3 22 # Set include directories
4 23 INCLUDES = -I$(top_srcdir)/src/support
... ... @@ -7,7 +26,7 @@ INCLUDES = -I$(top_srcdir)/src/support
7 26 bin_PROGRAMS = ctmapcube
8 27  
9 28 # Sources
10   -sources = ctmapcube.cpp
  29 +sources = ctmapcube.cpp ctmapcube.hpp
11 30  
12 31 # Libtool library
13 32 noinst_LTLIBRARIES = libctmapcube.la
... ... @@ -18,8 +37,11 @@ libctmapcube_la_LDFLAGS = @OPENMP_LIB_LDFLAGS@
18 37 ctmapcube_SOURCES = main.cpp
19 38 ctmapcube_LDFLAGS = $(LIB_LINK_OPTION) @LDFLAGS@
20 39 ctmapcube_CPPFLAGS = @CPPFLAGS@
21   -ctmapcube_LDADD = libctmapcube.la $(top_srcdir)/src/support/libsupport.la
  40 +ctmapcube_LDADD = libctmapcube.la $(top_builddir)/src/support/libsupport.la
22 41  
23 42 # Parameter files
24 43 pfilesdir = $(prefix)/syspfiles
25   -pfiles_DATA = ctmapcube.par
  44 +pfiles_DATA = $(srcdir)/ctmapcube.par
  45 +
  46 +# Extra files to be distributed in the tar file
  47 +EXTRA_DIST = $(pfiles_DATA)
... ...
src/ctmodel/Makefile.am
1   -## Process this file with automake to produce Makefile.in
  1 +#############################################################################
  2 +# Makefile.am for ctmodel tool #
  3 +# ------------------------------------------------------------------------- #
  4 +# Copyright (C) 2016 Juergen Knoedlseder #
  5 +# ------------------------------------------------------------------------- #
  6 +# #
  7 +# This program is free software: you can redistribute it and/or modify #
  8 +# it under the terms of the GNU General Public License as published by #
  9 +# the Free Software Foundation, either version 3 of the License, or #
  10 +# (at your option) any later version. #
  11 +# #
  12 +# This program is distributed in the hope that it will be useful, #
  13 +# but WITHOUT ANY WARRANTY; without even the implied warranty of #
  14 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
  15 +# GNU General Public License for more details. #
  16 +# #
  17 +# You should have received a copy of the GNU General Public License #
  18 +# along with this program. If not, see <http://www.gnu.org/licenses/>. #
  19 +# #
  20 +#############################################################################
2 21  
3 22 # Set include directories
4 23 INCLUDES = -I$(top_srcdir)/src/support
... ... @@ -7,7 +26,7 @@ INCLUDES = -I$(top_srcdir)/src/support
7 26 bin_PROGRAMS = ctmodel
8 27  
9 28 # Sources
10   -sources = ctmodel.cpp
  29 +sources = ctmodel.cpp ctmodel.hpp
11 30  
12 31 # Libtool library
13 32 noinst_LTLIBRARIES = libctmodel.la
... ... @@ -18,8 +37,11 @@ libctmodel_la_LDFLAGS = @OPENMP_LIB_LDFLAGS@
18 37 ctmodel_SOURCES = main.cpp
19 38 ctmodel_LDFLAGS = $(LIB_LINK_OPTION) @LDFLAGS@
20 39 ctmodel_CPPFLAGS = @CPPFLAGS@
21   -ctmodel_LDADD = libctmodel.la $(top_srcdir)/src/support/libsupport.la
  40 +ctmodel_LDADD = libctmodel.la $(top_builddir)/src/support/libsupport.la
22 41  
23 42 # Parameter files
24 43 pfilesdir = $(prefix)/syspfiles
25   -pfiles_DATA = ctmodel.par
  44 +pfiles_DATA = $(srcdir)/ctmodel.par
  45 +
  46 +# Extra files to be distributed in the tar file
  47 +EXTRA_DIST = $(pfiles_DATA)
... ...
src/ctobssim/Makefile.am
1   -## Process this file with automake to produce Makefile.in
  1 +#############################################################################
  2 +# Makefile.am for ctobssim tool #
  3 +# ------------------------------------------------------------------------- #
  4 +# Copyright (C) 2016 Juergen Knoedlseder #
  5 +# ------------------------------------------------------------------------- #
  6 +# #
  7 +# This program is free software: you can redistribute it and/or modify #
  8 +# it under the terms of the GNU General Public License as published by #
  9 +# the Free Software Foundation, either version 3 of the License, or #
  10 +# (at your option) any later version. #
  11 +# #
  12 +# This program is distributed in the hope that it will be useful, #
  13 +# but WITHOUT ANY WARRANTY; without even the implied warranty of #
  14 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
  15 +# GNU General Public License for more details. #
  16 +# #
  17 +# You should have received a copy of the GNU General Public License #
  18 +# along with this program. If not, see <http://www.gnu.org/licenses/>. #
  19 +# #
  20 +#############################################################################
2 21  
3 22 # Set include directories
4 23 INCLUDES = -I$(top_srcdir)/src/support
... ... @@ -7,7 +26,7 @@ INCLUDES = -I$(top_srcdir)/src/support
7 26 bin_PROGRAMS = ctobssim
8 27  
9 28 # Sources
10   -sources = ctobssim.cpp
  29 +sources = ctobssim.cpp ctobssim.hpp
11 30  
12 31 # Libtool library
13 32 noinst_LTLIBRARIES = libctobssim.la
... ... @@ -18,8 +37,11 @@ libctobssim_la_LDFLAGS = @OPENMP_LIB_LDFLAGS@
18 37 ctobssim_SOURCES = main.cpp
19 38 ctobssim_LDFLAGS = $(LIB_LINK_OPTION) @LDFLAGS@
20 39 ctobssim_CPPFLAGS = @CPPFLAGS@
21   -ctobssim_LDADD = libctobssim.la $(top_srcdir)/src/support/libsupport.la
  40 +ctobssim_LDADD = libctobssim.la $(top_builddir)/src/support/libsupport.la
22 41  
23 42 # Parameter files
24 43 pfilesdir = $(prefix)/syspfiles
25   -pfiles_DATA = ctobssim.par
  44 +pfiles_DATA = $(srcdir)/ctobssim.par
  45 +
  46 +# Extra files to be distributed in the tar file
  47 +EXTRA_DIST = $(pfiles_DATA)
... ...
src/ctpsfcube/Makefile.am
1   -## Process this file with automake to produce Makefile.in
  1 +#############################################################################
  2 +# Makefile.am for ctpsfcube tool #
  3 +# ------------------------------------------------------------------------- #
  4 +# Copyright (C) 2016 Juergen Knoedlseder #
  5 +# ------------------------------------------------------------------------- #
  6 +# #
  7 +# This program is free software: you can redistribute it and/or modify #
  8 +# it under the terms of the GNU General Public License as published by #
  9 +# the Free Software Foundation, either version 3 of the License, or #
  10 +# (at your option) any later version. #
  11 +# #
  12 +# This program is distributed in the hope that it will be useful, #
  13 +# but WITHOUT ANY WARRANTY; without even the implied warranty of #
  14 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
  15 +# GNU General Public License for more details. #
  16 +# #
  17 +# You should have received a copy of the GNU General Public License #
  18 +# along with this program. If not, see <http://www.gnu.org/licenses/>. #
  19 +# #
  20 +#############################################################################
2 21  
3 22 # Set include directories
4 23 INCLUDES = -I$(top_srcdir)/src/support
... ... @@ -7,7 +26,7 @@ INCLUDES = -I$(top_srcdir)/src/support
7 26 bin_PROGRAMS = ctpsfcube
8 27  
9 28 # Sources
10   -sources = ctpsfcube.cpp
  29 +sources = ctpsfcube.cpp ctpsfcube.hpp
11 30  
12 31 # Libtool library
13 32 noinst_LTLIBRARIES = libctpsfcube.la
... ... @@ -18,8 +37,11 @@ libctpsfcube_la_LDFLAGS = @OPENMP_LIB_LDFLAGS@
18 37 ctpsfcube_SOURCES = main.cpp
19 38 ctpsfcube_LDFLAGS = $(LIB_LINK_OPTION) @LDFLAGS@
20 39 ctpsfcube_CPPFLAGS = @CPPFLAGS@
21   -ctpsfcube_LDADD = libctpsfcube.la $(top_srcdir)/src/support/libsupport.la
  40 +ctpsfcube_LDADD = libctpsfcube.la $(top_builddir)/src/support/libsupport.la
22 41  
23 42 # Parameter files
24 43 pfilesdir = $(prefix)/syspfiles
25   -pfiles_DATA = ctpsfcube.par
  44 +pfiles_DATA = $(srcdir)/ctpsfcube.par
  45 +
  46 +# Extra files to be distributed in the tar file
  47 +EXTRA_DIST = $(pfiles_DATA)
... ...
src/ctselect/Makefile.am
1   -## Process this file with automake to produce Makefile.in
  1 +#############################################################################
  2 +# Makefile.am for ctselect tool #
  3 +# ------------------------------------------------------------------------- #
  4 +# Copyright (C) 2016 Juergen Knoedlseder #
  5 +# ------------------------------------------------------------------------- #
  6 +# #
  7 +# This program is free software: you can redistribute it and/or modify #
  8 +# it under the terms of the GNU General Public License as published by #
  9 +# the Free Software Foundation, either version 3 of the License, or #
  10 +# (at your option) any later version. #
  11 +# #
  12 +# This program is distributed in the hope that it will be useful, #
  13 +# but WITHOUT ANY WARRANTY; without even the implied warranty of #
  14 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
  15 +# GNU General Public License for more details. #
  16 +# #
  17 +# You should have received a copy of the GNU General Public License #
  18 +# along with this program. If not, see <http://www.gnu.org/licenses/>. #
  19 +# #
  20 +#############################################################################
2 21  
3 22 # Set include directories
4 23 INCLUDES = -I$(top_srcdir)/src/support
... ... @@ -7,7 +26,7 @@ INCLUDES = -I$(top_srcdir)/src/support
7 26 bin_PROGRAMS = ctselect
8 27  
9 28 # Sources
10   -sources = ctselect.cpp
  29 +sources = ctselect.cpp ctselect.hpp
11 30  
12 31 # Libtool library (only needed for python bindings)
13 32 noinst_LTLIBRARIES = libctselect.la
... ... @@ -18,8 +37,11 @@ libctselect_la_LDFLAGS = @OPENMP_LIB_LDFLAGS@
18 37 ctselect_SOURCES = main.cpp
19 38 ctselect_LDFLAGS = $(LIB_LINK_OPTION) @LDFLAGS@
20 39 ctselect_CPPFLAGS = @CPPFLAGS@
21   -ctselect_LDADD = libctselect.la $(top_srcdir)/src/support/libsupport.la
  40 +ctselect_LDADD = libctselect.la $(top_builddir)/src/support/libsupport.la
22 41  
23 42 # Parameter files
24 43 pfilesdir = $(prefix)/syspfiles
25   -pfiles_DATA = ctselect.par
  44 +pfiles_DATA = $(srcdir)/ctselect.par
  45 +
  46 +# Extra files to be distributed in the tar file
  47 +EXTRA_DIST = $(pfiles_DATA)
... ...
src/ctskymap/Makefile.am
1   -## Process this file with automake to produce Makefile.in
  1 +#############################################################################
  2 +# Makefile.am for ctskymap tool #
  3 +# ------------------------------------------------------------------------- #
  4 +# Copyright (C) 2016 Juergen Knoedlseder #
  5 +# ------------------------------------------------------------------------- #
  6 +# #
  7 +# This program is free software: you can redistribute it and/or modify #
  8 +# it under the terms of the GNU General Public License as published by #
  9 +# the Free Software Foundation, either version 3 of the License, or #
  10 +# (at your option) any later version. #
  11 +# #
  12 +# This program is distributed in the hope that it will be useful, #
  13 +# but WITHOUT ANY WARRANTY; without even the implied warranty of #
  14 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
  15 +# GNU General Public License for more details. #
  16 +# #
  17 +# You should have received a copy of the GNU General Public License #
  18 +# along with this program. If not, see <http://www.gnu.org/licenses/>. #
  19 +# #
  20 +#############################################################################
2 21  
3 22 # Set include directories
4 23 INCLUDES = -I$(top_srcdir)/src/support
... ... @@ -7,7 +26,7 @@ INCLUDES = -I$(top_srcdir)/src/support
7 26 bin_PROGRAMS = ctskymap
8 27  
9 28 # Sources
10   -sources = ctskymap.cpp
  29 +sources = ctskymap.cpp ctskymap.hpp
11 30  
12 31 # Libtool library
13 32 noinst_LTLIBRARIES = libctskymap.la
... ... @@ -18,8 +37,11 @@ libctskymap_la_LDFLAGS = @OPENMP_LIB_LDFLAGS@
18 37 ctskymap_SOURCES = main.cpp
19 38 ctskymap_LDFLAGS = $(LIB_LINK_OPTION) @LDFLAGS@
20 39 ctskymap_CPPFLAGS = @CPPFLAGS@
21   -ctskymap_LDADD = libctskymap.la $(top_srcdir)/src/support/libsupport.la
  40 +ctskymap_LDADD = libctskymap.la $(top_builddir)/src/support/libsupport.la
22 41  
23 42 # Parameter files
24 43 pfilesdir = $(prefix)/syspfiles
25   -pfiles_DATA = ctskymap.par
  44 +pfiles_DATA = $(srcdir)/ctskymap.par
  45 +
  46 +# Extra files to be distributed in the tar file
  47 +EXTRA_DIST = $(pfiles_DATA)
... ...
src/cttsmap/Makefile.am
1   -## Process this file with automake to produce Makefile.in
  1 +#############################################################################
  2 +# Makefile.am for cttsmap tool #
  3 +# ------------------------------------------------------------------------- #
  4 +# Copyright (C) 2016 Juergen Knoedlseder #
  5 +# ------------------------------------------------------------------------- #
  6 +# #
  7 +# This program is free software: you can redistribute it and/or modify #
  8 +# it under the terms of the GNU General Public License as published by #
  9 +# the Free Software Foundation, either version 3 of the License, or #
  10 +# (at your option) any later version. #
  11 +# #
  12 +# This program is distributed in the hope that it will be useful, #
  13 +# but WITHOUT ANY WARRANTY; without even the implied warranty of #
  14 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
  15 +# GNU General Public License for more details. #
  16 +# #
  17 +# You should have received a copy of the GNU General Public License #
  18 +# along with this program. If not, see <http://www.gnu.org/licenses/>. #
  19 +# #
  20 +#############################################################################
2 21  
3 22 # Set include directories
4 23 INCLUDES = -I$(top_srcdir)/src/support
... ... @@ -7,7 +26,7 @@ INCLUDES = -I$(top_srcdir)/src/support
7 26 bin_PROGRAMS = cttsmap
8 27  
9 28 # Sources
10   -sources = cttsmap.cpp
  29 +sources = cttsmap.cpp cttsmap.hpp
11 30  
12 31 # Libtool library
13 32 noinst_LTLIBRARIES = libcttsmap.la
... ... @@ -18,8 +37,11 @@ libcttsmap_la_LDFLAGS = @OPENMP_LIB_LDFLAGS@
18 37 cttsmap_SOURCES = main.cpp
19 38 cttsmap_LDFLAGS = $(LIB_LINK_OPTION) @LDFLAGS@
20 39 cttsmap_CPPFLAGS = @CPPFLAGS@
21   -cttsmap_LDADD = libcttsmap.la $(top_srcdir)/src/support/libsupport.la
  40 +cttsmap_LDADD = libcttsmap.la $(top_builddir)/src/support/libsupport.la
22 41  
23 42 # Parameter files
24 43 pfilesdir = $(prefix)/syspfiles
25   -pfiles_DATA = cttsmap.par
  44 +pfiles_DATA = $(srcdir)/cttsmap.par
  45 +
  46 +# Extra files to be distributed in the tar file
  47 +EXTRA_DIST = $(pfiles_DATA)
... ...
src/ctulimit/Makefile.am
1   -## Process this file with automake to produce Makefile.in
  1 +#############################################################################
  2 +# Makefile.am for ctulimit tool #
  3 +# ------------------------------------------------------------------------- #
  4 +# Copyright (C) 2016 Juergen Knoedlseder #
  5 +# ------------------------------------------------------------------------- #
  6 +# #
  7 +# This program is free software: you can redistribute it and/or modify #
  8 +# it under the terms of the GNU General Public License as published by #
  9 +# the Free Software Foundation, either version 3 of the License, or #
  10 +# (at your option) any later version. #
  11 +# #
  12 +# This program is distributed in the hope that it will be useful, #
  13 +# but WITHOUT ANY WARRANTY; without even the implied warranty of #
  14 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
  15 +# GNU General Public License for more details. #
  16 +# #
  17 +# You should have received a copy of the GNU General Public License #
  18 +# along with this program. If not, see <http://www.gnu.org/licenses/>. #
  19 +# #
  20 +#############################################################################
2 21  
3 22 # Set include directories
4 23 INCLUDES = -I$(top_srcdir)/src/support
... ... @@ -7,7 +26,7 @@ INCLUDES = -I$(top_srcdir)/src/support
7 26 bin_PROGRAMS = ctulimit
8 27  
9 28 # Sources
10   -sources = ctulimit.cpp
  29 +sources = ctulimit.cpp ctulimit.hpp
11 30  
12 31 # Libtool library
13 32 noinst_LTLIBRARIES = libctulimit.la
... ... @@ -18,8 +37,11 @@ libctulimit_la_LDFLAGS = @OPENMP_LIB_LDFLAGS@
18 37 ctulimit_SOURCES = main.cpp
19 38 ctulimit_LDFLAGS = $(LIB_LINK_OPTION) @LDFLAGS@
20 39 ctulimit_CPPFLAGS = @CPPFLAGS@
21   -ctulimit_LDADD = libctulimit.la $(top_srcdir)/src/support/libsupport.la
  40 +ctulimit_LDADD = libctulimit.la $(top_builddir)/src/support/libsupport.la
22 41  
23 42 # Parameter files
24 43 pfilesdir = $(prefix)/syspfiles
25   -pfiles_DATA = ctulimit.par
  44 +pfiles_DATA = $(srcdir)/ctulimit.par
  45 +
  46 +# Extra files to be distributed in the tar file
  47 +EXTRA_DIST = $(pfiles_DATA)
... ...
src/support/Makefile.am
1   -## Process this file with automake to produce Makefile.in
  1 +#############################################################################
  2 +# Makefile.am for ctool base class #
  3 +# ------------------------------------------------------------------------- #
  4 +# Copyright (C) 2016 Juergen Knoedlseder #
  5 +# ------------------------------------------------------------------------- #
  6 +# #
  7 +# This program is free software: you can redistribute it and/or modify #
  8 +# it under the terms of the GNU General Public License as published by #
  9 +# the Free Software Foundation, either version 3 of the License, or #
  10 +# (at your option) any later version. #
  11 +# #
  12 +# This program is distributed in the hope that it will be useful, #
  13 +# but WITHOUT ANY WARRANTY; without even the implied warranty of #
  14 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
  15 +# GNU General Public License for more details. #
  16 +# #
  17 +# You should have received a copy of the GNU General Public License #
  18 +# along with this program. If not, see <http://www.gnu.org/licenses/>. #
  19 +# #
  20 +#############################################################################
2 21  
3 22 # Define sources for this directory
4   -sources = ctool.cpp
  23 +sources = ctool.cpp ctool.hpp
5 24  
6 25 # Build libtool library
7 26 noinst_LTLIBRARIES = libsupport.la
... ...
test/Makefile.am
1   -## Process this file with automake to produce Makefile.in
  1 +#############################################################################
  2 +# Makefile.am for ctools unit tests #
  3 +# ------------------------------------------------------------------------- #
  4 +# Copyright (C) 2016 Juergen Knoedlseder #
  5 +# ------------------------------------------------------------------------- #
  6 +# #
  7 +# This program is free software: you can redistribute it and/or modify #
  8 +# it under the terms of the GNU General Public License as published by #
  9 +# the Free Software Foundation, either version 3 of the License, or #
  10 +# (at your option) any later version. #
  11 +# #
  12 +# This program is distributed in the hope that it will be useful, #
  13 +# but WITHOUT ANY WARRANTY; without even the implied warranty of #
  14 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
  15 +# GNU General Public License for more details. #
  16 +# #
  17 +# You should have received a copy of the GNU General Public License #
  18 +# along with this program. If not, see <http://www.gnu.org/licenses/>. #
  19 +# #
  20 +#############################################################################
2 21  
3 22 # Darwin support
4 23 MACOSX_DEPLOYMENT_TARGET=@CONFIGURE_MACOSX_DEPLOYMENT_TARGET@
... ... @@ -6,7 +25,6 @@ MACOSX_DEPLOYMENT_TARGET=@CONFIGURE_MACOSX_DEPLOYMENT_TARGET@
6 25  
7 26 # Optional python bindings
8 27 if WITH_PYTHON
9   - TEST_CSCRIPTS = test_cscripts.sh
10 28 TEST_PYTHON_CTOOLS = test_python_ctools.sh
11 29 TEST_PYTHON_CSCRIPTS = test_python_cscripts.sh
12 30 TEST_PYTHON_EXAMPLES = test_examples.py
... ... @@ -15,13 +33,44 @@ endif
15 33  
16 34 # Set test environment
17 35 TESTS_ENVIRONMENT = @RUNSHARED@=$(top_builddir)/src/.libs$(TEST_ENV_DIR):$(LIBDIR_GAMMALIB):$(@RUNSHARED@) \
18   - $(TEST_PYTHON_ENV)
  36 + $(TEST_PYTHON_ENV) \
  37 + TEST_SRCDIR=$(abs_top_srcdir) \
  38 + TEST_BUILDDIR=$(abs_top_builddir) \
  39 + TEST_DATA=$(abs_top_srcdir)/test/data
19 40  
20 41 # Tests (these are the tests to be executed)
21 42 TESTS = $(TEST_PYTHON_CTOOLS) \
22 43 $(TEST_PYTHON_CSCRIPTS) \
23 44 $(TEST_PYTHON_EXAMPLES)
24 45  
  46 +# Create report directory
  47 +all-local:
  48 + mkdir -p reports
  49 +
  50 +# Files to be removed in build directory
  51 +clean-local:
  52 + rm -rf $(builddir)/*.fits
  53 + rm -rf $(builddir)/*.log
  54 + rm -rf $(builddir)/*.xml
  55 + rm -rf $(builddir)/*.eps
  56 + rm -rf $(builddir)/*.dat
  57 + rm -rf $(builddir)/*.reg
  58 + rm -rf $(builddir)/reports/*.xml
  59 + rm -rf $(builddir)/caldb
  60 + rm -rf $(builddir)/pfiles
  61 + rm -rf $(builddir)/prod3
  62 + rm -rf $(builddir)/csroot2caldb_*
  63 + rm -rf $(builddir)/iactdata_*
  64 +
  65 +# Tests to be done on installed version
  66 +if WITH_PYTHON
  67 +installcheck-local:
  68 + @export CTOOLS=$(DESTDIR)$(prefix); \
  69 + . $(DESTDIR)$(prefix)/bin/ctools-init.sh; \
  70 + python -c 'import ctools; ctools.test()'; \
  71 + python -c 'import cscripts; cscripts.test()'
  72 +endif
  73 +
25 74 # Add Valgrind rule
26 75 valgrind:
27 76 @if type valgrind >/dev/null 2>&1; then \
... ...
test/data/iactdata/events.fits.gz 0 → 100644
No preview for this file type
test/data/iactdata/hdu-index.fits.gz 0 → 100644
No preview for this file type
test/irf/irf_file.fits.gz renamed to test/data/iactdata/irf_file.fits.gz
No preview for this file type
test/iactdata/master.json renamed to test/data/iactdata/master.json
test/iactdata/obs-index.fits.gz renamed to test/data/iactdata/obs-index.fits.gz
No preview for this file type
test/data/irf_file.fits.gz 0 → 100644
No preview for this file type
test/data/models.txt
1   -data/model_cube_background.xml
2   -data/model_cube_background2.xml
  1 +model_cube_background.xml
  2 +model_cube_background2.xml
... ...
test/data/obs_unbinned.xml
... ... @@ -2,9 +2,9 @@
2 2 <observation_list title="observation list">
3 3 <observation name="" id="00001" instrument="CTA">
4 4 <parameter name="EventList" file="crab_events.fits" />
5   - <parameter name="EffectiveArea" file="irf/irf_file.fits" />
6   - <parameter name="PointSpreadFunction" file="irf/irf_file.fits" />
7   - <parameter name="EnergyDispersion" file="irf/irf_file.fits" />
8   - <parameter name="Background" file="irf/irf_file.fits" />
  5 + <parameter name="EffectiveArea" file="$(TEST_DATA)/irf_file.fits" />
  6 + <parameter name="PointSpreadFunction" file="$(TEST_DATA)/irf_file.fits" />
  7 + <parameter name="EnergyDispersion" file="$(TEST_DATA)/irf_file.fits" />
  8 + <parameter name="Background" file="$(TEST_DATA)/irf_file.fits" />
9 9 </observation>
10 10 </observation_list>
... ...
test/data/tsmaps.txt
1   -data/tsmap_0.fits
2   -data/tsmap_1.fits
  1 +tsmap_0.fits
  2 +tsmap_1.fits
... ...
test/data/workflow.xml
... ... @@ -2,9 +2,9 @@
2 2 <workflow>
3 3 <actor name="input">
4 4 <output>
5   - <parameter name="inmodel" value="data/crab.xml" />
6   - <parameter name="caldb" value="irf" />
7   - <parameter name="irf" value="cta_dummy_irf" />
  5 + <parameter name="inmodel" value="$(TEST_DATA)/crab.xml" />
  6 + <parameter name="caldb" value="prod2" />
  7 + <parameter name="irf" value="South_0.5h" />
8 8 <parameter name="edisp" value="no" />
9 9 <parameter name="deadc" value="0.95" />
10 10 <parameter name="ra" value="83.63" />
... ...
test/iactdata/hdu-index.fits.gz deleted
No preview for this file type
test/irf/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.
test/test_cscripts.sh.in deleted
1   -#! /bin/sh
2   -# ==========================================================================
3   -# This script tests all cscripts that are shipped with ctools
4   -#
5   -# Copyright (C) 2011-2016 Juergen Knoedlseder
6   -#
7   -# This program is free software: you can redistribute it and/or modify
8   -# it under the terms of the GNU General Public License as published by
9   -# the Free Software Foundation, either version 3 of the License, or
10   -# (at your option) any later version.
11   -#
12   -# This program is distributed in the hope that it will be useful,
13   -# but WITHOUT ANY WARRANTY; without even the implied warranty of
14   -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15   -# GNU General Public License for more details.
16   -#
17   -# You should have received a copy of the GNU General Public License
18   -# along with this program. If not, see <http://www.gnu.org/licenses/>.
19   -#
20   -# ==========================================================================
21   -
22   -#
23   -# Get echo command (to circumvent built-in echo on some systems)
24   -#
25   -ECHO=`which echo`
26   -
27   -#
28   -# Print Header
29   -#
30   -$ECHO ""
31   -$ECHO "*****************"
32   -$ECHO "* Test cscripts *"
33   -$ECHO "*****************"
34   -
35   -
36   -#
37   -# Remove any existing result files
38   -# ================================
39   -rm -rf *.fits *.xml *.dat *.reg .coverage
40   -
41   -
42   -#
43   -# Creates pfiles directory
44   -# ========================
45   -export PFILES=pfiles
46   -export CALDB=$PWD/caldb
47   -rm -rf $PFILES
48   -mkdir -p $PFILES
49   -cp -r ../src/*/*.par pfiles/
50   -cp -r ../cscripts/*.par pfiles/
51   -rm -rf $CALDB
52   -mkdir -p $CALDB
53   -
54   -
55   -#
56   -# Test cscaldb
57   -# ============
58   -$ECHO -n "Test cscaldb: "
59   -chmod +x @abs_top_srcdir@/cscripts/cscaldb.py
60   -@PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/cscaldb.py \
61   - chatter=4 > cscaldb.log
62   -$ECHO -n "."
63   -if [ -s "cscaldb.log" ]
64   -then
65   - $ECHO -n "."
66   -else
67   - $ECHO " cscaldb.log file is not valid"
68   - exit 1
69   -fi
70   -$ECHO " ok"
71   -
72   -
73   -#
74   -# Test csobs2caldb
75   -# ================
76   -$ECHO -n "Test csobs2caldb: "
77   -chmod +x @abs_top_srcdir@/cscripts/csobs2caldb.py
78   -@PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/csobs2caldb.py \
79   - inobs="data/obs_unbinned.xml" \
80   - caldb="cta" \
81   - irf="Standard" \
82   - chatter=4 > csobs2caldb.log
83   -$ECHO -n "."
84   -if [ -s "$CALDB/data/cta/cta/bcf/Standard/irf_file.fits" ]
85   -then
86   - $ECHO -n "."
87   -else
88   - $ECHO " $CALDB/data/cta/cta/bcf/Standard/irf_file.fits file is not valid"
89   - exit 1
90   -fi
91   -$ECHO " ok"
92   -
93   -
94   -#
95   -# Test csobsdef
96   -# =============
97   -$ECHO -n "Test csobsdef: "
98   -chmod +x @abs_top_srcdir@/cscripts/csobsdef.py
99   -@PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/csobsdef.py \
100   - inpnt="data/pntdef.dat" \
101   - outobs="obs.xml" \
102   - caldb="irf" \
103   - irf="cta_dummy_irf" \
104   - emin=0.1 \
105   - emax=100.0 \
106   - duration=1800.0 \
107   - rad=5.0 > csobsdef.log
108   -$ECHO -n "."
109   -if [ -s "obs.xml" ]
110   -then
111   - $ECHO -n "."
112   -else
113   - $ECHO " obs.xml file is not valid"
114   - exit 1
115   -fi
116   -$ECHO " ok"
117   -
118   -
119   -#
120   -# Test csobsinfo
121   -# ==============
122   -$ECHO -n "Test csobsinfo: "
123   -chmod +x @abs_top_srcdir@/cscripts/csobsinfo.py
124   -@PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/csobsinfo.py \
125   - inobs="obs.xml" \
126   - ds9file="obs.reg" \
127   - offset=yes \
128   - ra="83.6331" \
129   - dec="22.01" > csobsinfo.log
130   -$ECHO -n "."
131   -if [ -s "obs.reg" ]
132   -then
133   - $ECHO -n "."
134   -else
135   - $ECHO " obs.reg file is not valid"
136   - exit 1
137   -fi
138   -$ECHO " ok"
139   -
140   -
141   -#
142   -# Test csmodelinfo
143   -# ================
144   -$ECHO -n "Test csmodelinfo: "
145   -chmod +x @abs_top_srcdir@/cscripts/csmodelinfo.py
146   -@PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/csmodelinfo.py \
147   - inmodel="data/crab.xml" \
148   - ds9file="model.reg" > csmodelinfo.log
149   -$ECHO -n "."
150   -if [ -s "model.reg" ]
151   -then
152   - $ECHO -n "."
153   -else
154   - $ECHO " model.reg file is not valid"
155   - exit 1
156   -fi
157   -$ECHO " ok"
158   -
159   -
160   -#
161   -# Test csmodelmerge
162   -# =================
163   -$ECHO -n "Test csmodelmerge: "
164   -# === space-separated ===
165   -chmod +x @abs_top_srcdir@/cscripts/csmodelmerge.py
166   -@PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/csmodelmerge.py \
167   - inmodels="data/crab.xml data/source1.xml" \
168   - outmodel="merged_models.xml" > csmodelmerge.log
169   -$ECHO -n "."
170   -if [ -s "merged_models.xml" ]
171   -then
172   - $ECHO -n "."
173   -else
174   - $ECHO " merged_models.xml file is not valid"
175   - exit 1
176   -fi
177   -# === semi-colon separated ===
178   -@PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/csmodelmerge.py \
179   - inmodels="data/crab.xml;data/source1.xml" \
180   - outmodel="merged_models2.xml" > csmodelmerge.log
181   -$ECHO -n "."
182   -if [ -s "merged_models2.xml" ]
183   -then
184   - $ECHO -n "."
185   -else
186   - $ECHO " merged_models2.xml file is not valid"
187   - exit 1
188   -fi
189   -# === wildcard string ===
190   -@PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/csmodelmerge.py \
191   - inmodels="data/model_cube_background*.xml" \
192   - outmodel="merged_models3.xml" > csmodelmerge.log
193   -$ECHO -n "."
194   -if [ -s "merged_models3.xml" ]
195   -then
196   - $ECHO -n "."
197   -else
198   - $ECHO " merged_models3.xml file is not valid"
199   - exit 1
200   -fi
201   -# === ascii-file ===
202   -ls data/model_cube_background* > models.txt
203   -@PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/csmodelmerge.py \
204   - inmodels="@models.txt" \
205   - outmodel="merged_models4.xml" > csmodelmerge.log
206   -$ECHO -n "."
207   -if [ -s "merged_models4.xml" ]
208   -then
209   - $ECHO -n "."
210   -else
211   - $ECHO " merged_models4.xml file is not valid"
212   - exit 1
213   -fi
214   -$ECHO " ok"
215   -rm models.txt
216   -
217   -
218   -#
219   -# Test cstsmapmerge
220   -# =================
221   -$ECHO -n "Test cstsmapmerge: "
222   -# === semi-colon separated ===
223   -chmod +x @abs_top_srcdir@/cscripts/cstsmapmerge.py
224   -@PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/cstsmapmerge.py \
225   - inmaps="data/tsmap_0.fits;data/tsmap_1.fits" \
226   - outmap="merged_tsmap1.fits" > cstsmapmerge.log
227   -$ECHO -n "."
228   -if [ -s "merged_tsmap1.fits" ]
229   -then
230   - $ECHO -n "."
231   -else
232   - $ECHO " merged_tsmap1.fits file is not valid"
233   - exit 1
234   -fi
235   -# === space-separated ===
236   -@PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/cstsmapmerge.py \
237   - inmaps="data/tsmap_0.fits data/tsmap_1.fits" \
238   - outmap="merged_tsmap2.fits" > cstsmapmerge.log
239   -$ECHO -n "."
240   -if [ -s "merged_tsmap2.fits" ]
241   -then
242   - $ECHO -n "."
243   -else
244   - $ECHO " merged_tsmap2.fits file is not valid"
245   - exit 1
246   -fi
247   -# === wildcard string ===
248   -@PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/cstsmapmerge.py \
249   - inmaps="data/tsmap_*.fits" \
250   - outmap="merged_tsmap3.fits" > cstsmapmerge.log
251   -$ECHO -n "."
252   -if [ -s "merged_tsmap3.fits" ]
253   -then
254   - $ECHO -n "."
255   -else
256   - $ECHO " merged_tsmap3.fits file is not valid"
257   - exit 1
258   -fi
259   -# === ascii-file ===
260   -#ls data/tsmap_*.fits > tsmaps.txt
261   -@PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/cstsmapmerge.py \
262   - inmaps="@data/tsmaps.txt" \
263   - outmap="merged_tsmap4.fits" > cstsmapmerge.log
264   -$ECHO -n "."
265   -if [ -s "merged_tsmap4.fits" ]
266   -then
267   - $ECHO -n "."
268   -else
269   - $ECHO " merged_tsmap4.fits file is not valid"
270   - exit 1
271   -fi
272   -$ECHO " ok"
273   -rm tsmaps.txt
274   -
275   -
276   -#
277   -# Test cspull
278   -# ===========
279   -$ECHO -n "Test cspull: "
280   -chmod +x @abs_top_srcdir@/cscripts/cspull.py
281   -@PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/cspull.py \
282   - inmodel="data/crab.xml" \
283   - outfile="pull.dat" \
284   - ntrials="3" \
285   - caldb="cta" \
286   - irf="Standard" \
287   - ra=83.6331 \
288   - dec=22.0145 \
289   - emin=0.1 \
290   - emax=100.0 \
291   - enumbins=0 \
292   - tmax=1800.0 \
293   - deadc=0.95 \
294   - rad=5.0 \
295   - npix=200 \
296   - debug=yes \
297   - binsz=0.05 > cspull.log
298   -$ECHO -n "."
299   -if [ -s "pull.dat" ]
300   -then
301   - $ECHO -n "."
302   -else
303   - $ECHO " pull.dat file is not valid"
304   - exit 1
305   -fi
306   -$ECHO " ok"
307   -
308   -
309   -#
310   -# Test cssens
311   -# ===========
312   -$ECHO -n "Test cssens: "
313   -chmod +x @abs_top_srcdir@/cscripts/cssens.py
314   -@PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/cssens.py \
315   - inmodel="data/crab.xml" \
316   - srcname="Crab" \
317   - caldb="irf" \
318   - irf="cta_dummy_irf" \
319   - duration=1800.0 \
320   - rad=3.0 \
321   - emin=1.0 \
322   - emax=10.0 \
323   - bins=1 > cssens.log
324   -$ECHO -n "."
325   -if [ -s "sensitivity.dat" ]
326   -then
327   - $ECHO -n "."
328   -else
329   - $ECHO " sensitivity.dat file is not valid"
330   - exit 1
331   -fi
332   -$ECHO " ok"
333   -
334   -
335   -#
336   -# Test cstsdist
337   -# =============
338   -$ECHO -n "Test cstsdist: "
339   -chmod +x @abs_top_srcdir@/cscripts/cstsdist.py
340   -@PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/cstsdist.py \
341   - inmodel="data/crab.xml" \
342   - srcname="Crab" \
343   - outfile="ts.dat" \
344   - ntrials="1" \
345   - caldb="irf" \
346   - irf="cta_dummy_irf" \
347   - ra=83.63 \
348   - dec=22.01 \
349   - emin=0.1 \
350   - emax=100.0 \
351   - enumbins=0 \
352   - tmax=1800.0 \
353   - rad=5.0 \
354   - npix=200 \
355   - binsz=0.05 > cstsdist.log
356   -$ECHO -n "."
357   -if [ -s "ts.dat" ]
358   -then
359   - $ECHO -n "."
360   -else
361   - $ECHO " ts.dat file is not valid"
362   - exit 1
363   -fi
364   -$ECHO " ok"
365   -
366   -
367   -#
368   -# Test csresmap
369   -# =============
370   -$ECHO -n "Test csresmap: "
371   -chmod +x @abs_top_srcdir@/cscripts/csresmap.py
372   -@PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/csresmap.py \
373   - inobs="data/crab_events.fits" \
374   - outmap="resmap.fits" \
375   - inmodel="data/crab.xml" \
376   - caldb="irf" \
377   - irf="cta_dummy_irf" \
378   - nxpix=50 \
379   - nypix=50 \
380   - binsz=0.02 \
381   - coordsys="CEL" \
382   - xref=83.63 \
383   - yref=22.01 \
384   - proj="CAR" \
385   - binsz=0.05 \
386   - algorithm="SUBDIV" > csresmap.log
387   -$ECHO -n "."
388   -if [ -s "resmap.fits" ]
389   -then
390   - $ECHO -n "."
391   -else
392   - $ECHO " resmap.fits file is not valid"
393   - exit 1
394   -fi
395   -$ECHO " ok"
396   -
397   -
398   -#
399   -# Test csspec
400   -# ===========
401   -$ECHO -n "Test csspec: "
402   -# === Unbinned ===
403   -chmod +x @abs_top_srcdir@/cscripts/csspec.py
404   -@PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/csspec.py \
405   - inobs="data/crab_events.fits" \
406   - inmodel="data/crab.xml" \
407   - caldb="irf" \
408   - irf="cta_dummy_irf" \
409   - ebinalg="LOG" \
410   - enumbins=5 \
411   - srcname="Crab" \
412   - emin=0.1 \
413   - emax=100.0 \
414   - outfile="spectrum.fits" > csspec.log
415   -$ECHO -n "."
416   -if [ -s "spectrum.fits" ]
417   -then
418   - $ECHO -n "."
419   -else
420   - $ECHO " spectrum.fits file is not valid"
421   - exit 1
422   -fi
423   -# === Binned ===
424   -@PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/csspec.py \
425   - inobs="data/crab_cntmap_small.fits.gz" \
426   - expcube="data/crab_expcube.fits.gz" \
427   - psfcube="data/crab_psfcube.fits.gz" \
428   - edispcube="data/crab_edispcube.fits.gz" \
429   - bkgcube="data/crab_bkgcube.fits.gz" \
430   - inmodel="data/crab_bkgcube.xml" \
431   - ebinalg="LOG" \
432   - enumbins=2 \
433   - emin=0.1 \
434   - emax=100.0 \
435   - srcname="Crab" \
436   - outfile="spectrum_binned.fits" > csspec.log
437   -$ECHO -n "."
438   -if [ -s "spectrum_binned.fits" ]
439   -then
440   - $ECHO -n "."
441   -else
442   - $ECHO " spectrum_binned.fits file is not valid"
443   - exit 1
444   -fi
445   -$ECHO " ok"
446   -
447   -
448   -#
449   -# Test cslightcrv
450   -# ===============
451   -$ECHO -n "Test cslightcrv: "
452   -# === unbinned ===
453   -chmod +x @abs_top_srcdir@/cscripts/cslightcrv.py
454   -@PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/cslightcrv.py \
455   - inobs="data/crab_events.fits" \
456   - inmodel="data/crab.xml" \
457   - srcname="Crab" \
458   - caldb="irf" \
459   - irf="cta_dummy_irf" \
460   - tbinalg="LIN" \
461   - tmin=51544.5 \
462   - tmax=51544.53 \
463   - tbins=3 \
464   - enumbins=0 \
465   - emin=0.1 \
466   - emax=100.0 \
467   - outfile="lightcurve.fits" > cslightcrv.log
468   -$ECHO -n "."
469   -if [ -s "lightcurve.fits" ]
470   -then
471   - $ECHO -n "."
472   -else
473   - $ECHO " lightcurve.fits file is not valid"
474   - exit 1
475   -fi
476   -# === binned ===
477   -@PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/cslightcrv.py \
478   - inobs="data/crab_events.fits" \
479   - inmodel="data/crab.xml" \
480   - srcname="Crab" \
481   - caldb="irf" \
482   - irf="cta_dummy_irf" \
483   - tbinalg="GTI" \
484   - enumbins=2 \
485   - emin=0.1 \
486   - emax=100.0 \
487   - coordsys="CEL" \
488   - proj="CAR" \
489   - xref=83.63 \
490   - yref=22.01 \
491   - nxpix=10 \
492   - nypix=10 \
493   - binsz=0.1 \
494   - outfile="lightcurve_binned.fits" > cslightcrv.log
495   -$ECHO -n "."
496   -if [ -s "lightcurve_binned.fits" ]
497   -then
498   - $ECHO -n "."
499   -else
500   - $ECHO " lightcurve_binned.fits file is not valid"
501   - exit 1
502   -fi
503   -$ECHO " ok"
504   -
505   -
506   -#
507   -# Optional tests for Python 2.6++ (scripts needing json module)
508   -# =============================================================
509   -python_version=`echo @PYTHON_VERSION@ | sed 's/\(10\.[[0-9]]*\).*/\1/' | sed -e 's/\.//g'`
510   -if [ $python_version -ge 26 ]; then
511   -
512   - #
513   - # Test csfindobs
514   - # ==============
515   - $ECHO -n "Test csfindobs: "
516   - chmod +x @abs_top_srcdir@/cscripts/csfindobs.py
517   - @PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/csfindobs.py \
518   - datapath="iactdata/" \
519   - prodname="unit-test" \
520   - ra="83.6331" \
521   - dec="22.01" \
522   - rad="1.0" \
523   - outfile="iactrunlist.dat" > csfindobs.log
524   - $ECHO -n "."
525   - if [ -s "iactrunlist.dat" ]
526   - then
527   - $ECHO -n "."
528   - else
529   - $ECHO " iactdata/runlist.txt file is not valid"
530   - exit 1
531   - fi
532   - $ECHO " ok"
533   -
534   -
535   - #
536   - # Test csiactcopy
537   - # ===============
538   - $ECHO -n "Test csiactcopy: "
539   - chmod +x @abs_top_srcdir@/cscripts/csiactcopy.py
540   - @PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/csiactcopy.py \
541   - remote_master="iactdata/master.json" \
542   - outpath="iactdata_test" \
543   - prodname="unit-test" > csiactcopy.log
544   - $ECHO -n "."
545   - if [ -s "iactdata_test/master.json" ]
546   - then
547   - $ECHO -n "."
548   - else
549   - $ECHO " iactdata_test/master.json file is not valid"
550   - exit 1
551   - fi
552   - $ECHO " ok"
553   -
554   -
555   - #
556   - # Test csiactobs
557   - # ==============
558   - $ECHO -n "Test csiactobs: "
559   - chmod +x @abs_top_srcdir@/cscripts/csiactobs.py
560   - @PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/csiactobs.py \
561   - datapath="iactdata/" \
562   - prodname="unit-test" \
563   - infile="iactrunlist.dat" \
564   - bkgpars="1" \
565   - outobs="obs2.xml" \
566   - outmodel="bkgmodels.xml" > csiactobs.log
567   - $ECHO -n "."
568   - if [ -s "obs2.xml" ]
569   - then
570   - $ECHO -n "."
571   - else
572   - $ECHO " obs.xml file is not valid"
573   - exit 1
574   - fi
575   - $ECHO " ok"
576   -
577   -fi # Python 2.6+ specific tests
test/test_csfindobs.py
... ... @@ -42,6 +42,9 @@ class Test(test):
42 42 # Call base class constructor
43 43 test.__init__(self)
44 44  
  45 + # Set data members
  46 + self._datapath = self._datadir + '/iactdata'
  47 +
45 48 # Return
46 49 return
47 50  
... ... @@ -69,7 +72,7 @@ class Test(test):
69 72 csfindobs = self._script('csfindobs')
70 73  
71 74 # Setup csfindobs command
72   - cmd = csfindobs+' datapath="iactdata/"'+ \
  75 + cmd = csfindobs+' datapath="'+self._datapath+'"'+ \
73 76 ' prodname="unit-test"'+ \
74 77 ' ra=83.63 dec=22.01 rad=1.0'+ \
75 78 ' outfile="runlist_cmd1.dat"'+ \
... ... @@ -107,7 +110,7 @@ class Test(test):
107 110 """
108 111 # Set-up csfindobs
109 112 findobs = cscripts.csfindobs()
110   - findobs['datapath'] = 'iactdata/'
  113 + findobs['datapath'] = self._datapath
111 114 findobs['prodname'] = 'unit-test'
112 115 findobs['outfile'] = 'runlist_py1.dat'
113 116 findobs['ra'] = 83.63
... ...
test/test_csiactcopy.py
... ... @@ -42,6 +42,9 @@ class Test(test):
42 42 # Call base class constructor
43 43 test.__init__(self)
44 44  
  45 + # Set data members
  46 + self._remote = self._datadir + '/iactdata/master.json'
  47 +
45 48 # Return
46 49 return
47 50  
... ... @@ -69,7 +72,7 @@ class Test(test):
69 72 csiactcopy = self._script('csiactcopy')
70 73  
71 74 # Setup csiactcopy command
72   - cmd = csiactcopy+' remote_master="iactdata/master.json"'+ \
  75 + cmd = csiactcopy+' remote_master="'+self._remote+'"'+ \
73 76 ' prodname="unit-test"'+ \
74 77 ' outpath="iactdata_cmd1"'+ \
75 78 ' logfile="csiactcopy_cmd1.log" chatter=1'
... ... @@ -105,7 +108,7 @@ class Test(test):
105 108 """
106 109 # Set-up csiactcopy
107 110 findobs = cscripts.csiactcopy()
108   - findobs['remote_master'] = 'iactdata/master.json'
  111 + findobs['remote_master'] = self._remote
109 112 findobs['prodname'] = 'unit-test'
110 113 findobs['outpath'] = 'iactdata_py1'
111 114 findobs['logfile'] = 'csiactcopy_py1.log'
... ... @@ -134,17 +137,17 @@ class Test(test):
134 137  
135 138 # Check for existence of files
136 139 self.test_assert(hdu_index_name.exists(),
137   - 'Check is file "hdu-index.fits" exists.')
  140 + 'Check if file "hdu-index.fits" exists.')
138 141 self.test_assert(obs_index_name.exists(),
139   - 'Check is file "obs-index.fits" exists.')
  142 + 'Check if file "obs-index.fits" exists.')
140 143 self.test_assert(master_name.exists(),
141   - 'Check is file "master.json" exists.')
  144 + 'Check if file "master.json" exists.')
142 145  
143 146 # Check if index files are FITS file
144 147 self.test_assert(hdu_index_name.is_fits(),
145   - 'Check is file "hdu-index.fits" is FITS file.')
  148 + 'Check if file "hdu-index.fits" is FITS file.')
146 149 self.test_assert(obs_index_name.is_fits(),
147   - 'Check is file "obs-index.fits" is FITS file.')
  150 + 'Check if file "obs-index.fits" is FITS file.')
148 151  
149 152 # Return
150 153 return
... ...
test/test_csiactdata.py
... ... @@ -42,6 +42,9 @@ class Test(test):
42 42 # Call base class constructor
43 43 test.__init__(self)
44 44  
  45 + # Set data members
  46 + self._datapath = self._datadir + '/iactdata'
  47 +
45 48 # Return
46 49 return
47 50  
... ... @@ -69,7 +72,7 @@ class Test(test):
69 72 csiactdata = self._script('csiactdata')
70 73  
71 74 # Setup csiactdata command
72   - cmd = csiactdata+' datapath="iactdata"'+ \
  75 + cmd = csiactdata+' datapath="'+self._datapath+'"'+ \
73 76 ' logfile="csiactdata_cmd1.log" chatter=1'
74 77  
75 78 # Check if execution of wrong command fails
... ... @@ -98,7 +101,7 @@ class Test(test):
98 101 """
99 102 # Set-up csiactdata
100 103 iactdata = cscripts.csiactdata()
101   - iactdata['datapath'] = 'iactdata'
  104 + iactdata['datapath'] = self._datapath
102 105 iactdata['logfile'] = 'csiactdata_py1.log'
103 106 iactdata['chatter'] = 2
104 107  
... ...
test/test_csiactobs.py
... ... @@ -42,6 +42,9 @@ class Test(test):
42 42 # Call base class constructor
43 43 test.__init__(self)
44 44  
  45 + # Set data members
  46 + self._datapath = self._datadir + '/iactdata'
  47 +
45 48 # Return
46 49 return
47 50  
... ... @@ -69,7 +72,7 @@ class Test(test):
69 72 csiactobs = self._script('csiactobs')
70 73  
71 74 # Setup csiactobs command
72   - cmd = csiactobs+' datapath="iactdata"'+ \
  75 + cmd = csiactobs+' datapath="'+self._datapath+'"'+ \
73 76 ' prodname="unit-test"'+ \
74 77 ' infile="runlist_cmd1.dat"'+ \
75 78 ' bkgpars=1'+\
... ... @@ -114,7 +117,7 @@ class Test(test):
114 117 """
115 118 # Set-up csiactobs
116 119 iactobs = cscripts.csiactobs()
117   - iactobs['datapath'] = 'iactdata'
  120 + iactobs['datapath'] = self._datapath
118 121 iactobs['prodname'] = 'unit-test'
119 122 iactobs['infile'] = 'runlist_py1.dat'
120 123 iactobs['bkgpars'] = 1
... ... @@ -151,7 +154,7 @@ class Test(test):
151 154 # Check number of observations
152 155 self.test_value(obs.size(), 1,
153 156 'Check for single observation in XML file')
154   - self.test_assert(obs[0].eventfile().file() == 'crab_events.fits.gz',
  157 + self.test_assert(obs[0].eventfile().file() == 'events.fits.gz',
155 158 'Check event file name')
156 159 self.test_assert(obs[0].eventfile().extname() == 'EVENTS',
157 160 'Check event extension name')
... ...
test/test_cslightcrv.py
... ... @@ -42,10 +42,6 @@ class Test(test):
42 42 # Call base class constructor
43 43 test.__init__(self)
44 44  
45   - # Set members
46   - self._events_name = 'data/crab_events.fits'
47   - self._model_name = 'data/crab.xml'
48   -
49 45 # Return
50 46 return
51 47  
... ... @@ -73,9 +69,9 @@ class Test(test):
73 69 cslightcrv = self._script('cslightcrv')
74 70  
75 71 # Setup cslightcrv command
76   - cmd = cslightcrv+' inobs="'+self._events_name+'"'+ \
77   - ' inmodel="'+self._model_name+'"'+ \
78   - ' srcname="Crab" caldb="prod2" irf="South_0.5h"'+ \
  72 + cmd = cslightcrv+' inobs="'+self._events+'"'+ \
  73 + ' inmodel="'+self._model+'" srcname="Crab"'+ \
  74 + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \
79 75 ' tbinalg="LIN" tmin=51544.50 tmax=51544.53'+ \
80 76 ' tbins=3 enumbins=0 emin=0.1 emax=100.0'+ \
81 77 ' outfile="lightcurve_cmd1.fits"'+ \
... ... @@ -94,8 +90,8 @@ class Test(test):
94 90  
95 91 # Setup cslightcrv command
96 92 cmd = cslightcrv+' inobs="events_that_do_not_exist.fits"'+ \
97   - ' inmodel="'+self._model_name+'"'+ \
98   - ' srcname="Crab" caldb="prod2" irf="South_0.5h"'+ \
  93 + ' inmodel="'+self._model+'" srcname="Crab"'+ \
  94 + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \
99 95 ' tbinalg="LIN" tmin=51544.50 tmax=51544.53'+ \
100 96 ' tbins=3 enumbins=0 emin=0.1 emax=100.0'+ \
101 97 ' outfile="lightcurve_cmd1.fits"'+ \
... ... @@ -115,11 +111,11 @@ class Test(test):
115 111 """
116 112 # Set-up unbinned cslightcrv
117 113 lcrv = cscripts.cslightcrv()
118   - lcrv['inobs'] = self._events_name
119   - lcrv['inmodel'] = self._model_name
  114 + lcrv['inobs'] = self._events
  115 + lcrv['inmodel'] = self._model
120 116 lcrv['srcname'] = 'Crab'
121   - lcrv['caldb'] = 'prod2'
122   - lcrv['irf'] = 'South_0.5h'
  117 + lcrv['caldb'] = self._caldb
  118 + lcrv['irf'] = self._irf
123 119 lcrv['tbinalg'] = 'LIN'
124 120 lcrv['tmin'] = 51544.50
125 121 lcrv['tmax'] = 51544.53
... ... @@ -152,11 +148,11 @@ class Test(test):
152 148  
153 149 # Set-up unbinned cslightcrv
154 150 lcrv = cscripts.cslightcrv()
155   - lcrv['inobs'] = self._events_name
156   - lcrv['inmodel'] = self._model_name
  151 + lcrv['inobs'] = self._events
  152 + lcrv['inmodel'] = self._model
157 153 lcrv['srcname'] = 'Crab'
158   - lcrv['caldb'] = 'prod2'
159   - lcrv['irf'] = 'South_0.5h'
  154 + lcrv['caldb'] = self._caldb
  155 + lcrv['irf'] = self._irf
160 156 lcrv['tbinalg'] = 'FILE'
161 157 lcrv['tbinfile'] = 'cslightcrv_py2.dat'
162 158 lcrv['enumbins'] = 0
... ... @@ -176,17 +172,17 @@ class Test(test):
176 172 # Now we setup an observation container on input. We attached the
177 173 # model to the observation container so that cslightcrv should
178 174 # no longer query for the parameter.
179   - cta = gammalib.GCTAObservation(self._events_name)
  175 + cta = gammalib.GCTAObservation(self._events)
180 176 obs = gammalib.GObservations()
181 177 obs.append(cta)
182   - obs.models(self._model_name)
  178 + obs.models(self._model)
183 179  
184 180 # Set-up unbinned cslightcrv from observation container. Now use
185 181 # the GTI algorithm so that we test all timing algorithms.
186 182 lcrv = cscripts.cslightcrv(obs)
187 183 lcrv['srcname'] = 'Crab'
188   - lcrv['caldb'] = 'prod2'
189   - lcrv['irf'] = 'South_0.5h'
  184 + lcrv['caldb'] = self._caldb
  185 + lcrv['irf'] = self._irf
190 186 lcrv['tbinalg'] = 'GTI'
191 187 lcrv['enumbins'] = 0
192 188 lcrv['emin'] = 0.1
... ... @@ -203,11 +199,11 @@ class Test(test):
203 199  
204 200 # Finally we set-up a binned cslightcrv
205 201 lcrv = cscripts.cslightcrv()
206   - lcrv['inobs'] = self._events_name
207   - lcrv['inmodel'] = self._model_name
  202 + lcrv['inobs'] = self._events
  203 + lcrv['inmodel'] = self._model
208 204 lcrv['srcname'] = 'Crab'
209   - lcrv['caldb'] = 'prod2'
210   - lcrv['irf'] = 'South_0.5h'
  205 + lcrv['caldb'] = self._caldb
  206 + lcrv['irf'] = self._irf
211 207 lcrv['tbinalg'] = 'LIN'
212 208 lcrv['tmin'] = 51544.50
213 209 lcrv['tmax'] = 51544.53
... ...
test/test_csmodelinfo.py
... ... @@ -37,14 +37,11 @@ class Test(test):
37 37 # Constructor
38 38 def __init__(self):
39 39 """
40   - Constructor.
  40 + Constructor
41 41 """
42 42 # Call base class constructor
43 43 test.__init__(self)
44 44  
45   - # Set members
46   - self._model_name = "data/crab.xml"
47   -
48 45 # Return
49 46 return
50 47  
... ... @@ -72,7 +69,7 @@ class Test(test):
72 69 csmodelinfo = self._script('csmodelinfo')
73 70  
74 71 # Setup csmodelinfo command
75   - cmd = csmodelinfo+' inmodel="'+self._model_name+'"'+ \
  72 + cmd = csmodelinfo+' inmodel="'+self._model+'"'+ \
76 73 ' ds9file="model_cmd1.reg"'+ \
77 74 ' logfile="csmodelinfo_cmd1.log" chatter=1'
78 75  
... ... @@ -106,7 +103,7 @@ class Test(test):
106 103 """
107 104 # Set-up csmodelinfo
108 105 modelinfo = cscripts.csmodelinfo()
109   - modelinfo['inmodel'] = self._model_name
  106 + modelinfo['inmodel'] = self._model
110 107 modelinfo['ds9file'] = 'csmodelinfo_py1.reg'
111 108 modelinfo['logfile'] = 'csmodelinfo_py1.log'
112 109 modelinfo['chatter'] = 2
... ... @@ -121,7 +118,7 @@ class Test(test):
121 118  
122 119 # Set-up csmodelinfo
123 120 modelinfo = cscripts.csmodelinfo()
124   - modelinfo['inmodel'] = self._model_name
  121 + modelinfo['inmodel'] = self._model
125 122 modelinfo['ds9file'] = 'csmodelinfo_py2.reg'
126 123 modelinfo['logfile'] = 'csmodelinfo_py2.log'
127 124 modelinfo['chatter'] = 3
... ...
test/test_csmodelmerge.py
... ... @@ -42,6 +42,12 @@ class Test(test):
42 42 # Call base class constructor
43 43 test.__init__(self)
44 44  
  45 + # Set members
  46 + self._model1 = self._datadir + '/crab.xml'
  47 + self._model2 = self._datadir + '/model_cube_background.xml'
  48 + self._model3 = self._datadir + '/model_cube_background*.xml'
  49 + self._model4 = '@' + self._datadir + '/models.txt'
  50 +
45 51 # Return
46 52 return
47 53  
... ... @@ -69,8 +75,8 @@ class Test(test):
69 75 csmodelmerge = self._script('csmodelmerge')
70 76  
71 77 # Setup csmodelmerge command
72   - cmd = csmodelmerge+' inmodels="data/crab.xml data/model_cube_background.xml"'+ \
73   - ' outmodel="mergedmodel_cmd1.xml"'+ \
  78 + cmd = csmodelmerge+' inmodels="'+self._model1+' '+self._model2+'"'+ \
  79 + ' outmodel="csmodelmerge_cmd1.xml"'+ \
74 80 ' logfile="csmodelmerge_cmd1.log" chatter=1'
75 81  
76 82 # Check if execution of wrong command fails
... ... @@ -82,11 +88,11 @@ class Test(test):
82 88 'Check successful execution from command line')
83 89  
84 90 # Check model file
85   - self._check_model_file('mergedmodel_cmd1.xml', 3)
  91 + self._check_model_file('csmodelmerge_cmd1.xml', 3)
86 92  
87 93 # Setup csmodelmerge command
88 94 cmd = csmodelmerge+' inmodels="model_that_does_not_exist.xml"'+ \
89   - ' outmodel="mergedmodel_cmd2.xml"'+ \
  95 + ' outmodel="csmodelmerge_cmd2.xml"'+ \
90 96 ' logfile="csmodelmerge_cmd2.log"'
91 97  
92 98 # Check if execution failed
... ... @@ -103,8 +109,8 @@ class Test(test):
103 109 """
104 110 # Set-up csmodelmerge for space-separated input
105 111 modelmerge = cscripts.csmodelmerge()
106   - modelmerge['inmodels'] = 'data/crab.xml data/model_cube_background.xml'
107   - modelmerge['outmodel'] = 'mergedmodel_py1.xml'
  112 + modelmerge['inmodels'] = self._model1+' '+self._model2
  113 + modelmerge['outmodel'] = 'csmodelmerge_py1.xml'
108 114 modelmerge['logfile'] = 'csmodelmerge_py1.log'
109 115 modelmerge['chatter'] = 2
110 116  
... ... @@ -114,12 +120,12 @@ class Test(test):
114 120 modelmerge.save()
115 121  
116 122 # Check model file
117   - self._check_model_file('mergedmodel_py1.xml', 3)
  123 + self._check_model_file('csmodelmerge_py1.xml', 3)
118 124  
119 125 # Set-up csmodelmerge for semi-colon separated input
120 126 modelmerge = cscripts.csmodelmerge()
121   - modelmerge['inmodels'] = 'data/crab.xml;data/model_cube_background.xml'
122   - modelmerge['outmodel'] = 'mergedmodel_py2.xml'
  127 + modelmerge['inmodels'] = self._model1+';'+self._model2
  128 + modelmerge['outmodel'] = 'csmodelmerge_py2.xml'
123 129 modelmerge['logfile'] = 'csmodelmerge_py2.log'
124 130 modelmerge['chatter'] = 3
125 131  
... ... @@ -127,12 +133,12 @@ class Test(test):
127 133 modelmerge.execute()
128 134  
129 135 # Check model file
130   - self._check_model_file('mergedmodel_py2.xml', 3)
  136 + self._check_model_file('csmodelmerge_py2.xml', 3)
131 137  
132 138 # Set-up csmodelmerge for wildcard input
133 139 modelmerge = cscripts.csmodelmerge()
134   - modelmerge['inmodels'] = 'data/model_cube_background*.xml'
135   - modelmerge['outmodel'] = 'mergedmodel_py3.xml'
  140 + modelmerge['inmodels'] = self._model3
  141 + modelmerge['outmodel'] = 'csmodelmerge_py3.xml'
136 142 modelmerge['logfile'] = 'csmodelmerge_py3.log'
137 143 modelmerge['chatter'] = 4
138 144  
... ... @@ -140,12 +146,12 @@ class Test(test):
140 146 modelmerge.execute()
141 147  
142 148 # Check model file
143   - self._check_model_file('mergedmodel_py3.xml', 2)
  149 + self._check_model_file('csmodelmerge_py3.xml', 2)
144 150  
145 151 # Set-up csmodelmerge for ASCII file
146 152 modelmerge = cscripts.csmodelmerge()
147   - modelmerge['inmodels'] = '@data/models.txt'
148   - modelmerge['outmodel'] = 'mergedmodel_py4.xml'
  153 + modelmerge['inmodels'] = self._model4
  154 + modelmerge['outmodel'] = 'csmodelmerge_py4.xml'
149 155 modelmerge['logfile'] = 'csmodelmerge_py4.log'
150 156 modelmerge['chatter'] = 4
151 157  
... ... @@ -153,7 +159,7 @@ class Test(test):
153 159 modelmerge.execute()
154 160  
155 161 # Check model file
156   - self._check_model_file('mergedmodel_py4.xml', 2)
  162 + self._check_model_file('csmodelmerge_py4.xml', 2)
157 163  
158 164 # Return
159 165 return
... ...
test/test_csobs2caldb.py
... ... @@ -44,7 +44,7 @@ class Test(test):
44 44 test.__init__(self)
45 45  
46 46 # Set members
47   - self._inobs = 'data/obs_unbinned.xml'
  47 + self._inobs = self._datadir + '/obs_unbinned.xml'
48 48  
49 49 # Clean calibration database
50 50 os.system('rm -rf caldb >/dev/null 2>&1')
... ...
test/test_csobsdef.py
... ... @@ -42,6 +42,9 @@ class Test(test):
42 42 # Call base class constructor
43 43 test.__init__(self)
44 44  
  45 + # Set members
  46 + self._pntdef = self._datadir + '/pntdef.dat'
  47 +
45 48 # Return
46 49 return
47 50  
... ... @@ -69,9 +72,9 @@ class Test(test):
69 72 csobsdef = self._script('csobsdef')
70 73  
71 74 # Setup csobsdef command
72   - cmd = csobsdef+' inpnt="data/pntdef.dat"'+ \
  75 + cmd = csobsdef+' inpnt="'+self._pntdef+'"'+ \
73 76 ' outobs="csobsdef_cmd1.xml"'+ \
74   - ' caldb="prod2" irf="South_0.5h"'+ \
  77 + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \
75 78 ' emin=0.1 emax=100.0 duration=1800.0 rad=5.0'+ \
76 79 ' logfile="csobsdef_cmd1.log" chatter=1'
77 80  
... ... @@ -89,7 +92,7 @@ class Test(test):
89 92 # Setup csobsdef command
90 93 cmd = csobsdef+' inpnt="obs_definition_that_does_not_exist.dat"'+ \
91 94 ' outobs="csobsdef_cmd1.xml"'+ \
92   - ' caldb="prod2" irf="South_0.5h"'+ \
  95 + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \
93 96 ' emin=0.1 emax=100.0 duration=1800.0 rad=5.0'+ \
94 97 ' logfile="csobsdef_cmd2.log"'
95 98  
... ... @@ -107,10 +110,10 @@ class Test(test):
107 110 """
108 111 # Set-up csobsdef
109 112 obsdef = cscripts.csobsdef()
110   - obsdef['inpnt'] = 'data/pntdef.dat'
  113 + obsdef['inpnt'] = self._pntdef
111 114 obsdef['outobs'] = 'csobsdef_py1.xml'
112   - obsdef['caldb'] = 'prod2'
113   - obsdef['irf'] = 'South_0.5h'
  115 + obsdef['caldb'] = self._caldb
  116 + obsdef['irf'] = self._irf
114 117 obsdef['emin'] = 0.1
115 118 obsdef['emax'] = 100.0
116 119 obsdef['duration'] = 1800.0
... ... @@ -128,10 +131,10 @@ class Test(test):
128 131  
129 132 # Set-up csobsdef
130 133 obsdef = cscripts.csobsdef()
131   - obsdef['inpnt'] = 'data/pntdef.dat'
  134 + obsdef['inpnt'] = self._pntdef
132 135 obsdef['outobs'] = 'csobsdef_py2.xml'
133   - obsdef['caldb'] = 'prod2'
134   - obsdef['irf'] = 'South_0.5h'
  136 + obsdef['caldb'] = self._caldb
  137 + obsdef['irf'] = self._irf
135 138 obsdef['emin'] = 0.1
136 139 obsdef['emax'] = 100.0
137 140 obsdef['duration'] = 1800.0
... ... @@ -146,14 +149,14 @@ class Test(test):
146 149 self._check_obsdef_file('csobsdef_py2.xml')
147 150  
148 151 # Load CSV table
149   - csv = gammalib.GCsv('data/pntdef.dat', ',')
  152 + csv = gammalib.GCsv(self._pntdef, ',')
150 153  
151 154 # Set-up csobsdef
152 155 obsdef = cscripts.csobsdef()
153 156 obsdef.pntdef(csv)
154 157 obsdef['outobs'] = 'csobsdef_py3.xml'
155   - obsdef['caldb'] = 'prod2'
156   - obsdef['irf'] = 'South_0.5h'
  158 + obsdef['caldb'] = self._caldb
  159 + obsdef['irf'] = self._irf
157 160 obsdef['emin'] = 0.1
158 161 obsdef['emax'] = 100.0
159 162 obsdef['duration'] = 1800.0
... ...
test/test_csobsinfo.py
... ... @@ -42,6 +42,9 @@ class Test(test):
42 42 # Call base class constructor
43 43 test.__init__(self)
44 44  
  45 + # Set members
  46 + self._inobs = self._datadir + '/obs_unbinned.xml'
  47 +
45 48 # Return
46 49 return
47 50  
... ... @@ -69,7 +72,7 @@ class Test(test):
69 72 csobsinfo = self._script('csobsinfo')
70 73  
71 74 # Setup csobsinfo command
72   - cmd = csobsinfo+' inobs="data/obs_unbinned.xml"'+ \
  75 + cmd = csobsinfo+' inobs="'+self._inobs+'"'+ \
73 76 ' ds9file="csobsinfo_cmd1.reg"'+ \
74 77 ' offset=yes ra=83.63 dec=22.01'+ \
75 78 ' logfile="csobsinfo_cmd1.log" chatter=1'
... ... @@ -105,7 +108,7 @@ class Test(test):
105 108 """
106 109 # Set-up csobsinfo
107 110 obsinfo = cscripts.csobsinfo()
108   - obsinfo['inobs'] = 'data/obs_unbinned.xml'
  111 + obsinfo['inobs'] = self._inobs
109 112 obsinfo['ds9file'] = 'csobsinfo_py1.reg'
110 113 obsinfo['offset'] = True
111 114 obsinfo['ra'] = 83.63
... ... @@ -123,7 +126,7 @@ class Test(test):
123 126  
124 127 # Set-up csobsinfo
125 128 obsinfo = cscripts.csobsinfo()
126   - obsinfo['inobs'] = 'data/obs_unbinned.xml'
  129 + obsinfo['inobs'] = self._inobs
127 130 obsinfo['ds9file'] = 'csobsinfo_py2.reg'
128 131 obsinfo['offset'] = True
129 132 obsinfo['ra'] = 83.63
... ...
test/test_cspull.py
... ... @@ -42,6 +42,10 @@ class Test(test):
42 42 # Call base class constructor
43 43 test.__init__(self)
44 44  
  45 + # Set members
  46 + self._inobs = self._datadir + '/obs_stacked.xml'
  47 + self._stacked_model = self._datadir + '/crab_bkgcube.xml'
  48 +
45 49 # Return
46 50 return
47 51  
... ... @@ -69,9 +73,10 @@ class Test(test):
69 73 cspull = self._script('cspull')
70 74  
71 75 # Setup cspull command
72   - cmd = cspull+' inmodel="data/crab.xml"'+ \
  76 + cmd = cspull+' inmodel="'+self._model+'"'+ \
73 77 ' outfile="cspull_cmd1.dat"'+ \
74   - ' ntrials=3 caldb="prod2" irf="South_0.5h"'+ \
  78 + ' ntrials=3'+ \
  79 + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \
75 80 ' ra=83.6331 dec=22.0145 emin=0.1 emax=100.0'+ \
76 81 ' enumbins=0 tmax=1800.0 deadc=0.95 rad=5.0'+ \
77 82 ' npix=200 binsz=0.05'+ \
... ... @@ -91,7 +96,8 @@ class Test(test):
91 96 # Setup cspull command
92 97 cmd = cspull+' inmodel="model_that_does_not_exist.xml"'+ \
93 98 ' outfile="cspull_cmd1.dat"'+ \
94   - ' ntrials=3 caldb="prod2" irf="South_0.5h"'+ \
  99 + ' ntrials=3'+ \
  100 + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \
95 101 ' ra=83.6331 dec=22.0145 emin=0.1 emax=100.0'+ \
96 102 ' enumbins=0 tmax=1800.0 deadc=0.95 rad=5.0'+ \
97 103 ' npix=200 binsz=0.05'+ \
... ... @@ -111,11 +117,11 @@ class Test(test):
111 117 """
112 118 # Set-up unbinned cspull
113 119 pull = cscripts.cspull()
114   - pull['inmodel'] = 'data/crab.xml'
  120 + pull['inmodel'] = self._model
115 121 pull['outfile'] = 'cspull_py1.dat'
116 122 pull['ntrials'] = 3
117   - pull['caldb'] = 'prod2'
118   - pull['irf'] = 'South_0.5h'
  123 + pull['caldb'] = self._caldb
  124 + pull['irf'] = self._irf
119 125 pull['ra'] = 83.6331
120 126 pull['dec'] = 22.0145
121 127 pull['emin'] = 0.1
... ... @@ -137,11 +143,11 @@ class Test(test):
137 143  
138 144 # Set-up binned cspull
139 145 pull = cscripts.cspull()
140   - pull['inmodel'] = 'data/crab.xml'
  146 + pull['inmodel'] = self._model
141 147 pull['outfile'] = 'cspull_py2.dat'
142 148 pull['ntrials'] = 3
143   - pull['caldb'] = 'prod2'
144   - pull['irf'] = 'South_0.5h'
  149 + pull['caldb'] = self._caldb
  150 + pull['irf'] = self._irf
145 151 pull['ra'] = 83.6331
146 152 pull['dec'] = 22.0145
147 153 pull['emin'] = 0.1
... ... @@ -165,12 +171,12 @@ class Test(test):
165 171  
166 172 # Set-up cspull from event list
167 173 pull = cscripts.cspull()
168   - pull['inobs'] = 'data/crab_events.fits'
169   - pull['inmodel'] = 'data/crab.xml'
  174 + pull['inobs'] = self._events
  175 + pull['inmodel'] = self._model
170 176 pull['outfile'] = 'cspull_py3.dat'
171 177 pull['ntrials'] = 3
172   - pull['caldb'] = 'prod2'
173   - pull['irf'] = 'South_0.5h'
  178 + pull['caldb'] = self._caldb
  179 + pull['irf'] = self._irf
174 180 pull['enumbins'] = 0
175 181 pull['logfile'] = 'cspull_py3.log'
176 182 pull['chatter'] = 4
... ... @@ -182,17 +188,17 @@ class Test(test):
182 188 self._check_pull_file('cspull_py3.dat')
183 189  
184 190 # Build observation container with unbinned observation
185   - cta = gammalib.GCTAObservation('data/crab_events.fits')
  191 + cta = gammalib.GCTAObservation(self._events)
186 192 obs = gammalib.GObservations()
187 193 obs.append(cta)
188 194  
189 195 # Set-up cspull from observation container with unbinned observation
190 196 pull = cscripts.cspull(obs)
191   - pull['inmodel'] = 'data/crab.xml'
  197 + pull['inmodel'] = self._model
192 198 pull['outfile'] = 'cspull_py4.dat'
193 199 pull['ntrials'] = 3
194   - pull['caldb'] = 'prod2'
195   - pull['irf'] = 'South_0.5h'
  200 + pull['caldb'] = self._caldb
  201 + pull['irf'] = self._irf
196 202 pull['enumbins'] = 0
197 203 pull['logfile'] = 'cspull_py4.log'
198 204 pull['chatter'] = 4
... ... @@ -205,12 +211,12 @@ class Test(test):
205 211  
206 212 # Set-up stacked cspull
207 213 pull = cscripts.cspull()
208   - pull['inobs'] = 'data/obs_stacked.xml'
209   - pull['inmodel'] = 'data/crab_bkgcube.xml'
  214 + pull['inobs'] = self._inobs
  215 + pull['inmodel'] = self._stacked_model
210 216 pull['outfile'] = 'cspull_py5.dat'
211 217 pull['ntrials'] = 3
212   - pull['caldb'] = 'prod2'
213   - pull['irf'] = 'South_0.5h'
  218 + pull['caldb'] = self._caldb
  219 + pull['irf'] = self._irf
214 220 pull['enumbins'] = 0
215 221 pull['logfile'] = 'cspull_py5.log'
216 222 pull['chatter'] = 4
... ...
test/test_csresmap.py
... ... @@ -69,10 +69,10 @@ class Test(test):
69 69 csresmap = self._script('csresmap')
70 70  
71 71 # Setup csresmap command
72   - cmd = csresmap+' inobs="data/crab_events.fits"'+ \
  72 + cmd = csresmap+' inobs="'+self._events+'"'+ \
73 73 ' outmap="csresmap_cmd1.fits"'+ \
74   - ' inmodel="data/crab.xml"'+ \
75   - ' caldb="prod2" irf="South_0.5h"' + \
  74 + ' inmodel="'+self._model+'"'+ \
  75 + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \
76 76 ' emin=0.1 emax=100.0 enumbins=20'+ \
77 77 ' nxpix=50 nypix=50 binsz=0.02'+ \
78 78 ' coordsys="CEL" proj="CAR" xref=83.63 yref=22.01'+ \
... ... @@ -93,8 +93,8 @@ class Test(test):
93 93 # Setup csresmap command
94 94 cmd = csresmap+' inobs="event_file_that_does_not_exist.fits"'+ \
95 95 ' outmap="csresmap_cmd1.fits"'+ \
96   - ' inmodel="data/crab.xml"'+ \
97   - ' caldb="prod2" irf="South_0.5h"' + \
  96 + ' inmodel="'+self._model+'"'+ \
  97 + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \
98 98 ' emin=0.1 emax=100.0 enumbins=20'+ \
99 99 ' nxpix=50 nypix=50 binsz=0.02'+ \
100 100 ' coordsys="CEL" proj="CAR" xref=83.63 yref=22.01'+ \
... ... @@ -115,11 +115,11 @@ class Test(test):
115 115 """
116 116 # Set-up csresmap for event list
117 117 resmap = cscripts.csresmap()
118   - resmap['inobs'] = 'data/crab_events.fits'
  118 + resmap['inobs'] = self._events
119 119 resmap['outmap'] = 'csresmap_py1.fits'
120   - resmap['inmodel'] = 'data/crab.xml'
121   - resmap['caldb'] = 'prod2'
122   - resmap['irf'] = 'South_0.5h'
  120 + resmap['inmodel'] = self._model
  121 + resmap['caldb'] = self._caldb
  122 + resmap['irf'] = self._irf
123 123 resmap['emin'] = 0.1
124 124 resmap['emax'] = 100.0
125 125 resmap['enumbins'] = 20
... ... @@ -144,15 +144,15 @@ class Test(test):
144 144  
145 145 # Set-up csresmap for counts cube
146 146 resmap = cscripts.csresmap()
147   - resmap['inobs'] = 'data/crab_cntmap.fits'
  147 + resmap['inobs'] = self._cntcube
148 148 resmap['modcube'] = 'NONE'
149 149 resmap['expcube'] = 'NONE'
150 150 resmap['psfcube'] = 'NONE'
151 151 resmap['edispcube'] = 'NONE'
152 152 resmap['bkgcube'] = 'NONE'
153   - resmap['caldb'] = 'prod2'
154   - resmap['irf'] = 'South_0.5h'
155   - resmap['inmodel'] = 'data/crab.xml'
  153 + resmap['caldb'] = self._caldb
  154 + resmap['irf'] = self._irf
  155 + resmap['inmodel'] = self._model
156 156 resmap['outmap'] = 'csresmap_py2.fits'
157 157 resmap['algorithm'] = 'SUBDIV'
158 158 resmap['logfile'] = 'csresmap_py2.log'
... ...
test/test_csroot2caldb.py
... ... @@ -38,11 +38,14 @@ class Test(test):
38 38 # Constructor
39 39 def __init__(self):
40 40 """
41   - Constructor.
  41 + Constructor
42 42 """
43 43 # Call base class constructor
44 44 test.__init__(self)
45 45  
  46 + # Set members
  47 + self._infile = self._datadir + '/irf.root'
  48 +
46 49 # Clean calibration database
47 50 os.system('rm -rf csroot2caldb_* >/dev/null 2>&1')
48 51  
... ... @@ -73,7 +76,7 @@ class Test(test):
73 76 csroot2caldb = self._script('csroot2caldb')
74 77  
75 78 # Setup csroot2caldb command
76   - cmd = csroot2caldb+' infile="data/irf.root"'+ \
  79 + cmd = csroot2caldb+' infile="'+self._infile+'"'+ \
77 80 ' outdir="csroot2caldb_cmd1"'+ \
78 81 ' inst=prod3 id=South_50h version=prod3'+ \
79 82 ' analysis=DESY'+ \
... ... @@ -97,7 +100,7 @@ class Test(test):
97 100 """
98 101 # Set-up csroot2caldb
99 102 caldb = cscripts.csroot2caldb()
100   - caldb['infile'] = 'data/irf.root'
  103 + caldb['infile'] = self._infile
101 104 caldb['outdir'] = 'csroot2caldb_py1'
102 105 caldb['inst'] = 'prod3'
103 106 caldb['id'] = 'South_50h'
... ...
test/test_cssens.py
... ... @@ -69,8 +69,9 @@ class Test(test):
69 69 cssens = self._script('cssens')
70 70  
71 71 # Setup cssens command
72   - cmd = cssens+' inmodel="data/crab.xml"'+ \
73   - ' srcname="Crab" caldb="prod2" irf="South_0.5h"' + \
  72 + cmd = cssens+' inmodel="'+self._model+'"'+ \
  73 + ' srcname="Crab"'+ \
  74 + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \
74 75 ' duration=1800.0 rad=3.0 emin=1.0 emax=10.0 bins=1'+ \
75 76 ' outfile="cssens_cmd1.dat"'+ \
76 77 ' logfile="cssens_cmd1.log" chatter=1'
... ... @@ -88,7 +89,8 @@ class Test(test):
88 89  
89 90 # Setup cssens command
90 91 cmd = cssens+' inmodel="model_that_does_not_exist.xml"'+ \
91   - ' srcname="Crab" caldb="prod2" irf="South_0.5h"' + \
  92 + ' srcname="Crab"'+ \
  93 + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \
92 94 ' duration=1800.0 rad=3.0 emin=1.0 emax=10.0 bins=1'+ \
93 95 ' outfile="cssens_cmd2.dat"'+ \
94 96 ' logfile="cssens_cmd2.log" chatter=2'
... ... @@ -108,10 +110,10 @@ class Test(test):
108 110 # Set-up cssens
109 111 sens = cscripts.cssens()
110 112 sens['inobs'] = 'NONE'
111   - sens['inmodel'] = 'data/crab.xml'
  113 + sens['inmodel'] = self._model
112 114 sens['srcname'] = 'Crab'
113   - sens['caldb'] = 'prod2'
114   - sens['irf'] = 'South_0.5h'
  115 + sens['caldb'] = self._caldb
  116 + sens['irf'] = self._irf
115 117 sens['outfile'] = 'cssens_py1.dat'
116 118 sens['duration'] = 1800.0
117 119 sens['rad'] = 3.0
... ... @@ -141,8 +143,10 @@ class Test(test):
141 143 results = gammalib.GCsv(filename, ',')
142 144  
143 145 # Check dimensions
144   - self.test_value(results.nrows(), 2, 'Check for 2 rows in sensitivity file')
145   - self.test_value(results.ncols(), 7, 'Check for 7 columns in sensitivity file')
  146 + self.test_value(results.nrows(), 2,
  147 + 'Check for 2 rows in sensitivity file')
  148 + self.test_value(results.ncols(), 7,
  149 + 'Check for 7 columns in sensitivity file')
146 150  
147 151 # Return
148 152 return
... ...
test/test_csspec.py
... ... @@ -42,6 +42,13 @@ class Test(test):
42 42 # Call base class constructor
43 43 test.__init__(self)
44 44  
  45 + # Set members
  46 + self._inobs = self._datadir + '/crab_cntmap_small.fits'
  47 + self._expcube = self._datadir + '/crab_expcube.fits'
  48 + self._psfcube = self._datadir + '/crab_psfcube.fits'
  49 + self._edispcube = self._datadir + '/crab_edispcube.fits'
  50 + self._bkgcube = self._datadir + '/crab_bkgcube.fits'
  51 +
45 52 # Return
46 53 return
47 54  
... ... @@ -69,9 +76,10 @@ class Test(test):
69 76 csspec = self._script('csspec')
70 77  
71 78 # Setup csspec command
72   - cmd = csspec+' inobs="data/crab_events.fits"'+ \
73   - ' inmodel="data/crab.xml"'+ \
74   - ' srcname="Crab" caldb="prod2" irf="South_0.5h"' + \
  79 + cmd = csspec+' inobs="'+self._events+'"'+ \
  80 + ' inmodel="'+self._model+'"'+ \
  81 + ' srcname="Crab"'+ \
  82 + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \
75 83 ' ebinalg="LOG" enumbins=5 emin=0.1 emax=100.0'+ \
76 84 ' outfile="csspec_cmd1.fits"'+ \
77 85 ' logfile="csspec_cmd1.log" chatter=1'
... ... @@ -89,8 +97,9 @@ class Test(test):
89 97  
90 98 # Setup csspec command
91 99 cmd = csspec+' inobs="input_file_that_does_not_exist.fits"'+ \
92   - ' inmodel="data/crab.xml"'+ \
93   - ' srcname="Crab" caldb="prod2" irf="South_0.5h"' + \
  100 + ' inmodel="'+self._model+'"'+ \
  101 + ' srcname="Crab"'+ \
  102 + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \
94 103 ' ebinalg="LOG" enumbins=5 emin=0.1 emax=100.0'+ \
95 104 ' outfile="csspec_cmd2.fits"'+ \
96 105 ' logfile="csspec_cmd2.log" chatter=1'
... ... @@ -109,11 +118,11 @@ class Test(test):
109 118 """
110 119 # Set-up unbinned csspec
111 120 spec = cscripts.csspec()
112   - spec['inobs'] = 'data/crab_events.fits'
113   - spec['inmodel'] = 'data/crab.xml'
  121 + spec['inobs'] = self._events
  122 + spec['inmodel'] = self._model
114 123 spec['srcname'] = 'Crab'
115   - spec['caldb'] = 'prod2'
116   - spec['irf'] = 'South_0.5h'
  124 + spec['caldb'] = self._caldb
  125 + spec['irf'] = self._irf
117 126 spec['outfile'] = 'csspec_py1.fits'
118 127 spec['ebinalg'] = 'LOG'
119 128 spec['enumbins'] = 5
... ... @@ -132,12 +141,12 @@ class Test(test):
132 141  
133 142 # Set-up binned csspec
134 143 spec = cscripts.csspec()
135   - spec['inobs'] = 'data/crab_cntmap_small.fits'
136   - spec['expcube'] = 'data/crab_expcube.fits'
137   - spec['psfcube'] = 'data/crab_psfcube.fits'
138   - spec['edispcube'] = 'data/crab_edispcube.fits'
139   - spec['bkgcube'] = 'data/crab_bkgcube.fits'
140   - spec['inmodel'] = 'data/crab.xml'
  144 + spec['inobs'] = self._inobs
  145 + spec['expcube'] = self._expcube
  146 + spec['psfcube'] = self._psfcube
  147 + spec['edispcube'] = self._edispcube
  148 + spec['bkgcube'] = self._bkgcube
  149 + spec['inmodel'] = self._model
141 150 spec['srcname'] = 'Crab'
142 151 spec['outfile'] = 'csspec_py2.fits'
143 152 spec['ebinalg'] = 'LOG'
... ... @@ -168,8 +177,10 @@ class Test(test):
168 177 spectrum = fits['SPECTRUM']
169 178  
170 179 # Check dimensions
171   - self.test_value(spectrum.nrows(), bins, 'Check for %d rows in spectrum' % bins)
172   - self.test_value(spectrum.ncols(), 8, 'Check for 8 columns in spectrum')
  180 + self.test_value(spectrum.nrows(), bins,
  181 + 'Check for %d rows in spectrum' % bins)
  182 + self.test_value(spectrum.ncols(), 8,
  183 + 'Check for 8 columns in spectrum')
173 184  
174 185 # Return
175 186 return
... ...
test/test_cstsdist.py
... ... @@ -69,8 +69,9 @@ class Test(test):
69 69 cstsdist = self._script('cstsdist')
70 70  
71 71 # Setup cstsdist command
72   - cmd = cstsdist+' inmodel="data/crab.xml"'+ \
73   - ' srcname="Crab" caldb="prod2" irf="South_0.5h"' + \
  72 + cmd = cstsdist+' inmodel="'+self._model+'"'+ \
  73 + ' srcname="Crab"'+ \
  74 + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \
74 75 ' ntrials=1 ra=83.63 dec=22.01 emin=0.1 emax=100.0'+ \
75 76 ' enumbins=0 tmax=1800.0 rad=5.0 npix=200 npix=200'+ \
76 77 ' binsz=0.05'+ \
... ... @@ -90,7 +91,8 @@ class Test(test):
90 91  
91 92 # Setup cstsdist command
92 93 cmd = cstsdist+' inmodel="model_that_does_not_exist.xml"'+ \
93   - ' srcname="Crab" caldb="prod2" irf="South_0.5h"' + \
  94 + ' srcname="Crab"'+ \
  95 + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \
94 96 ' ntrials=1 ra=83.63 dec=22.01 emin=0.1 emax=100.0'+ \
95 97 ' enumbins=0 tmax=1800.0 rad=5.0 npix=200 npix=200'+ \
96 98 ' binsz=0.05'+ \
... ... @@ -111,10 +113,10 @@ class Test(test):
111 113 """
112 114 # Set-up cstsdist
113 115 tsdist = cscripts.cstsdist()
114   - tsdist['inmodel'] = 'data/crab.xml'
  116 + tsdist['inmodel'] = self._model
115 117 tsdist['srcname'] = 'Crab'
116   - tsdist['caldb'] = 'prod2'
117   - tsdist['irf'] = 'South_0.5h'
  118 + tsdist['caldb'] = self._caldb
  119 + tsdist['irf'] = self._irf
118 120 tsdist['outfile'] = 'cstsdist_py1.dat'
119 121 tsdist['ntrials'] = 1
120 122 tsdist['ra'] = 83.63
... ...
test/test_cstsmapmerge.py
... ... @@ -42,6 +42,12 @@ class Test(test):
42 42 # Call base class constructor
43 43 test.__init__(self)
44 44  
  45 + # Set members
  46 + self._map0 = self._datadir + '/tsmap_0.fits'
  47 + self._map1 = self._datadir + '/tsmap_1.fits'
  48 + self._mapstar = self._datadir + '/tsmap_*.fits'
  49 + self._mapat = '@' + self._datadir + '/tsmaps.txt'
  50 +
45 51 # Return
46 52 return
47 53  
... ... @@ -69,7 +75,7 @@ class Test(test):
69 75 cstsmapmerge = self._script('cstsmapmerge')
70 76  
71 77 # Setup cstsmapmerge command
72   - cmd = cstsmapmerge+' inmaps="data/tsmap_0.fits;data/tsmap_1.fits"'+ \
  78 + cmd = cstsmapmerge+' inmaps="'+self._map0+';'+self._map1+'"'+ \
73 79 ' outmap="cstsmapmerge_cmd1.fits"'+ \
74 80 ' logfile="cstsmapmerge_cmd1.log" chatter=1'
75 81  
... ... @@ -103,7 +109,7 @@ class Test(test):
103 109 """
104 110 # Set-up semi-colon separated cstsmapmerge
105 111 merge = cscripts.cstsmapmerge()
106   - merge['inmaps'] = 'data/tsmap_0.fits;data/tsmap_1.fits'
  112 + merge['inmaps'] = self._map0+';'+self._map1
107 113 merge['outmap'] = 'cstsmapmerge_py1.fits'
108 114 merge['logfile'] = 'cstsmapmerge_py1.log'
109 115 merge['chatter'] = 2
... ... @@ -118,7 +124,7 @@ class Test(test):
118 124  
119 125 # Set-up space-separated cstsmapmerge
120 126 merge = cscripts.cstsmapmerge()
121   - merge['inmaps'] = 'data/tsmap_0.fits data/tsmap_1.fits'
  127 + merge['inmaps'] = self._map0+' '+self._map1
122 128 merge['outmap'] = 'cstsmapmerge_py2.fits'
123 129 merge['logfile'] = 'cstsmapmerge_py2.log'
124 130 merge['chatter'] = 3
... ... @@ -131,7 +137,7 @@ class Test(test):
131 137  
132 138 # Set-up wildcard string cstsmapmerge
133 139 merge = cscripts.cstsmapmerge()
134   - merge['inmaps'] = 'data/tsmap_*.fits'
  140 + merge['inmaps'] = self._mapstar
135 141 merge['outmap'] = 'cstsmapmerge_py3.fits'
136 142 merge['logfile'] = 'cstsmapmerge_py3.log'
137 143 merge['chatter'] = 4
... ... @@ -144,7 +150,7 @@ class Test(test):
144 150  
145 151 # Set-up ASCII file cstsmapmerge
146 152 merge = cscripts.cstsmapmerge()
147   - merge['inmaps'] = '@data/tsmaps.txt'
  153 + merge['inmaps'] = self._mapat
148 154 merge['outmap'] = 'cstsmapmerge_py4.fits'
149 155 merge['logfile'] = 'cstsmapmerge_py4.log'
150 156 merge['chatter'] = 4
... ...
test/test_cstsmapsplit.py
... ... @@ -69,11 +69,11 @@ class Test(test):
69 69 cstsmapsplit = self._script('cstsmapsplit')
70 70  
71 71 # Setup cstsmapsplit command
72   - cmd = cstsmapsplit+' inobs="data/crab_events.fits"'+ \
73   - ' inmodel="data/crab.xml"'+ \
  72 + cmd = cstsmapsplit+' inobs="'+self._events+'"'+ \
  73 + ' inmodel="'+self._model+'"'+ \
74 74 ' srcname="Crab"'+ \
75   - ' caldb="prod2"'+ \
76   - ' irf="South_0.5h"'+ \
  75 + ' caldb="'+self._caldb+'"'+ \
  76 + ' irf="'+self._irf+'"'+ \
77 77 ' outmap="tsmap.fits"'+ \
78 78 ' nxpix=5'+ \
79 79 ' nypix=5'+ \
... ... @@ -99,11 +99,11 @@ class Test(test):
99 99 self._check_cmdfile('cstsmapsplit_cmd1.dat')
100 100  
101 101 # Setup cstsmapsplit command
102   - cmd = cstsmapsplit+' inobs="data/crab_events.fits"'+ \
103   - ' inmodel="data/crab.xml"'+ \
  102 + cmd = cstsmapsplit+' inobs="'+self._events+'"'+ \
  103 + ' inmodel="'+self._model+'"'+ \
104 104 ' srcname="Does_not_exist"'+ \
105   - ' caldb="prod2"'+ \
106   - ' irf="South_0.5h"'+ \
  105 + ' caldb="'+self._caldb+'"'+ \
  106 + ' irf="'+self._irf+'"'+ \
107 107 ' outmap="tsmap.fits"'+ \
108 108 ' nxpix=5'+ \
109 109 ' nypix=5'+ \
... ... @@ -131,11 +131,11 @@ class Test(test):
131 131 """
132 132 # Set-up cstsmapsplit
133 133 tsmapsplit = cscripts.cstsmapsplit()
134   - tsmapsplit['inobs'] = 'data/crab_events.fits'
135   - tsmapsplit['inmodel'] = 'data/crab.xml'
  134 + tsmapsplit['inobs'] = self._events
  135 + tsmapsplit['inmodel'] = self._model
136 136 tsmapsplit['srcname'] = 'Crab'
137   - tsmapsplit['caldb'] = 'prod2'
138   - tsmapsplit['irf'] = 'South_0.5h'
  137 + tsmapsplit['caldb'] = self._caldb
  138 + tsmapsplit['irf'] = self._irf
139 139 tsmapsplit['outmap'] = 'tsmap.fits'
140 140 tsmapsplit['bins_per_job'] = 5
141 141 tsmapsplit['compute_null'] = False
... ...
test/test_csworkflow.py
... ... @@ -42,6 +42,9 @@ class Test(test):
42 42 # Call base class constructor
43 43 test.__init__(self)
44 44  
  45 + # Set members
  46 + self._workflow = self._datadir + '/workflow.xml'
  47 +
45 48 # Return
46 49 return
47 50  
... ... @@ -72,7 +75,7 @@ class Test(test):
72 75 gammalib.GFilename('wf_crab_results.xml').remove()
73 76  
74 77 # Setup csworkflow command
75   - cmd = csworkflow+' inflow="data/workflow.xml"'+ \
  78 + cmd = csworkflow+' inflow="'+self._workflow+'"'+ \
76 79 ' logfile="csworkflow_cmd1.log" chatter=1'
77 80  
78 81 # Check if execution of wrong command fails
... ... @@ -99,7 +102,7 @@ class Test(test):
99 102  
100 103 # Set-up csworkflow
101 104 workflow = cscripts.csworkflow()
102   - workflow['inflow'] = 'data/workflow.xml'
  105 + workflow['inflow'] = self._workflow
103 106 workflow['logfile'] = 'csworkflow_py1.log'
104 107 workflow['chatter'] = 2
105 108  
... ... @@ -115,7 +118,7 @@ class Test(test):
115 118  
116 119 # Set-up csworkflow
117 120 workflow = cscripts.csworkflow()
118   - workflow['inflow'] = 'data/workflow.xml'
  121 + workflow['inflow'] = self._workflow
119 122 workflow['logfile'] = 'csworkflow_py2.log'
120 123 workflow['chatter'] = 3
121 124  
... ... @@ -140,13 +143,13 @@ class Test(test):
140 143 self.test_value(models['Crab'][2].value(),
141 144 5.71055e-16, 1.0e-5, 'Crab prefactor')
142 145 self.test_value(models['Crab'][3].value(),
143   - -2.50996, 1.0e-5, 'Crab index')
  146 + -2.47559, 1.0e-5, 'Crab index')
144 147 self.test_value(models['Background'][0].value(),
145   - 2.98499, 1.0e-5, 'Background model sigma')
  148 + 3.00491, 1.0e-5, 'Background model sigma')
146 149 self.test_value(models['Background'][1].value(),
147 150 6.27131e-05, 1.0e-5, 'Background model prefactor')
148 151 self.test_value(models['Background'][2].value(),
149   - -1.85037, 1.0e-5, 'Background model index')
  152 + -1.83164, 1.0e-5, 'Background model index')
150 153  
151 154 # Return
152 155 return
... ...
test/test_ctbin.py
... ... @@ -42,9 +42,6 @@ class Test(test):
42 42 # Call base class constructor
43 43 test.__init__(self)
44 44  
45   - # Set members
46   - self._events_name = 'data/crab_events.fits'
47   -
48 45 # Return
49 46 return
50 47  
... ... @@ -72,7 +69,7 @@ class Test(test):
72 69 ctbin = self._tool('ctbin')
73 70  
74 71 # Setup ctbin command
75   - cmd = ctbin+' inobs="'+self._events_name+'"'+ \
  72 + cmd = ctbin+' inobs="'+self._events+'"'+ \
76 73 ' outcube="cntmap_cmd1.fits"'+\
77 74 ' emin=0.1 emax=100.0 enumbins=20 ebinalg="LOG"'+ \
78 75 ' nxpix=200 nypix=200 binsz=0.02 coordsys="CEL"'+ \
... ... @@ -111,7 +108,7 @@ class Test(test):
111 108 """
112 109 # Set-up ctbin
113 110 bin = ctools.ctbin()
114   - bin['inobs'] = self._events_name
  111 + bin['inobs'] = self._events
115 112 bin['outcube'] = 'cntmap.fits'
116 113 bin['ebinalg'] = 'LOG'
117 114 bin['emin'] = 0.1
... ... @@ -157,7 +154,7 @@ class Test(test):
157 154 self._check_cube(evt, 5542)
158 155  
159 156 # Prepare observation container for stacked analysis
160   - cta = gammalib.GCTAObservation(self._events_name)
  157 + cta = gammalib.GCTAObservation(self._events)
161 158 obs = gammalib.GObservations()
162 159 cta.id('0001')
163 160 obs.append(cta)
... ...
test/test_ctbkgcube.py
... ... @@ -65,12 +65,12 @@ class Test(test):
65 65 ctbkgcube = self._tool('ctbkgcube')
66 66  
67 67 # Setup ctbkgcube command
68   - cmd = ctbkgcube+' inobs="data/crab_events.fits"'+ \
69   - ' inmodel="data/crab.xml"'+ \
  68 + cmd = ctbkgcube+' inobs="'+self._events+'"'+ \
  69 + ' inmodel="'+self._model+'"'+ \
70 70 ' incube="NONE"'+ \
71 71 ' outcube="ctbkgcube_cmd1.fits"'+ \
72 72 ' outmodel="ctbkgcube_cmd1.xml"'+ \
73   - ' caldb="prod2" irf="South_0.5h"'+ \
  73 + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \
74 74 ' ebinalg="LOG" emin=0.1 emax=100.0 enumbins=20'+ \
75 75 ' nxpix=10 nypix=10 binsz=0.4'+ \
76 76 ' coordsys="CEL" proj="CAR" xref=83.63 yref=22.01'+ \
... ... @@ -89,11 +89,11 @@ class Test(test):
89 89  
90 90 # Setup ctbkgcube command
91 91 cmd = ctbkgcube+' inobs="event_file_that_does_not_exist.fits"'+ \
92   - ' inmodel="data/crab.xml"'+ \
  92 + ' inmodel="'+self._model+'"'+ \
93 93 ' incube="NONE"'+ \
94 94 ' outcube="ctbkgcube_cmd2.fits"'+ \
95 95 ' outmodel="ctbkgcube_cmd2.xml"'+ \
96   - ' caldb="prod2" irf="South_0.5h"'+ \
  96 + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \
97 97 ' ebinalg="LOG" emin=0.1 emax=100.0 enumbins=20'+ \
98 98 ' nxpix=10 nypix=10 binsz=0.4'+ \
99 99 ' coordsys="CEL" proj="CAR" xref=83.63 yref=22.01'+ \
... ... @@ -113,13 +113,13 @@ class Test(test):
113 113 """
114 114 # Set-up ctbkgcube
115 115 bkgcube = ctools.ctbkgcube()
116   - bkgcube['inobs'] = 'data/crab_events.fits'
117   - bkgcube['inmodel'] = 'data/crab.xml'
  116 + bkgcube['inobs'] = self._events
  117 + bkgcube['inmodel'] = self._model
118 118 bkgcube['incube'] = 'NONE'
119 119 bkgcube['outcube'] = 'ctbkgcube_py1.fits'
120 120 bkgcube['outmodel'] = 'ctbkgcube_py1.xml'
121   - bkgcube['caldb'] = 'prod2'
122   - bkgcube['irf'] = 'South_0.5h'
  121 + bkgcube['caldb'] = self._caldb
  122 + bkgcube['irf'] = self._irf
123 123 bkgcube['ebinalg'] = 'LOG'
124 124 bkgcube['emin'] = 0.1
125 125 bkgcube['emax'] = 100
... ...
test/test_ctbutterfly.py
... ... @@ -28,12 +28,12 @@ from testing import test
28 28 # =============================== #
29 29 class Test(test):
30 30 """
31   - Test class for ctbutterfly tool.
  31 + Test class for ctbutterfly tool
32 32 """
33 33 # Constructor
34 34 def __init__(self):
35 35 """
36   - Constructor.
  36 + Constructor
37 37 """
38 38 # Call base class constructor
39 39 test.__init__(self)
... ... @@ -44,7 +44,7 @@ class Test(test):
44 44 # Set test functions
45 45 def set(self):
46 46 """
47   - Set all test functions.
  47 + Set all test functions
48 48 """
49 49 # Set test name
50 50 self.name('ctbutterfly')
... ... @@ -59,16 +59,16 @@ class Test(test):
59 59 # Test ctbutterfly on command line
60 60 def _test_cmd(self):
61 61 """
62   - Test ctbutterfly on the command line.
  62 + Test ctbutterfly on the command line
63 63 """
64 64 # Set tool name
65 65 ctbutterfly = self._tool('ctbutterfly')
66 66  
67 67 # Setup ctbutterfly command
68   - cmd = ctbutterfly+' inobs="data/crab_events.fits"'+\
69   - ' outfile="ctbutterfly_cmd1.txt"'+ \
70   - ' inmodel="data/crab.xml" srcname="Crab"'+ \
71   - ' caldb="prod2" irf="South_0.5h"'+ \
  68 + cmd = ctbutterfly+' inobs="'+self._events+'"'+\
  69 + ' outfile="ctbutterfly_cmd1.dat"'+ \
  70 + ' inmodel="'+self._model +'" srcname="Crab"'+ \
  71 + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \
72 72 ' emin=0.1 emax=100.0'+ \
73 73 ' logfile="ctbutterfly_cmd1.log" chatter=1'
74 74  
... ... @@ -81,13 +81,13 @@ class Test(test):
81 81 'Check successful execution from command line')
82 82  
83 83 # Check result file
84   - self._check_result_file('ctbutterfly_cmd1.txt')
  84 + self._check_result_file('ctbutterfly_cmd1.dat')
85 85  
86 86 # Setup ctbutterfly command
87 87 cmd = ctbutterfly+' inobs="event_file_that_does_not_exist.fits"'+\
88   - ' outfile="ctbutterfly_cmd2.txt"'+ \
89   - ' inmodel="data/crab.xml" srcname="Crab"'+ \
90   - ' caldb="prod2" irf="South_0.5h"'+ \
  88 + ' outfile="ctbutterfly_cmd2.dat"'+ \
  89 + ' inmodel="'+self._model +'" srcname="Crab"'+ \
  90 + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \
91 91 ' emin=0.1 emax=100.0'+ \
92 92 ' logfile="ctbutterfly_cmd2.log" chatter=1'
93 93  
... ... @@ -105,14 +105,14 @@ class Test(test):
105 105 """
106 106 # Set-up ctbutterfly
107 107 butterfly = ctools.ctbutterfly()
108   - butterfly['inobs'] = 'data/crab_events.fits'
109   - butterfly['inmodel'] = 'data/crab.xml'
  108 + butterfly['inobs'] = self._events
  109 + butterfly['inmodel'] = self._model
110 110 butterfly['srcname'] = 'Crab'
111   - butterfly['caldb'] = 'prod2'
112   - butterfly['irf'] = 'South_0.5h'
  111 + butterfly['caldb'] = self._caldb
  112 + butterfly['irf'] = self._irf
113 113 butterfly['emin'] = 0.1
114 114 butterfly['emax'] = 100.0
115   - butterfly['outfile'] = 'ctbutterfly_py1.txt'
  115 + butterfly['outfile'] = 'ctbutterfly_py1.dat'
116 116 butterfly['logfile'] = 'ctbutterfly_py1.log'
117 117 butterfly['chatter'] = 2
118 118  
... ... @@ -122,7 +122,7 @@ class Test(test):
122 122 butterfly.save()
123 123  
124 124 # Check result file
125   - self._check_result_file('ctbutterfly_py1.txt')
  125 + self._check_result_file('ctbutterfly_py1.dat')
126 126  
127 127 # Return
128 128 return
... ... @@ -136,8 +136,10 @@ class Test(test):
136 136 results = gammalib.GCsv(filename)
137 137  
138 138 # Check dimensions
139   - self.test_value(results.nrows(), 100, 'Check for 100 rows in butterfly file')
140   - self.test_value(results.ncols(), 4, 'Check for 4 columns in butterfly file')
  139 + self.test_value(results.nrows(), 100,
  140 + 'Check for 100 rows in butterfly file')
  141 + self.test_value(results.ncols(), 4,
  142 + 'Check for 4 columns in butterfly file')
141 143  
142 144 # Return
143 145 return
... ...
test/test_ctcubemask.py
... ... @@ -38,6 +38,9 @@ class Test(test):
38 38 # Call base class constructor
39 39 test.__init__(self)
40 40  
  41 + # Set members
  42 + self._exclusion = self._datadir + '/exclusion.reg'
  43 +
41 44 # Return
42 45 return
43 46  
... ... @@ -65,8 +68,8 @@ class Test(test):
65 68 ctcubemask = self._tool('ctcubemask')
66 69  
67 70 # Setup ctcubemask command
68   - cmd = ctcubemask+' inobs="data/crab_cntmap.fits"'+ \
69   - ' regfile="data/exclusion.reg"'+ \
  71 + cmd = ctcubemask+' inobs="'+self._cntcube+'"'+ \
  72 + ' regfile="'+self._exclusion+'"'+ \
70 73 ' outcube="ctcubemask_cmd1.fits"'+ \
71 74 ' ra=83.63 dec=22.01 rad=2.0'+ \
72 75 ' emin=0.1 emax=100.0'+ \
... ... @@ -85,7 +88,7 @@ class Test(test):
85 88  
86 89 # Setup ctcubemask command
87 90 cmd = ctcubemask+' inobs="counts_cube_that_does_not_exist.fits"'+ \
88   - ' regfile="data/exclusion.reg"'+ \
  91 + ' regfile="'+self._exclusion+'"'+ \
89 92 ' outcube="ctcubemask_cmd2.fits"'+ \
90 93 ' ra=83.63 dec=22.01 rad=2.0'+ \
91 94 ' emin=0.1 emax=100.0'+ \
... ... @@ -105,8 +108,8 @@ class Test(test):
105 108 """
106 109 # Set-up ctcubemask
107 110 mask = ctools.ctcubemask()
108   - mask['inobs'] = 'data/crab_cntmap.fits'
109   - mask['regfile'] = 'data/exclusion.reg'
  111 + mask['inobs'] = self._cntcube
  112 + mask['regfile'] = self._exclusion
110 113 mask['outcube'] = 'ctcubemask_py1.fits'
111 114 mask['ra'] = 83.63
112 115 mask['dec'] = 22.01
... ...
test/test_ctedispcube.py
... ... @@ -65,10 +65,10 @@ class Test(test):
65 65 ctedispcube = self._tool('ctedispcube')
66 66  
67 67 # Setup ctedispcube command
68   - cmd = ctedispcube+' inobs="data/crab_events.fits"'+ \
  68 + cmd = ctedispcube+' inobs="'+self._events+'"'+ \
69 69 ' incube="NONE"'+ \
70 70 ' outcube="ctedispcube_cmd1.fits"'+ \
71   - ' caldb="prod2" irf="South_0.5h"'+ \
  71 + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \
72 72 ' ebinalg="LOG" emin=0.1 emax=100.0 enumbins=20'+ \
73 73 ' nxpix=10 nypix=10 binsz=0.4'+ \
74 74 ' coordsys="CEL" proj="CAR" xref=83.63 yref=22.01'+ \
... ... @@ -90,7 +90,7 @@ class Test(test):
90 90 cmd = ctedispcube+' inobs="events_that_do_not_exist.fits"'+ \
91 91 ' incube="NONE"'+ \
92 92 ' outcube="ctedispcube_cmd2.fits"'+ \
93   - ' caldb="prod2" irf="South_0.5h"'+ \
  93 + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \
94 94 ' ebinalg="LOG" emin=0.1 emax=100.0 enumbins=20'+ \
95 95 ' nxpix=10 nypix=10 binsz=0.4'+ \
96 96 ' coordsys="CEL" proj="CAR" xref=83.63 yref=22.01'+ \
... ... @@ -111,11 +111,11 @@ class Test(test):
111 111 """
112 112 # Set-up ctedispcube
113 113 edispcube = ctools.ctedispcube()
114   - edispcube['inobs'] = 'data/crab_events.fits'
  114 + edispcube['inobs'] = self._events
115 115 edispcube['incube'] = 'NONE'
116 116 edispcube['outcube'] = 'ctedispcube_py1.fits'
117   - edispcube['caldb'] = 'prod2'
118   - edispcube['irf'] = 'South_0.5h'
  117 + edispcube['caldb'] = self._caldb
  118 + edispcube['irf'] = self._irf
119 119 edispcube['ebinalg'] = 'LOG'
120 120 edispcube['emin'] = 0.1
121 121 edispcube['emax'] = 100
... ...
test/test_cterror.py
... ... @@ -38,13 +38,6 @@ class Test(test):
38 38 # Call base class constructor
39 39 test.__init__(self)
40 40  
41   - # Set members
42   - self.events_name = 'data/crab_events.fits'
43   - self.model_name = 'data/crab.xml'
44   - self.result_name = 'cterror_result.xml'
45   - self.caldb = 'irf'
46   - self.irf = 'cta_dummy_irf'
47   -
48 41 # Return
49 42 return
50 43  
... ... @@ -72,9 +65,9 @@ class Test(test):
72 65 cterror = self._tool('cterror')
73 66  
74 67 # Setup cterror command
75   - cmd = cterror+' inobs="data/crab_events.fits"'+ \
76   - ' inmodel="data/crab.xml" srcname="Crab"'+ \
77   - ' caldb="prod2" irf="South_0.5h"'+ \
  68 + cmd = cterror+' inobs="'+self._events+'"'+ \
  69 + ' inmodel="'+self._model+'" srcname="Crab"'+ \
  70 + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \
78 71 ' outmodel="cterror_cmd1.xml"'+ \
79 72 ' logfile="cterror_cmd1.log" chatter=1'
80 73  
... ... @@ -91,8 +84,8 @@ class Test(test):
91 84  
92 85 # Setup cterror command
93 86 cmd = cterror+' inobs="event_file_that_does_not_exist.fits"'+ \
94   - ' inmodel="data/crab.xml" srcname="Crab"'+ \
95   - ' caldb="prod2" irf="South_0.5h"'+ \
  87 + ' inmodel="'+self._model+'" srcname="Crab"'+ \
  88 + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \
96 89 ' outmodel="cterror_cmd2.xml"'+ \
97 90 ' logfile="cterror_cmd2.log" chatter=1'
98 91  
... ... @@ -110,12 +103,12 @@ class Test(test):
110 103 """
111 104 # Set-up cterror
112 105 error = ctools.cterror()
113   - error['inobs'] = 'data/crab_events.fits'
114   - error['inmodel'] = 'data/crab.xml'
  106 + error['inobs'] = self._events
  107 + error['inmodel'] = self._model
115 108 error['outmodel'] = 'cterror_py1.xml'
116 109 error['srcname'] = 'Crab'
117   - error['caldb'] = 'prod2'
118   - error['irf'] = 'South_0.5h'
  110 + error['caldb'] = self._caldb
  111 + error['irf'] = self._irf
119 112 error['logfile'] = 'cterror_py1.log'
120 113 error['chatter'] = 2
121 114  
... ...
test/test_ctexpcube.py
... ... @@ -65,10 +65,10 @@ class Test(test):
65 65 ctexpcube = self._tool('ctexpcube')
66 66  
67 67 # Setup ctexpcube command
68   - cmd = ctexpcube+' inobs="data/crab_events.fits"'+ \
  68 + cmd = ctexpcube+' inobs="'+self._events+'"'+ \
69 69 ' incube="NONE"'+ \
70 70 ' outcube="ctexpcube_cmd1.fits"'+ \
71   - ' caldb="prod2" irf="South_0.5h"'+ \
  71 + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \
72 72 ' ebinalg="LOG" emin=0.1 emax=100.0 enumbins=20'+ \
73 73 ' nxpix=200 nypix=200 binsz=0.02'+ \
74 74 ' coordsys="CEL" proj="CAR" xref=83.63 yref=22.01'+ \
... ... @@ -89,7 +89,7 @@ class Test(test):
89 89 cmd = ctexpcube+' inobs="event_file_that_does_not_exist.fits"'+ \
90 90 ' incube="NONE"'+ \
91 91 ' outcube="ctexpcube_cmd2.fits"'+ \
92   - ' caldb="prod2" irf="South_0.5h"'+ \
  92 + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \
93 93 ' ebinalg="LOG" emin=0.1 emax=100.0 enumbins=20'+ \
94 94 ' nxpix=200 nypix=200 binsz=0.02'+ \
95 95 ' coordsys="CEL" proj="CAR" xref=83.63 yref=22.01'+ \
... ... @@ -109,11 +109,11 @@ class Test(test):
109 109 """
110 110 # Set-up ctexpcube
111 111 expcube = ctools.ctexpcube()
112   - expcube['inobs'] = 'data/crab_events.fits'
  112 + expcube['inobs'] = self._events
113 113 expcube['incube'] = 'NONE'
114 114 expcube['outcube'] = 'ctexpcube_py1.fits'
115   - expcube['caldb'] = 'prod2'
116   - expcube['irf'] = 'South_0.5h'
  115 + expcube['caldb'] = self._caldb
  116 + expcube['irf'] = self._irf
117 117 expcube['ebinalg'] = 'LOG'
118 118 expcube['emin'] = 0.1
119 119 expcube['emax'] = 100
... ...
test/test_ctlike.py
... ... @@ -65,9 +65,9 @@ class Test(test):
65 65 ctlike = self._tool('ctlike')
66 66  
67 67 # Setup ctlike command
68   - cmd = ctlike+' inobs="data/crab_events.fits"'+ \
69   - ' inmodel="data/crab.xml"'+ \
70   - ' caldb="prod2" irf="South_0.5h"'+ \
  68 + cmd = ctlike+' inobs="'+self._events+'"'+ \
  69 + ' inmodel="'+self._model+'"'+ \
  70 + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \
71 71 ' outmodel="ctlike_cmd1.xml"'+ \
72 72 ' logfile="ctlike_cmd1.log" chatter=1'
73 73  
... ... @@ -84,8 +84,8 @@ class Test(test):
84 84  
85 85 # Setup ctlike command
86 86 cmd = ctlike+' inobs="event_file_that_does_not_exist.fits"'+ \
87   - ' inmodel="data/crab.xml"'+ \
88   - ' caldb="prod2" irf="South_0.5h"'+ \
  87 + ' inmodel="'+self._model+'"'+ \
  88 + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \
89 89 ' outmodel="ctlike_cmd2.xml"'+ \
90 90 ' logfile="ctlike_cmd2.log" chatter=1'
91 91  
... ... @@ -103,10 +103,10 @@ class Test(test):
103 103 """
104 104 # Set-up ctlike
105 105 like = ctools.ctlike()
106   - like['inobs'] = 'data/crab_events.fits'
107   - like['inmodel'] = 'data/crab.xml'
108   - like['caldb'] = 'prod2'
109   - like['irf'] = 'South_0.5h'
  106 + like['inobs'] = self._events
  107 + like['inmodel'] = self._model
  108 + like['caldb'] = self._caldb
  109 + like['irf'] = self._irf
110 110 like['outmodel'] = 'ctlike_py1.xml'
111 111 like['logfile'] = 'ctlike_py1.log'
112 112 like['chatter'] = 2
... ...
test/test_ctmapcube.py
... ... @@ -42,9 +42,6 @@ class Test(test):
42 42 # Call base class constructor
43 43 test.__init__(self)
44 44  
45   - # Set members
46   - self._model_name = 'data/crab.xml'
47   -
48 45 # Return
49 46 return
50 47  
... ... @@ -72,7 +69,7 @@ class Test(test):
72 69 ctmapcube = self._tool('ctmapcube')
73 70  
74 71 # Setup ctmapcube command
75   - cmd = ctmapcube+' inmodel="'+self._model_name+'"'+ \
  72 + cmd = ctmapcube+' inmodel="'+self._model+'"'+ \
76 73 ' outcube="ctmapcube_cmd1.fits"'+\
77 74 ' emin=0.1 emax=100.0 enumbins=20 ebinalg=LOG'+ \
78 75 ' nxpix=200 nypix=200 binsz=0.02 coordsys=CEL'+ \
... ... @@ -112,7 +109,7 @@ class Test(test):
112 109 """
113 110 # Set-up ctmapcube
114 111 mapcube = ctools.ctmapcube()
115   - mapcube['inmodel'] = self._model_name
  112 + mapcube['inmodel'] = self._model
116 113 mapcube['outcube'] = 'ctmapcube_py1.fits'
117 114 mapcube['ebinalg'] = 'LOG'
118 115 mapcube['emin'] = 0.1
... ...
test/test_ctmodel.py
... ... @@ -68,8 +68,8 @@ class Test(test):
68 68 cmd = ctmodel+' incube="NONE" inobs="NONE" expcube="NONE"'+\
69 69 ' psfcube="NONE" bkgcube="NONE"'+ \
70 70 ' outcube="ctmodel_cmd1.fits"'+ \
71   - ' inmodel="data/crab.xml"'+ \
72   - ' caldb="prod2" irf="South_0.5h"'+ \
  71 + ' inmodel="'+self._model+'"'+ \
  72 + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \
73 73 ' rad=5.0 ra=83.63 dec=22.01 tmin=0.0 tmax=1800'+ \
74 74 ' emin=0.1 emax=100.0 enumbins=20 nxpix=200 nypix=200'+ \
75 75 ' binsz=0.02 coordsys="CEL" proj="CAR"'+ \
... ... @@ -92,7 +92,7 @@ class Test(test):
92 92 ' psfcube="NONE" bkgcube="NONE"'+ \
93 93 ' outcube="ctmodel_cmd2.fits"'+ \
94 94 ' inmodel="model_that_does_not_exist.xml"'+ \
95   - ' caldb="prod2" irf="South_0.5h"'+ \
  95 + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \
96 96 ' rad=5.0 ra=83.63 dec=22.01 tmin=0.0 tmax=1800'+ \
97 97 ' emin=0.1 emax=100.0 enumbins=20 nxpix=200 nypix=200'+ \
98 98 ' binsz=0.02 coordsys="CEL" proj="CAR"'+ \
... ... @@ -115,13 +115,13 @@ class Test(test):
115 115 model = ctools.ctmodel()
116 116 model['incube'] = 'NONE'
117 117 model['outcube'] = 'ctmodel_py1.fits'
118   - model['inmodel'] = 'data/crab.xml'
  118 + model['inmodel'] = self._model
119 119 model['inobs'] = 'NONE'
120 120 model['expcube'] = 'NONE'
121 121 model['psfcube'] = 'NONE'
122 122 model['bkgcube'] = 'NONE'
123   - model['caldb'] = 'prod2'
124   - model['irf'] = 'South_0.5h'
  123 + model['caldb'] = self._caldb
  124 + model['irf'] = self._irf
125 125 model['rad'] = 5
126 126 model['ra'] = 83.63
127 127 model['dec'] = 22.01
... ...
test/test_ctobssim.py
... ... @@ -43,11 +43,6 @@ class Test(test):
43 43 # Call base class constructor
44 44 test.__init__(self)
45 45  
46   - # Set members
47   - self._model_name = 'data/crab.xml'
48   - self._caldb = 'irf'
49   - self._irf = 'cta_dummy_irf'
50   -
51 46 # Return
52 47 return
53 48  
... ... @@ -75,8 +70,9 @@ class Test(test):
75 70 ctobssim = self._tool('ctobssim')
76 71  
77 72 # Setup ctobssim command
78   - cmd = ctobssim+' inmodel="data/crab.xml" outevents="events.fits"'+ \
79   - ' caldb="irf" irf="cta_dummy_irf" '+ \
  73 + cmd = ctobssim+' inmodel="'+self._model+'" '+ \
  74 + ' outevents="events.fits"'+ \
  75 + ' caldb="'+self._caldb+'" irf="'+self._irf+'" '+ \
80 76 ' ra=83.63 dec=22.01 rad=10.0'+ \
81 77 ' tmin=0.0 tmax=1800.0 emin=0.1 emax=100.0'
82 78  
... ... @@ -90,12 +86,12 @@ class Test(test):
90 86  
91 87 # Load counts cube and check content.
92 88 evt = gammalib.GCTAEventList('events.fits')
93   - self._test_list(evt, 4119)
  89 + self._test_list(evt, 6881)
94 90  
95 91 # Setup ctobssim command
96 92 cmd = ctobssim+' inmodel="model_that_does_not_exist.xml"'+ \
97 93 ' outevents="events.fits"'+ \
98   - ' caldb="irf" irf="cta_dummy_irf" '+ \
  94 + ' caldb="'+self._caldb+'" irf="'+self._irf+'" '+ \
99 95 ' ra=83.63 dec=22.01 rad=10.0'+ \
100 96 ' tmin=0.0 tmax=1800.0 emin=0.1 emax=100.0'
101 97  
... ... @@ -113,7 +109,7 @@ class Test(test):
113 109 """
114 110 # Set-up ctobssim
115 111 sim = ctools.ctobssim()
116   - sim['inmodel'] = self._model_name
  112 + sim['inmodel'] = self._model
117 113 sim['outevents'] = 'events.fits'
118 114 sim['caldb'] = self._caldb
119 115 sim['irf'] = self._irf
... ... @@ -130,14 +126,14 @@ class Test(test):
130 126  
131 127 # Check content of observation
132 128 self._test_observation(sim)
133   - self._test_list(sim.obs()[0].events(), 4119)
  129 + self._test_list(sim.obs()[0].events(), 6881)
134 130  
135 131 # Save events
136 132 sim.save()
137 133  
138 134 # Load counts cube and check content.
139 135 evt = gammalib.GCTAEventList('events.fits')
140   - self._test_list(evt, 4119)
  136 + self._test_list(evt, 6881)
141 137  
142 138 # Set-up observation container
143 139 pnts = [{'ra': 83.63, 'dec': 21.01},
... ... @@ -149,17 +145,17 @@ class Test(test):
149 145 # Set-up ctobssim from observation container
150 146 sim = ctools.ctobssim(obs)
151 147 sim['outevents'] = 'sim_events.xml'
152   - sim['inmodel'] = self._model_name
  148 + sim['inmodel'] = self._model
153 149  
154 150 # Run tool
155 151 sim.run()
156 152  
157 153 # Retrieve observation and check content
158 154 self._test_observation(sim, nobs=4, pnts=pnts)
159   - self._test_list(sim.obs()[0].events(), 4063)
160   - self._test_list(sim.obs()[1].events(), 4059)
161   - self._test_list(sim.obs()[2].events(), 4010)
162   - self._test_list(sim.obs()[3].events(), 4138)
  155 + self._test_list(sim.obs()[0].events(), 6003)
  156 + self._test_list(sim.obs()[1].events(), 6084)
  157 + self._test_list(sim.obs()[2].events(), 5955)
  158 + self._test_list(sim.obs()[3].events(), 6030)
163 159  
164 160 # Save events
165 161 sim.save()
... ... @@ -168,10 +164,10 @@ class Test(test):
168 164 obs = gammalib.GObservations('sim_events.xml')
169 165  
170 166 # Retrieve observation and check content
171   - self._test_list(obs[0].events(), 4063)
172   - self._test_list(obs[1].events(), 4059)
173   - self._test_list(obs[2].events(), 4010)
174   - self._test_list(obs[3].events(), 4138)
  167 + self._test_list(obs[0].events(), 6003)
  168 + self._test_list(obs[1].events(), 6084)
  169 + self._test_list(obs[2].events(), 5955)
  170 + self._test_list(obs[3].events(), 6030)
175 171  
176 172 # Set-up ctobssim with invalid event file
177 173 sim = ctools.ctobssim()
... ...
test/test_ctools.sh deleted
1   -#! /bin/sh
2   -# ==========================================================================
3   -# This script tests all ctools
4   -#
5   -# Copyright (C) 2011-2016 Juergen Knoedlseder
6   -#
7   -# This program is free software: you can redistribute it and/or modify
8   -# it under the terms of the GNU General Public License as published by
9   -# the Free Software Foundation, either version 3 of the License, or
10   -# (at your option) any later version.
11   -#
12   -# This program is distributed in the hope that it will be useful,
13   -# but WITHOUT ANY WARRANTY; without even the implied warranty of
14   -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15   -# GNU General Public License for more details.
16   -#
17   -# You should have received a copy of the GNU General Public License
18   -# along with this program. If not, see <http://www.gnu.org/licenses/>.
19   -#
20   -# ==========================================================================
21   -
22   -#
23   -# Get echo command (to circumvent built-in echo on some systems)
24   -#
25   -ECHO=`which echo`
26   -
27   -#
28   -# Print Header
29   -#
30   -$ECHO "***************"
31   -$ECHO "* Test ctools *"
32   -$ECHO "***************"
33   -
34   -#
35   -# Define executables
36   -# ==================
37   -ctbin=../src/ctbin/ctbin
38   -ctlike=../src/ctlike/ctlike
39   -cttsmap=../src/cttsmap/cttsmap
40   -ctmodel=../src/ctmodel/ctmodel
41   -ctobssim=../src/ctobssim/ctobssim
42   -ctselect=../src/ctselect/ctselect
43   -ctskymap=../src/ctskymap/ctskymap
44   -ctexpcube=../src/ctexpcube/ctexpcube
45   -ctpsfcube=../src/ctpsfcube/ctpsfcube
46   -ctedispcube=../src/ctedispcube/ctedispcube
47   -ctbkgcube=../src/ctbkgcube/ctbkgcube
48   -ctcubemask=../src/ctcubemask/ctcubemask
49   -ctbutterfly=../src/ctbutterfly/ctbutterfly
50   -ctulimit=../src/ctulimit/ctulimit
51   -cterror=../src/cterror/cterror
52   -
53   -
54   -#
55   -# Remove any existing result files
56   -# ================================
57   -rm -rf *.fits *.xml
58   -rm -rf ulimit.dat butterfly.txt
59   -
60   -
61   -#
62   -# Creates pfiles directory
63   -# ========================
64   -rm -rf pfiles
65   -mkdir -p pfiles
66   -cp -r ../src/*/*.par pfiles/
67   -export PFILES=pfiles
68   -
69   -
70   -#
71   -# Test ctobssim
72   -# =============
73   -$ECHO -n "Test ctobssim: "
74   -
75   -#
76   -# Run 1
77   -$ctobssim inmodel="data/crab.xml" \
78   - outevents="events.fits" \
79   - caldb="irf" \
80   - irf="cta_dummy_irf" \
81   - ra=83.63 \
82   - dec=22.01 \
83   - rad=10.0 \
84   - tmin=0.0 \
85   - tmax=1800.0 \
86   - emin=0.1 \
87   - emax=100.0
88   -$ECHO -n "."
89   -if [ -s "events.fits" ]
90   -then
91   - $ECHO -n "."
92   -else
93   - echo " events.fits file is not found"
94   - exit 1
95   -fi
96   -$ECHO " ok"
97   -
98   -
99   -#
100   -# Test ctskymap
101   -# =============
102   -$ECHO -n "Test ctskymap: "
103   -$ctskymap inobs="events.fits" \
104   - outmap="skymap.fits" \
105   - emin=0.1 \
106   - emax=100.0 \
107   - nxpix=200 \
108   - nypix=200 \
109   - binsz=0.02 \
110   - coordsys="CEL" \
111   - xref=83.63 \
112   - yref=22.01 \
113   - proj="CAR"
114   -$ECHO -n "."
115   -if [ -s "skymap.fits" ]
116   -then
117   - $ECHO -n "."
118   -else
119   - $ECHO " skymap.fits file is not found"
120   - exit 1
121   -fi
122   -$ECHO " ok"
123   -
124   -
125   -#
126   -# Test ctbin
127   -# ==========
128   -$ECHO -n "Test ctbin: "
129   -#
130   -# Run 1
131   -$ctbin inobs="events.fits" \
132   - outcube="cntmap1.fits" \
133   - emin=0.1 \
134   - emax=100.0 \
135   - enumbins=20 \
136   - ebinalg="LOG" \
137   - nxpix=200 \
138   - nypix=200 \
139   - binsz=0.02 \
140   - coordsys="CEL" \
141   - xref=83.63 \
142   - yref=22.01 \
143   - proj="CAR"
144   -$ECHO -n "."
145   -if [ -s "cntmap1.fits" ]
146   -then
147   - $ECHO -n "."
148   -else
149   - $ECHO " cntmap1.fits file is not found"
150   - exit 1
151   -fi
152   -#
153   -# Run 2
154   -$ctbin inobs="events.fits" \
155   - outcube="cntmap2.fits" \
156   - emin=0.3 \
157   - emax=8.0 \
158   - enumbins=7 \
159   - ebinalg="LOG" \
160   - nxpix=30 \
161   - nypix=30 \
162   - binsz=0.05 \
163   - coordsys="CEL" \
164   - xref=86.63 \
165   - yref=22.01 \
166   - proj="CAR"
167   -$ECHO -n "."
168   -if [ -s "cntmap2.fits" ]
169   -then
170   - $ECHO -n "."
171   -else
172   - $ECHO " cntmap2.fits file is not found"
173   - exit 1
174   -fi
175   -$ECHO " ok"
176   -
177   -#
178   -# Test ctexpcube
179   -# ==============
180   -$ECHO -n "Test ctexpcube: "
181   -#
182   -# Run 1
183   -$ctexpcube inobs="data/crab_events.fits" \
184   - incube="NONE" \
185   - outcube="expcube1.fits" \
186   - caldb="irf" \
187   - irf="cta_dummy_irf" \
188   - emin=0.1 \
189   - emax=100.0 \
190   - enumbins=20 \
191   - nxpix=200 \
192   - nypix=200 \
193   - binsz=0.02 \
194   - coordsys="CEL" \
195   - xref=83.63 \
196   - yref=22.01 \
197   - proj="CAR"
198   -$ECHO -n "."
199   -if [ -s "expcube1.fits" ]
200   -then
201   -$ECHO -n "."
202   -else
203   -$ECHO " expcube1.fits file is not found"
204   -exit 1
205   -fi
206   -#
207   -# Run 2
208   -$ctexpcube inobs="events.fits" \
209   - incube="cntmap2.fits" \
210   - outcube="expcube2.fits" \
211   - caldb="irf" \
212   - irf="cta_dummy_irf"
213   -$ECHO -n "."
214   -if [ -s "expcube2.fits" ]
215   -then
216   -$ECHO -n "."
217   -else
218   -$ECHO " expcube2.fits file is not found"
219   -exit 1
220   -fi
221   -$ECHO " ok"
222   -
223   -
224   -#
225   -# Test ctpsfcube
226   -# ==============
227   -$ECHO -n "Test ctpsfcube: "
228   -#
229   -# Run 1
230   -$ctpsfcube inobs="data/crab_events.fits" \
231   - incube="NONE" \
232   - outcube="psfcube1.fits" \
233   - caldb="irf" \
234   - irf="cta_dummy_irf" \
235   - emin=0.1 \
236   - emax=100.0 \
237   - enumbins=20 \
238   - nxpix=10 \
239   - nypix=10 \
240   - binsz=0.4 \
241   - coordsys="CEL" \
242   - xref=83.63 \
243   - yref=22.01 \
244   - proj="CAR" \
245   - amax=0.3 \
246   - anumbins=10
247   -$ECHO -n "."
248   -if [ -s "psfcube1.fits" ]
249   -then
250   -$ECHO -n "."
251   -else
252   -$ECHO " psfcube1.fits file is not found"
253   -exit 1
254   -fi
255   -#
256   -# Run 2
257   -$ctpsfcube inobs="events.fits" \
258   - incube="cntmap2.fits" \
259   - outcube="psfcube2.fits" \
260   - caldb="irf" \
261   - irf="cta_dummy_irf" \
262   - amax=0.3 \
263   - anumbins=2
264   -$ECHO -n "."
265   -if [ -s "psfcube2.fits" ]
266   -then
267   -$ECHO -n "."
268   -else
269   -$ECHO " psfcube2.fits file is not found"
270   -exit 1
271   -fi
272   -$ECHO " ok"
273   -
274   -
275   -#
276   -# Test ctedispcube
277   -# ==============
278   -$ECHO -n "Test ctedispcube: "
279   -#
280   -# Run 1
281   -$ctedispcube inobs="data/crab_events.fits" \
282   - incube="NONE" \
283   - outcube="edispcube1.fits" \
284   - caldb="irf" \
285   - irf="cta_dummy_irf" \
286   - emin=0.1 \
287   - emax=100.0 \
288   - enumbins=20 \
289   - nxpix=10 \
290   - nypix=10 \
291   - binsz=0.4 \
292   - coordsys="CEL" \
293   - xref=83.63 \
294   - yref=22.01 \
295   - proj="CAR" \
296   - migramax=3.0 \
297   - migrabins=10
298   -$ECHO -n "."
299   -if [ -s "edispcube1.fits" ]
300   -then
301   -$ECHO -n "."
302   -else
303   -$ECHO " edispcube1.fits file is not found"
304   -exit 1
305   -fi
306   -#
307   -# Run 2
308   -$ctedispcube inobs="events.fits" \
309   - incube="cntmap2.fits" \
310   - outcube="edispcube2.fits" \
311   - caldb="irf" \
312   - irf="cta_dummy_irf" \
313   - migramax=3.0 \
314   - migrabins=3
315   -$ECHO -n "."
316   -if [ -s "edispcube2.fits" ]
317   -then
318   -$ECHO -n "."
319   -else
320   -$ECHO " edispcube2.fits file is not found"
321   -exit 1
322   -fi
323   -$ECHO " ok"
324   -
325   -
326   -#
327   -# Test ctbkgcube
328   -# ==============
329   -$ECHO -n "Test ctbkgcube: "
330   -#
331   -# Run 1
332   -$ctbkgcube inobs="data/crab_events.fits" \
333   - inmodel="data/crab.xml" \
334   - incube="NONE" \
335   - outcube="bkgcube1.fits" \
336   - outmodel="bkgcube1.xml" \
337   - caldb="irf" \
338   - irf="cta_dummy_irf" \
339   - emin=0.1 \
340   - emax=100.0 \
341   - enumbins=20 \
342   - nxpix=10 \
343   - nypix=10 \
344   - binsz=0.4 \
345   - coordsys="CEL" \
346   - xref=83.63 \
347   - yref=22.01 \
348   - proj="CAR"
349   -$ECHO -n "."
350   -if [ -s "bkgcube1.fits" ]
351   -then
352   -$ECHO -n "."
353   -else
354   -$ECHO " bkgcube1.fits file is not found"
355   -exit 1
356   -fi
357   -if [ -s "bkgcube1.xml" ]
358   -then
359   -$ECHO -n "."
360   -else
361   -$ECHO " bkgcube1.xml file is not found"
362   -exit 1
363   -fi
364   -#
365   -# Run 2
366   -$ctbkgcube inobs="events.fits" \
367   - inmodel="data/crab.xml" \
368   - incube="cntmap2.fits" \
369   - caldb="irf" \
370   - irf="cta_dummy_irf" \
371   - outcube="bkgcube2.fits" \
372   - outmodel="bkgcube2.xml"
373   -$ECHO -n "."
374   -if [ -s "bkgcube2.fits" ]
375   -then
376   -$ECHO -n "."
377   -else
378   -$ECHO " bkgcube2.fits file is not found"
379   -exit 1
380   -fi
381   -if [ -s "bkgcube2.fits" ]
382   -then
383   -$ECHO -n "."
384   -else
385   -$ECHO " bkgcube2.xml file is not found"
386   -exit 1
387   -fi
388   -$ECHO " ok"
389   -
390   -
391   -#
392   -# Test ctmodel
393   -# ============
394   -$ECHO -n "Test ctmodel: "
395   -#
396   -# Run 1
397   -$ctmodel inobs="cntmap1.fits" \
398   - incube="cntmap1.fits" \
399   - outcube="modmap1.fits" \
400   - expcube="NONE" \
401   - psfcube="NONE" \
402   - bkgcube="NONE" \
403   - edispcube="NONE" \
404   - caldb="irf" \
405   - irf="cta_dummy_irf" \
406   - inmodel="data/crab.xml"
407   -$ECHO -n "."
408   -if [ -s "modmap1.fits" ]
409   -then
410   - $ECHO -n "."
411   -else
412   - $ECHO " modmap1.fits file is not found"
413   - exit 1
414   -fi
415   -
416   -#
417   -# Run 2
418   -$ctmodel inobs="cntmap2.fits" \
419   - incube="cntmap2.fits" \
420   - outcube="modmap2.fits" \
421   - expcube="expcube2.fits" \
422   - psfcube="psfcube2.fits" \
423   - edispcube="edispcube2.fits" \
424   - bkgcube="bkgcube2.fits" \
425   - caldb="irf" \
426   - irf="cta_dummy_irf" \
427   - inmodel="bkgcube2.xml"
428   -$ECHO -n "."
429   -if [ -s "modmap2.fits" ]
430   -then
431   -$ECHO -n "."
432   -else
433   -$ECHO " modmap2.fits file is not found"
434   -exit 1
435   -fi
436   -
437   -#
438   -# Run 3
439   -$ctmodel inobs="NONE" \
440   - incube="NONE" \
441   - outcube="modmap3.fits" \
442   - expcube="NONE" \
443   - psfcube="NONE" \
444   - edispcube="NONE" \
445   - bkgcube="NONE" \
446   - caldb="irf" \
447   - irf="cta_dummy_irf" \
448   - inmodel="data/crab.xml" \
449   - ra=83.63 \
450   - dec=22.01 \
451   - rad=10.0 \
452   - tmin=0.0 \
453   - tmax=1800.0 \
454   - emin=0.1 \
455   - emax=100.0 \
456   - enumbins=20 \
457   - nxpix=200 \
458   - nypix=200 \
459   - binsz=0.02 \
460   - coordsys="CEL" \
461   - xref=83.63 \
462   - yref=22.01 \
463   - proj="CAR"
464   -$ECHO -n "."
465   -if [ -s "modmap3.fits" ]
466   -then
467   - $ECHO -n "."
468   -else
469   - $ECHO " modmap3.fits file is not found"
470   - exit 1
471   -fi
472   -$ECHO " ok"
473   -
474   -
475   -#
476   -# Test ctselect
477   -# =============
478   -$ECHO -n "Test ctselect: "
479   -$ctselect inobs="events.fits" \
480   - outobs="selected_events.fits" \
481   - ra=83.63 \
482   - dec=22.01 \
483   - rad=10.0 \
484   - tmin=0.0 \
485   - tmax=1800.0 \
486   - emin=0.1 \
487   - emax=100.0
488   -$ECHO -n "."
489   -if [ -s "selected_events.fits" ]
490   -then
491   - $ECHO -n "."
492   -else
493   - $ECHO " selected_events.fits file is not found"
494   - exit 1
495   -fi
496   -$ECHO " ok"
497   -
498   -
499   -#
500   -# Test ctlike
501   -# ===========
502   -$ECHO -n "Test ctlike: "
503   -#
504   -# Run 1
505   -$ctlike inobs="cntmap1.fits" \
506   - inmodel="data/crab.xml" \
507   - outmodel="results_binned.xml" \
508   - expcube="NONE" \
509   - psfcube="NONE" \
510   - edispcube="NONE" \
511   - bkgcube="NONE" \
512   - caldb="irf" \
513   - irf="cta_dummy_irf"
514   -$ECHO -n "."
515   -if [ -s "results_binned.xml" ]
516   -then
517   - $ECHO -n "."
518   -else
519   - $ECHO " results_binned.xml file is not found"
520   - exit 1
521   -fi
522   -#
523   -# Run 2
524   -$ctlike inobs="selected_events.fits" \
525   - inmodel="data/crab.xml" \
526   - outmodel="results_unbinned.xml" \
527   - caldb="irf" \
528   - irf="cta_dummy_irf"
529   -$ECHO -n "."
530   -if [ -s "results_unbinned.xml" ]
531   -then
532   - $ECHO -n "."
533   -else
534   - $ECHO " results_unbinned.xml file is not found"
535   - exit 1
536   -fi
537   -
538   -#
539   -# Run 3
540   -$ctlike inobs="cntmap2.fits" \
541   - inmodel="bkgcube2.xml" \
542   - outmodel="results_binned_cube_background.xml" \
543   - expcube="expcube2.fits" \
544   - psfcube="psfcube2.fits" \
545   - edispcube="NONE" \
546   - bkgcube="bkgcube2.fits" \
547   - caldb="irf" \
548   - irf="cta_dummy_irf"
549   -$ECHO -n "."
550   -if [ -s "results_binned_cube_background.xml" ]
551   -then
552   - $ECHO -n "."
553   -else
554   - $ECHO " results_binned_cube_background.xml file is not found"
555   - exit 1
556   -fi
557   -
558   -
559   -#
560   -# Run 4
561   -$ctlike inobs="cntmap2.fits" \
562   - inmodel="bkgcube2.xml" \
563   - outmodel="results_binned_cube_background_edisp.xml" \
564   - expcube="expcube2.fits" \
565   - psfcube="psfcube2.fits" \
566   - edispcube="edispcube2.fits" \
567   - bkgcube="bkgcube2.fits" \
568   - edisp="yes"
569   - caldb="irf" \
570   - irf="cta_dummy_irf"
571   -$ECHO -n "."
572   -if [ -s "results_binned_cube_background_edisp.xml" ]
573   -then
574   - $ECHO -n "."
575   -else
576   - $ECHO " results_binned_cube_background_edisp.xml file is not found"
577   - exit 1
578   -fi
579   -$ECHO " ok"
580   -
581   -
582   -#
583   -# Test cttsmap
584   -# ============
585   -$ECHO -n "Test cttsmap: "
586   -$cttsmap inobs="selected_events.fits" \
587   - inmodel="data/crab.xml" \
588   - srcname="Crab" \
589   - caldb="irf" \
590   - irf="cta_dummy_irf" \
591   - outmap="tsmap.fits" \
592   - nxpix=5 \
593   - nypix=5 \
594   - binsz=0.05 \
595   - coordsys="CEL" \
596   - xref=83.63 \
597   - yref=22.01 \
598   - proj="CAR"
599   -$ECHO -n "."
600   -if [ -s "tsmap.fits" ]
601   -then
602   - $ECHO -n "."
603   -else
604   - $ECHO " tsmap.fits file is not found"
605   - exit 1
606   -fi
607   -$ECHO " ok"
608   -
609   -
610   -#
611   -# Test ctcubemask
612   -# ===============
613   -$ECHO -n "Test ctcubemask: "
614   -$ctcubemask inobs="data/crab_cntmap.fits" \
615   - regfile="data/exclusion.reg" \
616   - outcube="filtered_cube.fits" \
617   - ra=83.63 \
618   - dec=22.01 \
619   - rad=2.0 \
620   - emin=0.1 \
621   - emax=100.0
622   -$ECHO -n "."
623   -if [ -s "filtered_cube.fits" ]
624   -then
625   - $ECHO -n "."
626   -else
627   - $ECHO " filtered_cube.fits file is not found"
628   - exit 1
629   -fi
630   -$ECHO " ok"
631   -
632   -
633   -#
634   -# Test ctbutterfly
635   -# ===============
636   -$ECHO -n "Test ctbutterfly: "
637   -$ctbutterfly inobs="data/crab_events.fits.gz" \
638   - inmodel="data/crab.xml" \
639   - srcname="Crab" \
640   - outfile="butterfly.txt" \
641   - caldb="irf" \
642   - irf="cta_dummy_irf" \
643   - emin=0.1 \
644   - emax=100.0
645   -$ECHO -n "."
646   -if [ -s "butterfly.txt" ]
647   -then
648   - $ECHO -n "."
649   -else
650   - $ECHO " butterfly.txt file is not found"
651   - exit 1
652   -fi
653   -$ECHO " ok"
654   -
655   -
656   -#
657   -# Test ctulimit
658   -# ===============
659   -$ECHO -n "Test ctulimit: "
660   -$ctulimit inobs="data/crab_events.fits.gz" \
661   - inmodel="data/crab.xml" \
662   - srcname="Crab" \
663   - caldb="irf" \
664   - irf="cta_dummy_irf"
665   -$ECHO -n "."
666   -if [ -s "ctulimit.log" ]
667   -then
668   - $ECHO -n "."
669   -else
670   - $ECHO " ctulimit.log file is not found"
671   - exit 1
672   -fi
673   -$ECHO " ok"
674   -
675   -
676   -#
677   -# Test cterror
678   -# ============
679   -$ECHO -n "Test cterror: "
680   -$cterror inobs="data/crab_events.fits.gz" \
681   - inmodel="data/crab.xml" \
682   - outmodel="results_error.xml" \
683   - srcname="Crab" \
684   - caldb="irf" \
685   - irf="cta_dummy_irf"
686   -$ECHO -n "."
687   -if [ -s "cterror.log" ]
688   -then
689   - $ECHO -n "."
690   -else
691   - $ECHO " cterror.log file is not found"
692   - exit 1
693   -fi
694   -$ECHO " ok"
695   -
test/test_ctpsfcube.py
... ... @@ -65,10 +65,10 @@ class Test(test):
65 65 ctpsfcube = self._tool('ctpsfcube')
66 66  
67 67 # Setup ctpsfcube command
68   - cmd = ctpsfcube+' inobs="data/crab_events.fits"'+ \
  68 + cmd = ctpsfcube+' inobs="'+self._events+'"'+ \
69 69 ' incube="NONE"'+ \
70 70 ' outcube="ctpsfcube_cmd1.fits"'+ \
71   - ' caldb="prod2" irf="South_0.5h"'+ \
  71 + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \
72 72 ' ebinalg="LOG" emin=0.1 emax=100.0 enumbins=20'+ \
73 73 ' nxpix=200 nypix=200 binsz=0.02'+ \
74 74 ' coordsys="CEL" proj="CAR" xref=83.63 yref=22.01'+ \
... ... @@ -90,7 +90,7 @@ class Test(test):
90 90 cmd = ctpsfcube+' inobs="event_file_that_does_not_exist.fits"'+ \
91 91 ' incube="NONE"'+ \
92 92 ' outcube="ctpsfcube_cmd2.fits"'+ \
93   - ' caldb="prod2" irf="South_0.5h"'+ \
  93 + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \
94 94 ' ebinalg="LOG" emin=0.1 emax=100.0 enumbins=20'+ \
95 95 ' nxpix=200 nypix=200 binsz=0.02'+ \
96 96 ' coordsys="CEL" proj="CAR" xref=83.63 yref=22.01'+ \
... ... @@ -111,11 +111,11 @@ class Test(test):
111 111 """
112 112 # Set-up ctpsfcube
113 113 psfcube = ctools.ctpsfcube()
114   - psfcube['inobs'] = 'data/crab_events.fits'
  114 + psfcube['inobs'] = self._events
115 115 psfcube['incube'] = 'NONE'
116 116 psfcube['outcube'] = 'ctpsfcube_py1.fits'
117   - psfcube['caldb'] = 'prod2'
118   - psfcube['irf'] = 'South_0.5h'
  117 + psfcube['caldb'] = self._caldb
  118 + psfcube['irf'] = self._irf
119 119 psfcube['ebinalg'] = 'LOG'
120 120 psfcube['emin'] = 0.1
121 121 psfcube['emax'] = 100
... ...
test/test_ctselect.py
... ... @@ -65,7 +65,7 @@ class Test(test):
65 65 ctselect = self._tool('ctselect')
66 66  
67 67 # Setup ctselect command
68   - cmd = ctselect+' inobs="data/crab_events.fits"'+ \
  68 + cmd = ctselect+' inobs="'+self._events+'"'+ \
69 69 ' outobs="ctselect_cmd1.fits"'+ \
70 70 ' ra=83.63 dec=22.01 rad=3.0'+ \
71 71 ' tmin=0.0 tmax=1800.0'+ \
... ... @@ -105,7 +105,7 @@ class Test(test):
105 105 """
106 106 # Set-up ctselect
107 107 select = ctools.ctselect()
108   - select['inobs'] = 'data/crab_events.fits'
  108 + select['inobs'] = self._events
109 109 select['outobs'] = 'ctselect_py1.fits'
110 110 select['ra'] = 83.63
111 111 select['dec'] = 22.01
... ...
test/test_ctskymap.py
... ... @@ -65,7 +65,7 @@ class Test(test):
65 65 ctskymap = self._tool('ctskymap')
66 66  
67 67 # Setup ctskymap command
68   - cmd = ctskymap+' inobs="data/crab_events.fits"'+\
  68 + cmd = ctskymap+' inobs="'+self._events+'"'+\
69 69 ' outmap="ctskymap_cmd1.fits"'+ \
70 70 ' emin=0.1 emax=100.0 nxpix=200 nypix=200'+ \
71 71 ' binsz=0.02 coordsys="CEL" proj="CAR"'+ \
... ... @@ -105,7 +105,7 @@ class Test(test):
105 105 """
106 106 # Set-up ctskymap
107 107 skymap = ctools.ctskymap()
108   - skymap['inobs'] = 'data/crab_events.fits'
  108 + skymap['inobs'] = self._events
109 109 skymap['outmap'] = 'ctskymap_py1.fits'
110 110 skymap['emin'] = 0.1
111 111 skymap['emax'] = 100
... ...
test/test_cttsmap.py
... ... @@ -33,7 +33,7 @@ class Test(test):
33 33 # Constructor
34 34 def __init__(self):
35 35 """
36   - Constructor.
  36 + Constructor
37 37 """
38 38 # Call base class constructor
39 39 test.__init__(self)
... ... @@ -65,9 +65,9 @@ class Test(test):
65 65 cttsmap = self._tool('cttsmap')
66 66  
67 67 # Setup cttsmap command
68   - cmd = cttsmap+' inobs="data/crab_events.fits"'+ \
69   - ' inmodel="data/crab.xml" srcname="Crab"'+ \
70   - ' caldb="prod2" irf="South_0.5h"'+ \
  68 + cmd = cttsmap+' inobs="'+self._events+'"'+ \
  69 + ' inmodel="'+self._model+'" srcname="Crab"'+ \
  70 + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \
71 71 ' outmap="cttsmap_cmd1.fits"'+ \
72 72 ' nxpix=5 nypix=5 binsz=0.02'+ \
73 73 ' coordsys="CEL" proj="CAR" xref=83.63 yref=22.01'+ \
... ... @@ -86,8 +86,8 @@ class Test(test):
86 86  
87 87 # Setup cttsmap command
88 88 cmd = cttsmap+' inobs="event_file_that_does_not_exist.fits"'+ \
89   - ' inmodel="data/crab.xml" srcname="Crab"'+ \
90   - ' caldb="prod2" irf="South_0.5h"'+ \
  89 + ' inmodel="'+self._model+'" srcname="Crab"'+ \
  90 + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \
91 91 ' outmap="cttsmap_cmd2.fits"'+ \
92 92 ' nxpix=5 nypix=5 binsz=0.02'+ \
93 93 ' coordsys="CEL" proj="CAR" xref=83.63 yref=22.01'+ \
... ... @@ -107,11 +107,11 @@ class Test(test):
107 107 """
108 108 # Set-up cttsmap
109 109 tsmap = ctools.cttsmap()
110   - tsmap['inobs'] = 'data/crab_events.fits'
111   - tsmap['inmodel'] = 'data/crab.xml'
  110 + tsmap['inobs'] = self._events
  111 + tsmap['inmodel'] = self._model
112 112 tsmap['srcname'] = 'Crab'
113   - tsmap['caldb'] = 'prod2'
114   - tsmap['irf'] = 'South_0.5h'
  113 + tsmap['caldb'] = self._caldb
  114 + tsmap['irf'] = self._irf
115 115 tsmap['outmap'] = 'cttsmap_py1.fits'
116 116 tsmap['nxpix'] = 5
117 117 tsmap['nypix'] = 5
... ...
test/test_ctulimit.py
... ... @@ -65,9 +65,9 @@ class Test(test):
65 65 ctulimit = self._tool('ctulimit')
66 66  
67 67 # Setup ctulimit command
68   - cmd = ctulimit+' inobs="data/crab_events.fits"'+ \
69   - ' inmodel="data/crab.xml" srcname="Crab"'+ \
70   - ' caldb="prod2" irf="South_0.5h"'+ \
  68 + cmd = ctulimit+' inobs="'+self._events+'"'+ \
  69 + ' inmodel="'+self._model+'" srcname="Crab"'+ \
  70 + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \
71 71 ' logfile="ctulimit_cmd1.log" chatter=1'
72 72  
73 73 # Check if execution of wrong command fails
... ... @@ -83,8 +83,8 @@ class Test(test):
83 83  
84 84 # Setup ctulimit command
85 85 cmd = ctulimit+' inobs="event_file_that_does_not_exist.fits"'+ \
86   - ' inmodel="data/crab.xml" srcname="Crab"'+ \
87   - ' caldb="prod2" irf="South_0.5h"'+ \
  86 + ' inmodel="'+self._model+'" srcname="Crab"'+ \
  87 + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \
88 88 ' logfile="ctulimit_cmd2.log" chatter=1'
89 89  
90 90 # Check if execution failed
... ... @@ -101,11 +101,11 @@ class Test(test):
101 101 """
102 102 # Set-up ctulimit
103 103 ulimit = ctools.ctulimit()
104   - ulimit['inobs'] = 'data/crab_events.fits'
105   - ulimit['inmodel'] = 'data/crab.xml'
  104 + ulimit['inobs'] = self._events
  105 + ulimit['inmodel'] = self._model
106 106 ulimit['srcname'] = 'Crab'
107   - ulimit['caldb'] = 'prod2'
108   - ulimit['irf'] = 'South_0.5h'
  107 + ulimit['caldb'] = self._caldb
  108 + ulimit['irf'] = self._irf
109 109 ulimit['logfile'] = 'ctulimit_py1.log'
110 110 ulimit['chatter'] = 2
111 111  
... ...
test/test_examples.py.in
... ... @@ -40,6 +40,9 @@ class Test(gammalib.GPythonTestSuite):
40 40 # Call base class constructor
41 41 gammalib.GPythonTestSuite.__init__(self)
42 42  
  43 + # Set test data directory
  44 + self._datadir = os.environ['TEST_DATA']
  45 +
43 46 # Return
44 47 return
45 48  
... ... @@ -58,7 +61,7 @@ class Test(gammalib.GPythonTestSuite):
58 61 String with name to be used for logging
59 62 """
60 63 # Setup command
61   - cmd = '@PYTHON_COVERAGE@../examples/' + name + '.py'
  64 + cmd = '@PYTHON_COVERAGE@@top_srcdir@/examples/' + name + '.py'
62 65 if len(args) > 0:
63 66 cmd += ' ' + args
64 67  
... ... @@ -89,26 +92,46 @@ class Test(gammalib.GPythonTestSuite):
89 92 self.name('examples')
90 93  
91 94 # Append tests
92   - self.append(self.test_generate_prod3_irfs, 'Test generate_prod3_irfs.py')
93   - self.append(self.test_make_pointings, 'Test make_pointings.py')
94   - self.append(self.test_make_spectrum, 'Test make_spectrum.py')
95   - self.append(self.test_make_ts_distributions, 'Test make_ts_distributions.py')
96   - self.append(self.test_pipeline_binned_disk, 'Test pipeline_binned_disk.py')
97   - self.append(self.test_pipeline_binned_mem, 'Test pipeline_binned_mem.py')
98   - self.append(self.test_pipeline_stacked_disk, 'Test pipeline_stacked_disk.py')
99   - self.append(self.test_pipeline_stacked_mem, 'Test pipeline_stacked_mem.py')
100   - self.append(self.test_pipeline_unbinned_disk, 'Test pipeline_unbinned_disk.py')
101   - self.append(self.test_pipeline_unbinned_mem, 'Test pipeline_unbinned_mem.py')
102   - self.append(self.test_show_butterfly, 'Test show_butterfly.py')
103   - self.append(self.test_show_model, 'Test show_model.py')
104   - self.append(self.test_show_pha, 'Test show_pha.py')
105   - self.append(self.test_show_pull_evolution, 'Test show_pull_evolution.py')
106   - self.append(self.test_show_pull_histogram, 'Test show_pull_histogram.py')
107   - self.append(self.test_show_response, 'Test test_show_response.py')
108   - self.append(self.test_show_sensitivity, 'Test test_show_sensitivity.py')
109   - self.append(self.test_show_spectrum, 'Test test_show_spectrum.py')
110   - self.append(self.test_show_ts_distribution, 'Test show_ts_distribution.py')
111   - self.append(self.test_show_obs, 'Test show_obs.py')
  95 + self.append(self.test_generate_prod3_irfs,
  96 + 'Test generate_prod3_irfs.py')
  97 + self.append(self.test_make_pointings,
  98 + 'Test make_pointings.py')
  99 + self.append(self.test_make_spectrum,
  100 + 'Test make_spectrum.py')
  101 + self.append(self.test_make_ts_distributions,
  102 + 'Test make_ts_distributions.py')
  103 + self.append(self.test_pipeline_binned_disk,
  104 + 'Test pipeline_binned_disk.py')
  105 + self.append(self.test_pipeline_binned_mem,
  106 + 'Test pipeline_binned_mem.py')
  107 + self.append(self.test_pipeline_stacked_disk,
  108 + 'Test pipeline_stacked_disk.py')
  109 + self.append(self.test_pipeline_stacked_mem,
  110 + 'Test pipeline_stacked_mem.py')
  111 + self.append(self.test_pipeline_unbinned_disk,
  112 + 'Test pipeline_unbinned_disk.py')
  113 + self.append(self.test_pipeline_unbinned_mem,
  114 + 'Test pipeline_unbinned_mem.py')
  115 + self.append(self.test_show_butterfly,
  116 + 'Test show_butterfly.py')
  117 + self.append(self.test_show_model,
  118 + 'Test show_model.py')
  119 + self.append(self.test_show_pha,
  120 + 'Test show_pha.py')
  121 + self.append(self.test_show_pull_evolution,
  122 + 'Test show_pull_evolution.py')
  123 + self.append(self.test_show_pull_histogram,
  124 + 'Test show_pull_histogram.py')
  125 + self.append(self.test_show_response,
  126 + 'Test test_show_response.py')
  127 + self.append(self.test_show_sensitivity,
  128 + 'Test test_show_sensitivity.py')
  129 + self.append(self.test_show_spectrum,
  130 + 'Test test_show_spectrum.py')
  131 + self.append(self.test_show_ts_distribution,
  132 + 'Test show_ts_distribution.py')
  133 + self.append(self.test_show_obs,
  134 + 'Test show_obs.py')
112 135  
113 136 # Return
114 137 return
... ... @@ -138,7 +161,8 @@ class Test(gammalib.GPythonTestSuite):
138 161 Test generate_prod3_irfs
139 162 """
140 163 # Execute script
141   - self._execute_python('generate_prod3_irfs')
  164 + self._execute_python('generate_prod3_irfs',
  165 + args=self._datadir)
142 166  
143 167 # Return
144 168 return
... ... @@ -149,7 +173,8 @@ class Test(gammalib.GPythonTestSuite):
149 173 Test make_spectrum
150 174 """
151 175 # Execute script
152   - self._execute_python('make_spectrum', args='eps')
  176 + self._execute_python('make_spectrum',
  177 + args=self._datadir+' eps')
153 178  
154 179 # Return
155 180 return
... ... @@ -160,7 +185,8 @@ class Test(gammalib.GPythonTestSuite):
160 185 Test make_ts_distributions
161 186 """
162 187 # Execute script
163   - self._execute_python('make_ts_distributions', args='-n 2 -e 0 -d 1800')
  188 + self._execute_python('make_ts_distributions',
  189 + args='-n 2 -e 0 -d 1800 -p '+self._datadir)
164 190  
165 191 # Return
166 192 return
... ... @@ -171,7 +197,7 @@ class Test(gammalib.GPythonTestSuite):
171 197 Test pipeline_binned_disk
172 198 """
173 199 # Execute script
174   - self._execute_python('pipeline_binned_disk')
  200 + self._execute_python('pipeline_binned_disk', args=self._datadir)
175 201  
176 202 # Return
177 203 return
... ... @@ -182,7 +208,7 @@ class Test(gammalib.GPythonTestSuite):
182 208 Test pipeline_binned_mem
183 209 """
184 210 # Execute script
185   - self._execute_python('pipeline_binned_mem')
  211 + self._execute_python('pipeline_binned_mem', args=self._datadir)
186 212  
187 213 # Return
188 214 return
... ... @@ -193,7 +219,7 @@ class Test(gammalib.GPythonTestSuite):
193 219 Test pipeline_stacked_disk
194 220 """
195 221 # Execute script
196   - self._execute_python('pipeline_stacked_disk')
  222 + self._execute_python('pipeline_stacked_disk', args=self._datadir)
197 223  
198 224 # Return
199 225 return
... ... @@ -204,7 +230,7 @@ class Test(gammalib.GPythonTestSuite):
204 230 Test pipeline_stacked_mem
205 231 """
206 232 # Execute script
207   - self._execute_python('pipeline_stacked_mem')
  233 + self._execute_python('pipeline_stacked_mem', args=self._datadir)
208 234  
209 235 # Return
210 236 return
... ... @@ -215,7 +241,7 @@ class Test(gammalib.GPythonTestSuite):
215 241 Test pipeline_unbinned_disk
216 242 """
217 243 # Execute script
218   - self._execute_python('pipeline_unbinned_disk')
  244 + self._execute_python('pipeline_unbinned_disk', args=self._datadir)
219 245  
220 246 # Return
221 247 return
... ... @@ -226,7 +252,7 @@ class Test(gammalib.GPythonTestSuite):
226 252 Test pipeline_unbinned_mem
227 253 """
228 254 # Execute script
229   - self._execute_python('pipeline_unbinned_mem')
  255 + self._execute_python('pipeline_unbinned_mem', args=self._datadir)
230 256  
231 257 # Return
232 258 return
... ... @@ -238,7 +264,7 @@ class Test(gammalib.GPythonTestSuite):
238 264 """
239 265 # Execute script
240 266 self._execute_python('show_butterfly',
241   - args='data/butterfly.txt '
  267 + args=self._datadir+'/butterfly.txt '
242 268 'example_show_butterfly.eps')
243 269  
244 270 # Return
... ... @@ -251,7 +277,8 @@ class Test(gammalib.GPythonTestSuite):
251 277 """
252 278 # Execute script
253 279 self._execute_python('show_model',
254   - args='data/crab.xml Crab example_show_model.eps')
  280 + args=self._datadir+'/crab.xml '
  281 + 'Crab example_show_model.eps')
255 282  
256 283 # Return
257 284 return
... ... @@ -263,7 +290,8 @@ class Test(gammalib.GPythonTestSuite):
263 290 """
264 291 # Execute script
265 292 self._execute_python('show_pha',
266   - args='data/pha.fits example_show_pha.eps')
  293 + args=self._datadir+'/pha.fits '
  294 + 'example_show_pha.eps')
267 295  
268 296 # Return
269 297 return
... ... @@ -275,7 +303,8 @@ class Test(gammalib.GPythonTestSuite):
275 303 """
276 304 # Execute script
277 305 self._execute_python('show_pull_evolution',
278   - args='data/pull.dat Pull_Crab_Prefactor '
  306 + args=self._datadir+'/pull.dat '
  307 + 'Pull_Crab_Prefactor '
279 308 'example_show_pull_evolution.eps')
280 309  
281 310 # Return
... ... @@ -288,7 +317,8 @@ class Test(gammalib.GPythonTestSuite):
288 317 """
289 318 # Execute script
290 319 self._execute_python('show_pull_histogram',
291   - args='data/pull.dat Pull_Crab_Prefactor 50 '
  320 + args=self._datadir+'/pull.dat '
  321 + 'Pull_Crab_Prefactor 50 '
292 322 'example_show_pull_histogram.eps')
293 323  
294 324 # Return
... ... @@ -312,7 +342,7 @@ class Test(gammalib.GPythonTestSuite):
312 342 """
313 343 # Execute script
314 344 self._execute_python('show_sensitivity',
315   - args='data/sensitivity.dat '
  345 + args=self._datadir+'/sensitivity.dat '
316 346 'example_show_sensitivity.eps')
317 347  
318 348 # Return
... ... @@ -325,7 +355,7 @@ class Test(gammalib.GPythonTestSuite):
325 355 """
326 356 # Execute script
327 357 self._execute_python('show_spectrum',
328   - args='data/spectrum.fits '
  358 + args=self._datadir+'/spectrum.fits '
329 359 'example_show_spectrum.eps')
330 360  
331 361 # Return
... ... @@ -338,7 +368,7 @@ class Test(gammalib.GPythonTestSuite):
338 368 """
339 369 # Execute script
340 370 self._execute_python('show_ts_distribution',
341   - args='data/ts.dat -n 100 '
  371 + args=self._datadir+'/ts.dat -n 100 '
342 372 '-f example_show_ts_distribution.eps')
343 373  
344 374 # Return
... ... @@ -351,7 +381,8 @@ class Test(gammalib.GPythonTestSuite):
351 381 """
352 382 # Execute script
353 383 self._execute_python('show_obs',
354   - args='obs_selected.xml example_show_obs.eps')
  384 + args=self._datadir+'/obs_unbinned.xml '
  385 + 'example_show_obs.eps')
355 386  
356 387 # Return
357 388 return
... ... @@ -363,7 +394,7 @@ class Test(gammalib.GPythonTestSuite):
363 394 if __name__ == '__main__':
364 395  
365 396 # Set calibration database
366   - os.environ['CALDB'] = '../caldb'
  397 + os.environ['CALDB'] = '%s/caldb' % (os.environ['TEST_SRCDIR'])
367 398  
368 399 # Set PFILES environment variable
369 400 try:
... ... @@ -373,8 +404,8 @@ if __name__ == &#39;__main__&#39;:
373 404 os.environ['PFILES'] = 'pfiles'
374 405  
375 406 # Copy over pfiles
376   - os.system('cp -r ../src/*/*.par pfiles/')
377   - os.system('cp -r ../cscripts/*.par pfiles/')
  407 + os.system('cp -r %s/src/*/*.par pfiles/' % (os.environ['TEST_SRCDIR']))
  408 + os.system('cp -r %s/cscripts/*.par pfiles/' % (os.environ['TEST_SRCDIR']))
378 409  
379 410 # Allocate test suites
380 411 suites = gammalib.GTestSuites('Examples testing')
... ...
test/test_pipelines.py
... ... @@ -18,6 +18,7 @@
18 18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 19 #
20 20 # ==========================================================================
  21 +import os
21 22 import gammalib
22 23 import ctools
23 24  
... ... @@ -27,30 +28,40 @@ import ctools
27 28 # ============================ #
28 29 class Test(gammalib.GPythonTestSuite):
29 30 """
30   - Test class for pipelines.
  31 + Test class for pipelines
31 32 """
32 33 # Constructor
33 34 def __init__(self):
34 35 """
35   - Constructor.
  36 + Constructor
36 37 """
37 38 # Call base class constructor
38 39 gammalib.GPythonTestSuite.__init__(self)
39 40  
  41 + # Set test data directory
  42 + self._datadir = os.environ['TEST_DATA']
  43 +
  44 + # Set some standard test data
  45 + self._model = self._datadir + '/crab.xml'
  46 + self._caldb = 'prod2'
  47 + self._irf = 'South_0.5h'
  48 +
40 49 # Return
41 50 return
42 51  
43 52 # Set test functions
44 53 def set(self):
45 54 """
46   - Set all test functions.
  55 + Set all test functions
47 56 """
48 57 # Set test name
49   - self.name("pipelines")
  58 + self.name('pipelines')
50 59  
51 60 # Append tests
52   - self.append(self.test_unbinned_fits, "Test unbinned pipeline with FITS file saving")
53   - self.append(self.test_unbinned_mem, "Test unbinned in-memory pipeline")
  61 + self.append(self.test_unbinned_fits,
  62 + 'Test unbinned pipeline with FITS file saving')
  63 + self.append(self.test_unbinned_mem,
  64 + 'Test unbinned in-memory pipeline')
54 65  
55 66 # Return
56 67 return
... ... @@ -58,15 +69,15 @@ class Test(gammalib.GPythonTestSuite):
58 69 # Test unbinned pipeline with FITS file saving
59 70 def test_unbinned_fits(self):
60 71 """
61   - Test unbinned pipeline with FITS file saving.
  72 + Test unbinned pipeline with FITS file saving
62 73 """
63 74 # Set script parameters
64   - model_name = "data/crab.xml"
65   - events_name = "events.fits"
66   - selected_events_name = "selected_events.fits"
67   - result_name = "results.xml"
68   - caldb = "irf"
69   - irf = "cta_dummy_irf"
  75 + model_name = self._model
  76 + events_name = 'events.fits'
  77 + selected_events_name = 'selected_events.fits'
  78 + result_name = 'results.xml'
  79 + caldb = self._caldb
  80 + irf = self._irf
70 81 ra = 83.63
71 82 dec = 22.01
72 83 rad_sim = 10.0
... ... @@ -78,116 +89,90 @@ class Test(gammalib.GPythonTestSuite):
78 89  
79 90 # Simulate events
80 91 sim = ctools.ctobssim()
81   - sim["inmodel"] = model_name
82   - sim["outevents"] = events_name
83   - sim["caldb"] = caldb
84   - sim["irf"] = irf
85   - sim["ra"] = ra
86   - sim["dec"] = dec
87   - sim["rad"] = rad_sim
88   - sim["tmin"] = tstart
89   - sim["tmax"] = tstop
90   - sim["emin"] = emin
91   - sim["emax"] = emax
92   - self.test_try("Execute ctobssim")
93   - try:
94   - sim.execute()
95   - self.test_try_success()
96   - except:
97   - self.test_try_failure("Exception occured in ctobssim.")
  92 + sim['inmodel'] = model_name
  93 + sim['outevents'] = events_name
  94 + sim['caldb'] = caldb
  95 + sim['irf'] = irf
  96 + sim['ra'] = ra
  97 + sim['dec'] = dec
  98 + sim['rad'] = rad_sim
  99 + sim['tmin'] = tstart
  100 + sim['tmax'] = tstop
  101 + sim['emin'] = emin
  102 + sim['emax'] = emax
  103 + sim.execute()
98 104  
99 105 # Select events
100 106 select = ctools.ctselect()
101   - select["inobs"] = events_name
102   - select["outobs"] = selected_events_name
103   - select["ra"] = ra
104   - select["dec"] = dec
105   - select["rad"] = rad_select
106   - select["tmin"] = tstart
107   - select["tmax"] = tstop
108   - select["emin"] = emin
109   - select["emax"] = emax
110   - self.test_try("Execute ctselect")
111   - try:
112   - select.execute()
113   - self.test_try_success()
114   - except:
115   - self.test_try_failure("Exception occured in ctselect.")
  107 + select['inobs'] = events_name
  108 + select['outobs'] = selected_events_name
  109 + select['ra'] = ra
  110 + select['dec'] = dec
  111 + select['rad'] = rad_select
  112 + select['tmin'] = tstart
  113 + select['tmax'] = tstop
  114 + select['emin'] = emin
  115 + select['emax'] = emax
  116 + select.execute()
116 117  
117 118 # Perform maximum likelihood fitting
118 119 like = ctools.ctlike()
119   - like["inobs"] = selected_events_name
120   - like["inmodel"] = model_name
121   - like["outmodel"] = result_name
122   - like["caldb"] = caldb
123   - like["irf"] = irf
124   - self.test_try("Execute ctlike")
125   - try:
126   - like.execute()
127   - self.test_try_success()
128   - except:
129   - self.test_try_failure("Exception occured in ctlike.")
  120 + like['inobs'] = selected_events_name
  121 + like['inmodel'] = model_name
  122 + like['outmodel'] = result_name
  123 + like['caldb'] = caldb
  124 + like['irf'] = irf
  125 + like.execute()
130 126  
  127 + # Return
  128 + return
131 129  
132 130 # Test unbinned in-memory pipeline
133 131 def test_unbinned_mem(self):
134 132 """
135   - Test unbinned in-memory pipeline.
  133 + Test unbinned in-memory pipeline
136 134 """
137 135 # Set script parameters
138   - model_name = "data/crab.xml"
139   - caldb = "irf"
140   - irf = "cta_dummy_irf"
141   - ra = 83.63
142   - dec = 22.01
143   - rad_sim = 10.0
144   - tstart = 0.0
145   - tstop = 1800.0
146   - emin = 0.1
147   - emax = 100.0
148   - rad_select = 3.0
  136 + model_name = self._model
  137 + caldb = self._caldb
  138 + irf = self._irf
  139 + ra = 83.63
  140 + dec = 22.01
  141 + rad_sim = 10.0
  142 + tstart = 0.0
  143 + tstop = 1800.0
  144 + emin = 0.1
  145 + emax = 100.0
  146 + rad_select = 3.0
149 147  
150 148 # Simulate events
151 149 sim = ctools.ctobssim()
152   - sim["inmodel"] = model_name
153   - sim["caldb"] = caldb
154   - sim["irf"] = irf
155   - sim["ra"] = ra
156   - sim["dec"] = dec
157   - sim["rad"] = rad_sim
158   - sim["tmin"] = tstart
159   - sim["tmax"] = tstop
160   - sim["emin"] = emin
161   - sim["emax"] = emax
162   - self.test_try("Run ctobssim")
163   - try:
164   - sim.run()
165   - self.test_try_success()
166   - except:
167   - self.test_try_failure("Exception occured in ctobssim.")
  150 + sim['inmodel'] = model_name
  151 + sim['caldb'] = caldb
  152 + sim['irf'] = irf
  153 + sim['ra'] = ra
  154 + sim['dec'] = dec
  155 + sim['rad'] = rad_sim
  156 + sim['tmin'] = tstart
  157 + sim['tmax'] = tstop
  158 + sim['emin'] = emin
  159 + sim['emax'] = emax
  160 + sim.run()
168 161  
169 162 # Select events
170 163 select = ctools.ctselect(sim.obs())
171   - select["ra"] = ra
172   - select["dec"] = dec
173   - select["rad"] = rad_select
174   - select["tmin"] = tstart
175   - select["tmax"] = tstop
176   - select["emin"] = emin
177   - select["emax"] = emax
  164 + select['ra'] = ra
  165 + select['dec'] = dec
  166 + select['rad'] = rad_select
  167 + select['tmin'] = tstart
  168 + select['tmax'] = tstop
  169 + select['emin'] = emin
  170 + select['emax'] = emax
178 171 select.run()
179   - self.test_try("Run ctselect")
180   - try:
181   - select.run()
182   - self.test_try_success()
183   - except:
184   - self.test_try_failure("Exception occured in ctselect.")
185 172  
186 173 # Perform maximum likelihood fitting
187 174 like = ctools.ctlike(select.obs())
188   - self.test_try("Run ctlike")
189   - try:
190   - like.run()
191   - self.test_try_success()
192   - except:
193   - self.test_try_failure("Exception occured in ctlike.")
  175 + like.run()
  176 +
  177 + # Return
  178 + return
... ...
test/test_python_cscripts.py
... ... @@ -74,13 +74,16 @@ def test(installed=False, debug=False):
74 74 dirname = os.path.dirname(testdir)
75 75  
76 76 # Copy over test data and irf
77   - os.system('cp -r %s %s' % (dirname+'/data', 'data'))
78   - os.system('cp -r %s %s' % (dirname+'/iactdata', 'iactdata'))
79   - os.system('cp -r %s %s' % (dirname+'/irf', 'irf'))
  77 + os.system('cp -r %s %s' % (dirname+'/data', 'data'))
80 78  
81   - # ... otherwise set the calibration database
  79 + # Set test data environment variable
  80 + os.environ['TEST_DATA'] = 'data'
  81 +
  82 + # ... otherwise set the calibration database to the one shipped with the
  83 + # package; we don't need to set the 'TEST_DATA', this is done by the
  84 + # test environment
82 85 else:
83   - os.environ['CALDB'] = '../caldb'
  86 + os.environ['CALDB'] = '%s/caldb' % (os.environ['TEST_SRCDIR'])
84 87  
85 88 # Set PFILES environment variable
86 89 try:
... ... @@ -91,9 +94,11 @@ def test(installed=False, debug=False):
91 94  
92 95 # Copy over pfiles
93 96 if not installed:
94   - os.system('cp -r ../cscripts/*.par pfiles/')
  97 + os.system('cp -r %s/cscripts/*.par pfiles/'% (os.environ['TEST_SRCDIR']))
  98 + os.system('chmod u+w pfiles/*')
95 99 else:
96 100 os.system('cp -r %s/syspfiles/*.par pfiles/' % (os.environ['CTOOLS']))
  101 + os.system('chmod u+w pfiles/*')
97 102  
98 103 # Allocate test suite container
99 104 suites = gammalib.GTestSuites('cscripts unit testing')
... ...
test/test_python_cscripts.sh.in
... ... @@ -22,4 +22,4 @@
22 22 #
23 23 # Run the Python test
24 24 # ===================
25   -@PYTHON_COVERAGE@./test_python_cscripts.py
  25 +@PYTHON_COVERAGE@@srcdir@/test_python_cscripts.py
... ...
test/test_python_ctools.py
... ... @@ -54,6 +54,10 @@ def test(installed=False):
54 54 installed : bool, optional
55 55 Flag indicating whether the script has been installed or not
56 56 """
  57 + # Set environment variables first
  58 + if installed:
  59 + os.environ['TEST_DATA'] = 'data'
  60 +
57 61 # Allocate test suite container
58 62 suites = gammalib.GTestSuites('ctools unit testing')
59 63  
... ... @@ -130,7 +134,10 @@ def test(installed=False):
130 134  
131 135 # Copy over test data and irf
132 136 os.system('cp -r %s %s' % (dirname+'/data', 'data'))
133   - os.system('cp -r %s %s' % (dirname+'/irf', 'irf'))
  137 +
  138 + # ... otherwise set the calibration database
  139 + else:
  140 + os.environ['CALDB'] = '%s/caldb' % (os.environ['TEST_SRCDIR'])
134 141  
135 142 # Set PFILES environment variable
136 143 try:
... ... @@ -141,9 +148,11 @@ def test(installed=False):
141 148  
142 149 # Copy over pfiles
143 150 if not installed:
144   - os.system('cp -r ../src/*/*.par pfiles/')
  151 + os.system('cp -r %s/src/*/*.par pfiles/' % (os.environ['TEST_SRCDIR']))
  152 + os.system('chmod u+w pfiles/*')
145 153 else:
146 154 os.system('cp -r %s/syspfiles/*.par pfiles/' % (os.environ['CTOOLS']))
  155 + os.system('chmod u+w pfiles/*')
147 156  
148 157 # Run test suite
149 158 success = suites.run()
... ...
test/test_python_ctools.sh.in
... ... @@ -22,4 +22,4 @@
22 22 #
23 23 # Run the Python test
24 24 # ===================
25   -@PYTHON_COVERAGE@./test_python_ctools.py
  25 +@PYTHON_COVERAGE@@srcdir@/test_python_ctools.py
... ...
test/testing.py
... ... @@ -37,6 +37,17 @@ class test(gammalib.GPythonTestSuite):
37 37 # Call base class constructor
38 38 gammalib.GPythonTestSuite.__init__(self)
39 39  
  40 + # Set test data directory
  41 + self._datadir = os.environ['TEST_DATA']
  42 +
  43 + # Set some standard test data (additional test data will be set in
  44 + # the derived classes as needed)
  45 + self._events = self._datadir + '/crab_events.fits'
  46 + self._cntcube = self._datadir + '/crab_cntmap.fits'
  47 + self._model = self._datadir + '/crab.xml'
  48 + self._caldb = 'prod2'
  49 + self._irf = 'South_0.5h'
  50 +
40 51 # Return
41 52 return
42 53  
... ... @@ -45,9 +56,11 @@ class test(gammalib.GPythonTestSuite):
45 56 """
46 57 Set script name
47 58 """
48   - # Kluge to set the command. The installed version has no README.md file
49   - if os.path.isfile('README.md'):
50   - script = '../cscripts/'+name+'.py'
  59 + # Set script name dependent on whether the software is installed or
  60 + # not. If the software is not installed the 'TEST_BUILDDIR' environment
  61 + # variable will exist
  62 + if 'TEST_BUILDDIR' in os.environ:
  63 + script = os.environ['TEST_BUILDDIR'] + '/cscripts/'+name+'.py'
51 64 else:
52 65 script = name
53 66  
... ... @@ -59,9 +72,11 @@ class test(gammalib.GPythonTestSuite):
59 72 """
60 73 Set tool name
61 74 """
62   - # Kluge to set the command. The installed version has no README.md file
63   - if os.path.isfile('README.md'):
64   - tool = '../src/'+name+'/'+name
  75 + # Set tool name dependent on whether the software is installed or
  76 + # not. If the software is not installed the 'TEST_BUILDDIR' environment
  77 + # variable will exist
  78 + if 'TEST_BUILDDIR' in os.environ:
  79 + tool = os.environ['TEST_BUILDDIR'] + '/src/'+name+'/'+name
65 80 else:
66 81 tool = name
67 82  
... ...