diff --git a/ChangeLog b/ChangeLog index f543d26..2d77bb7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,4 @@ -2016-07-01 Juergen Knoedlseder +2016-07-09 Juergen Knoedlseder * Version 1.1.0 released ======================== @@ -24,6 +24,7 @@ Add documentation for IACT analysis (#1646) ctselect allows usage of non-default events and GTI extensions (#1598) Add csworkflow workflow manager script (#1508) + Support out of source builds (#1484) 2016-01-27 Juergen Knoedlseder diff --git a/Makefile.am b/Makefile.am index 5b771b5..a5ecc2e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,23 @@ -## Process this file with automake to produce Makefile.in +############################################################################# +# Makefile for ctools package # +# ------------------------------------------------------------------------- # +# Copyright (C) 2016 Juergen Knoedlseder # +# ------------------------------------------------------------------------- # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################# # Include M4 macros ACLOCAL_AMFLAGS = -I m4 @@ -25,6 +44,10 @@ doc_DATA = \ README.md docdir = ${datadir}/doc/${PACKAGE} +# Extra files to be distributed in the tar file +EXTRA_DIST = README.md \ + doc/Doxyfile doc/source + #install-data-local: $(HTML_INSTALL_DATA_TARGETS) #uninstall-local: $(HTML_UNINSTALL_DATA_TARGETS) diff --git a/NEWS b/NEWS index 698a0b2..8f5d65b 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,6 @@ New Features and Important Changes in ctools 1.1.0 -1 July 2016 +9 July 2016 Introduction @@ -11,7 +11,7 @@ ctools release with respect to the precedent release. Configuration ------------- -None +The package now supports out of source builds (#1484). Python interface diff --git a/caldb/Makefile.am b/caldb/Makefile.am index b1aff4c..5270730 100644 --- a/caldb/Makefile.am +++ b/caldb/Makefile.am @@ -1,18 +1,47 @@ -## Process this file with automake to produce Makefile.in +############################################################################# +# Makefile.am for calibration database # +# ------------------------------------------------------------------------- # +# Copyright (C) 2016 Juergen Knoedlseder # +# ------------------------------------------------------------------------- # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################# -# Calibration files to distribute +# Calibration files to install caldb_prod2_indxdir = $(datadir)/caldb/data/cta/prod2 -caldb_prod2_indx_DATA = data/cta/prod2/caldb.indx +caldb_prod2_indx_DATA = $(srcdir)/data/cta/prod2/caldb.indx +# caldb_prod2_north1dir = $(datadir)/caldb/data/cta/prod2/bcf/North_0.5h -caldb_prod2_north1_DATA = data/cta/prod2/bcf/North_0.5h/irf_file.fits.gz +caldb_prod2_north1_DATA = $(srcdir)/data/cta/prod2/bcf/North_0.5h/irf_file.fits.gz caldb_prod2_north2dir = $(datadir)/caldb/data/cta/prod2/bcf/North_5h -caldb_prod2_north2_DATA = data/cta/prod2/bcf/North_5h/irf_file.fits.gz +caldb_prod2_north2_DATA = $(srcdir)/data/cta/prod2/bcf/North_5h/irf_file.fits.gz caldb_prod2_north3dir = $(datadir)/caldb/data/cta/prod2/bcf/North_50h -caldb_prod2_north3_DATA = data/cta/prod2/bcf/North_50h/irf_file.fits.gz +caldb_prod2_north3_DATA = $(srcdir)/data/cta/prod2/bcf/North_50h/irf_file.fits.gz # caldb_prod2_south1dir = $(datadir)/caldb/data/cta/prod2/bcf/South_0.5h -caldb_prod2_south1_DATA = data/cta/prod2/bcf/South_0.5h/irf_file.fits.gz +caldb_prod2_south1_DATA = $(srcdir)/data/cta/prod2/bcf/South_0.5h/irf_file.fits.gz caldb_prod2_south2dir = $(datadir)/caldb/data/cta/prod2/bcf/South_5h -caldb_prod2_south2_DATA = data/cta/prod2/bcf/South_5h/irf_file.fits.gz +caldb_prod2_south2_DATA = $(srcdir)/data/cta/prod2/bcf/South_5h/irf_file.fits.gz caldb_prod2_south3dir = $(datadir)/caldb/data/cta/prod2/bcf/South_50h -caldb_prod2_south3_DATA = data/cta/prod2/bcf/South_50h/irf_file.fits.gz +caldb_prod2_south3_DATA = $(srcdir)/data/cta/prod2/bcf/South_50h/irf_file.fits.gz + +# Calibration files to be distributed in the tar file +EXTRA_DIST = $(caldb_prod2_indx_DATA) \ + $(caldb_prod2_north1_DATA) \ + $(caldb_prod2_north2_DATA) \ + $(caldb_prod2_north3_DATA) \ + $(caldb_prod2_south1_DATA) \ + $(caldb_prod2_south2_DATA) \ + $(caldb_prod2_south3_DATA) diff --git a/configure.ac b/configure.ac index 9578d78..7dded68 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,5 @@ ############################################################################# -# Configuration for ctools - a set of tools for science analysis of CTA # -# data # +# Configuration for ctools - tools for science analysis of CTA data # # ------------------------------------------------------------------------- # # Copyright (C) 2011-2016 Juergen Knoedlseder # # ------------------------------------------------------------------------- # @@ -33,8 +32,8 @@ AC_INIT([ctools], [1.1.0.dev1], [jurgen.knodlseder@irap.omp.eu], [ctools]) AC_CONFIG_SRCDIR([src/ctselect/ctselect.cpp]) AC_CONFIG_MACRO_DIR([m4]) #AM_INIT_AUTOMAKE([gnu no-dependencies foreign]) -AM_INIT_AUTOMAKE([gnu -Wno-portability foreign]) -#AM_INIT_AUTOMAKE([gnu -Wno-portability serial-tests foreign]) +#AM_INIT_AUTOMAKE([gnu -Wno-portability foreign]) +AM_INIT_AUTOMAKE([gnu -Wno-portability foreign serial-tests]) AC_CONFIG_HEADER([config.h]) @@ -609,8 +608,9 @@ AC_C_INLINE # Python binding requires Python and either the files tools_wrap.cpp and # # tools.py or swig to create these files. The following conditionals are # # set: # -# WITH_PYTHON - Python bindings will be built # -# HAVE_SWIG - swig is available # +# WITH_PYTHON - Python bindings will be built # +# HAVE_SWIG - swig is available # +# HAVE_WRAPPERS - wrappers are available # ############################################################################# # Initialise flags enable_python="no" @@ -618,6 +618,7 @@ has_python="no" has_python_h="no" has_swig="no" has_wrappers="no" +build_wrappers="no" # Python binding enabled? AC_ARG_ENABLE([python-binding], @@ -734,12 +735,18 @@ else # Do we have wrappers (tools_wrap.cpp and tools.py)? has_wrappers="yes" - AC_CHECK_FILES([pyext/ctools/tools_wrap.cpp pyext/ctools/tools.py],, + AC_CHECK_FILES([$srcdir/pyext/ctools/tools_wrap.cpp + $srcdir/pyext/ctools/tools.py],, [has_wrappers="no"]) if test "x$has_wrappers" = "xno"; then AC_MSG_WARN([Python wrapper missing. Requires swig for wrapper generation.]) fi + # Don't we have wrappers but we have swig + if [test "x$has_wrappers" = "xno" -a "x$has_swig" = "xyes"]; then + build_wrappers="yes" + fi + # Signal if Python is enabled if test "x$ac_enable_python_binding" = "xyes" -a "x$has_python" = "xyes" -a "x$has_python_h" = "xyes"; then if test "x$has_swig" = "xyes" -o "x$has_wrappers" = "xyes"; then @@ -748,8 +755,10 @@ else fi fi -AM_CONDITIONAL(HAVE_SWIG, test "x$has_swig" = "xyes") AM_CONDITIONAL(WITH_PYTHON, test "x$enable_python" = "xyes") +AM_CONDITIONAL(HAVE_SWIG, test "x$has_swig" = "xyes") +AM_CONDITIONAL(HAVE_WRAPPERS, test "x$has_wrappers" = "xyes") +AM_CONDITIONAL(BUILD_WRAPPERS, test "x$build_wrappers" = "xyes") # Set Python environment if test "x$enable_python" = "xyes"; then @@ -1022,7 +1031,6 @@ AC_CONFIG_FILES([Makefile src/support/Makefile src/ctools-setup test/Makefile - test/test_cscripts.sh test/test_python_ctools.sh test/test_python_cscripts.sh test/test_examples.py @@ -1036,8 +1044,7 @@ AC_CONFIG_FILES([Makefile examples/Makefile ctools.pc testconf.sh], - [if test -f test/test_cscripts.sh; then chmod +x test/test_cscripts.sh; fi; - if test -f test/test_python_ctools.sh; then chmod +x test/test_python_ctools.sh; fi; + [if test -f test/test_python_ctools.sh; then chmod +x test/test_python_ctools.sh; fi; if test -f test/test_python_cscripts.sh; then chmod +x test/test_python_cscripts.sh; fi; if test -f test/test_examples.py; then chmod +x test/test_examples.py; fi; if test -f testconf.sh; then chmod +x testconf.sh; fi]) diff --git a/cscripts/Makefile.am b/cscripts/Makefile.am index 1072771..a4677f1 100644 --- a/cscripts/Makefile.am +++ b/cscripts/Makefile.am @@ -1,51 +1,70 @@ -## Process this file with automake to produce Makefile.in +############################################################################# +# Makefile for cscripts scripts # +# ------------------------------------------------------------------------- # +# Copyright (C) 2016 Juergen Knoedlseder # +# ------------------------------------------------------------------------- # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################# # Scripts to be distributed in $(pyexecdir)/cscripts -pythonscripts = __init__.py \ - cscaldb.py \ - csinfo.py \ - cslightcrv.py \ - csmodelinfo.py \ - csmodelmerge.py \ - csobs2caldb.py \ - csobsdef.py \ - csobsinfo.py \ - cspull.py \ - csresmap.py \ - csroot2caldb.py \ - cssens.py \ - csspec.py \ - cstsdist.py \ - cstsmapmerge.py \ - cstsmapsplit.py \ - csworkflow.py \ - csfindobs.py \ - csiactcopy.py \ - csiactdata.py \ - csiactobs.py \ - obsutils.py +pythonscripts = $(builddir)/__init__.py \ + $(srcdir)/cscaldb.py \ + $(srcdir)/csinfo.py \ + $(srcdir)/cslightcrv.py \ + $(srcdir)/csmodelinfo.py \ + $(srcdir)/csmodelmerge.py \ + $(srcdir)/csobs2caldb.py \ + $(srcdir)/csobsdef.py \ + $(srcdir)/csobsinfo.py \ + $(srcdir)/cspull.py \ + $(srcdir)/csresmap.py \ + $(srcdir)/csroot2caldb.py \ + $(srcdir)/cssens.py \ + $(srcdir)/csspec.py \ + $(srcdir)/cstsdist.py \ + $(srcdir)/cstsmapmerge.py \ + $(srcdir)/cstsmapsplit.py \ + $(srcdir)/csworkflow.py \ + $(srcdir)/csfindobs.py \ + $(srcdir)/csiactcopy.py \ + $(srcdir)/csiactdata.py \ + $(srcdir)/csiactobs.py \ + $(srcdir)/obsutils.py # Parfiles to be distributed in $(prefix)/syspfiles -parfiles = cscaldb.par \ - cslightcrv.par \ - csmodelinfo.par \ - csmodelmerge.par \ - csobs2caldb.par \ - csobsdef.par \ - csobsinfo.par \ - cspull.par \ - csresmap.par \ - csroot2caldb.par \ - cssens.par \ - csspec.par \ - cstsdist.par \ - cstsmapmerge.par \ - cstsmapsplit.par \ - csworkflow.par \ - csfindobs.par \ - csiactcopy.par \ - csiactdata.par \ - csiactobs.par +parfiles = $(srcdir)/cscaldb.par \ + $(srcdir)/cslightcrv.par \ + $(srcdir)/csmodelinfo.par \ + $(srcdir)/csmodelmerge.par \ + $(srcdir)/csobs2caldb.par \ + $(srcdir)/csobsdef.par \ + $(srcdir)/csobsinfo.par \ + $(srcdir)/cspull.par \ + $(srcdir)/csresmap.par \ + $(srcdir)/csroot2caldb.par \ + $(srcdir)/cssens.par \ + $(srcdir)/csspec.par \ + $(srcdir)/cstsdist.par \ + $(srcdir)/cstsmapmerge.par \ + $(srcdir)/cstsmapsplit.par \ + $(srcdir)/csworkflow.par \ + $(srcdir)/csfindobs.par \ + $(srcdir)/csiactcopy.par \ + $(srcdir)/csiactdata.par \ + $(srcdir)/csiactobs.par # Scripts for which symbolic links will be created in bindir linkscripts = cscaldb \ @@ -71,64 +90,70 @@ linkscripts = cscaldb \ csiactobs # Test scripts to be distributed in $(pyexecdir)/cscripts/tests -testscripts = tests/__init__.py \ - ../test/testing.py \ - ../test/test_python_cscripts.py \ - ../test/test_cscaldb.py \ - ../test/test_csmodelinfo.py \ - ../test/test_csmodelmerge.py \ - ../test/test_csobs2caldb.py \ - ../test/test_csobsdef.py \ - ../test/test_csobsinfo.py \ - ../test/test_cslightcrv.py \ - ../test/test_cspull.py \ - ../test/test_csresmap.py \ - ../test/test_csroot2caldb.py \ - ../test/test_cssens.py \ - ../test/test_csspec.py \ - ../test/test_cstsdist.py \ - ../test/test_cstsmapmerge.py \ - ../test/test_cstsmapsplit.py \ - ../test/test_csworkflow.py \ - ../test/test_csfindobs.py \ - ../test/test_csiactcopy.py \ - ../test/test_csiactdata.py \ - ../test/test_csiactobs.py +testscripts = $(srcdir)/tests/__init__.py \ + $(top_srcdir)/test/testing.py \ + $(top_srcdir)/test/test_python_cscripts.py \ + $(top_srcdir)/test/test_cscaldb.py \ + $(top_srcdir)/test/test_csmodelinfo.py \ + $(top_srcdir)/test/test_csmodelmerge.py \ + $(top_srcdir)/test/test_csobs2caldb.py \ + $(top_srcdir)/test/test_csobsdef.py \ + $(top_srcdir)/test/test_csobsinfo.py \ + $(top_srcdir)/test/test_cslightcrv.py \ + $(top_srcdir)/test/test_cspull.py \ + $(top_srcdir)/test/test_csresmap.py \ + $(top_srcdir)/test/test_csroot2caldb.py \ + $(top_srcdir)/test/test_cssens.py \ + $(top_srcdir)/test/test_csspec.py \ + $(top_srcdir)/test/test_cstsdist.py \ + $(top_srcdir)/test/test_cstsmapmerge.py \ + $(top_srcdir)/test/test_cstsmapsplit.py \ + $(top_srcdir)/test/test_csworkflow.py \ + $(top_srcdir)/test/test_csfindobs.py \ + $(top_srcdir)/test/test_csiactcopy.py \ + $(top_srcdir)/test/test_csiactdata.py \ + $(top_srcdir)/test/test_csiactobs.py # Test data to be distributed in $(pyexecdir)/cscripts/tests/data -testdata = ../test/data/crab.xml \ - ../test/data/obs_unbinned.xml \ - ../test/data/obs_stacked.xml \ - ../test/data/crab_events.fits.gz \ - ../test/data/crab_cntmap.fits.gz \ - ../test/data/crab_cntmap_small.fits.gz \ - ../test/data/crab_expcube.fits.gz \ - ../test/data/crab_psfcube.fits.gz \ - ../test/data/crab_edispcube.fits.gz \ - ../test/data/crab_bkgcube.fits.gz \ - ../test/data/tsmap_0.fits \ - ../test/data/tsmap_1.fits \ - ../test/data/exclusion.reg \ - ../test/data/pntdef.dat \ - ../test/data/models.txt \ - ../test/data/tsmaps.txt \ - ../test/data/model_cube_background.xml \ - ../test/data/model_cube_background2.xml \ - ../test/data/crab_bkgcube.xml \ - ../test/data/irf.root \ - ../test/data/workflow.xml +testdata = $(top_srcdir)/test/data/crab.xml \ + $(top_srcdir)/test/data/obs_unbinned.xml \ + $(top_srcdir)/test/data/obs_stacked.xml \ + $(top_srcdir)/test/data/crab_events.fits.gz \ + $(top_srcdir)/test/data/crab_cntmap.fits.gz \ + $(top_srcdir)/test/data/crab_cntmap_small.fits.gz \ + $(top_srcdir)/test/data/crab_expcube.fits.gz \ + $(top_srcdir)/test/data/crab_psfcube.fits.gz \ + $(top_srcdir)/test/data/crab_edispcube.fits.gz \ + $(top_srcdir)/test/data/crab_bkgcube.fits.gz \ + $(top_srcdir)/test/data/tsmap_0.fits \ + $(top_srcdir)/test/data/tsmap_1.fits \ + $(top_srcdir)/test/data/exclusion.reg \ + $(top_srcdir)/test/data/pntdef.dat \ + $(top_srcdir)/test/data/models.txt \ + $(top_srcdir)/test/data/tsmaps.txt \ + $(top_srcdir)/test/data/model_cube_background.xml \ + $(top_srcdir)/test/data/model_cube_background2.xml \ + $(top_srcdir)/test/data/crab_bkgcube.xml \ + $(top_srcdir)/test/data/irf.root \ + $(top_srcdir)/test/data/irf_file.fits.gz \ + $(top_srcdir)/test/data/workflow.xml \ + $(top_srcdir)/test/data/butterfly.txt \ + $(top_srcdir)/test/data/pha.fits \ + $(top_srcdir)/test/data/pull.dat \ + $(top_srcdir)/test/data/sensitivity.dat \ + $(top_srcdir)/test/data/spectrum.fits \ + $(top_srcdir)/test/data/ts.dat -# Test data to be distributed in $(pyexecdir)/cscripts/tests/iactdata -testiactdata = ../test/iactdata/hdu-index.fits.gz \ - ../test/iactdata/master.json \ - ../test/iactdata/obs-index.fits.gz +# Test data to be distributed in $(pyexecdir)/cscripts/tests/data/iactdata +testiactdata = $(top_srcdir)/test/data/iactdata/hdu-index.fits.gz \ + $(top_srcdir)/test/data/iactdata/master.json \ + $(top_srcdir)/test/data/iactdata/obs-index.fits.gz \ + $(top_srcdir)/test/data/iactdata/irf_file.fits.gz \ + $(top_srcdir)/test/data/iactdata/events.fits.gz -# Test IRFs to be distributed in $(pyexecdir)/cscripts/tests/irf -testirf = ../test/irf/irf_file.fits.gz \ - ../test/irf/cta_dummy_irf.dat - -# Distribute scripts and parfiles -EXTRA_DIST = $(binscripts) $(pythonscripts) +# Install scripts, parfiles, test scripts and test data. Note that we don't +# need to prepend $(DESTDIR) here (not fully clear why, but that's the way +# it is) binscriptsdir = $(bindir) binscripts_DATA = $(binscripts) pythonscriptsdir = $(pyexecdir)/cscripts @@ -139,12 +164,14 @@ testscriptsdir = $(pyexecdir)/cscripts/tests testscripts_DATA = $(testscripts) testdatadir = $(pyexecdir)/cscripts/tests/data testdata_DATA = $(testdata) -testiactdatadir = $(pyexecdir)/cscripts/tests/iactdata +testiactdatadir = $(pyexecdir)/cscripts/tests/data/iactdata testiactdata_DATA = $(testiactdata) -testirfdir = $(pyexecdir)/cscripts/tests/irf -testirf_DATA = $(testirf) -# Add hook rule to create symbolic links for cscripts +# Files to be distributed in the tar file +EXTRA_DIST = $(binscripts) $(pythonscripts) $(parfiles) \ + $(testscripts) $(testdata) $(testiactdata) + +# Add install hook rule to create symbolic links for cscripts install-data-hook: @binlist='$(binscripts)';\ for p in $$binlist; do \ @@ -156,4 +183,17 @@ install-data-hook: ln -s "$(DESTDIR)$(pyexecdir)/cscripts/$$p.py" "$(DESTDIR)$(bindir)/$$p"; \ chmod +x "$(DESTDIR)$(pyexecdir)/cscripts/$$p.py"; \ done - + +# Files to be removed in build directory +clean-local: + rm -rf $(builddir)/cs*.py + rm -rf $(builddir)/obsutils.py + rm -rf $(builddir)/*.pyc + rm -rf $(builddir)/*.par + +# Uninstall the cscripts Python module +uninstall-local: + rm -rf $(DESTDIR)$(pyexecdir)/cscripts/*.pyc + rm -rf $(DESTDIR)$(pyexecdir)/cscripts/__pycache__ + rm -rf $(DESTDIR)$(pyexecdir)/cscripts/tests/*.pyc + rm -rf $(DESTDIR)$(pyexecdir)/cscripts/tests/__pycache__ diff --git a/cscripts/csiactcopy.py b/cscripts/csiactcopy.py index e4da88f..8d8dc53 100755 --- a/cscripts/csiactcopy.py +++ b/cscripts/csiactcopy.py @@ -18,8 +18,8 @@ # along with this program. If not, see . # # ========================================================================== -import sys import os +import sys import json import shutil import gammalib @@ -694,7 +694,11 @@ class csiactcopy(ctools.cscript): self._log('Adding "'+str(newdict['name'])+'"') self._log('\n') - # Write new json master file + # Write new json master file. Make sure that we have write permission + # before writing the file. This is needed as the original master file + # may be read-only, and the shutil.copy2 function copies over the + # access permissions. + os.chmod(localmaster, 0644) f = open(localmaster, 'w') data['datasets'] = newconfigs json.dump(data, f, indent=2) diff --git a/cscripts/csmodelmerge.py b/cscripts/csmodelmerge.py index 558e428..0e461dd 100755 --- a/cscripts/csmodelmerge.py +++ b/cscripts/csmodelmerge.py @@ -18,6 +18,7 @@ # along with this program. If not, see . # # ========================================================================== +import os import sys import glob import gammalib @@ -64,10 +65,22 @@ class csmodelmerge(ctools.cscript): # Get input models string inmodels = self['inmodels'].string() - # Handle ascii files + # Handle ASCII files. If the file names given in the ASCII are + # relative filenames it is assumed that the filename is given + # relative to the location of the file. if '@' == inmodels[0]: - self._files = open(inmodels.replace('@','')).read().splitlines() - + filename = inmodels.replace('@','') + self._files = open(filename).read().splitlines() + dirname = os.path.dirname(filename) + files = [] + for f in self._files: + if f[0] != '/': + fname = dirname + '/' + f + else: + fname = f + files.append(fname) + self._files = files + # Handle wild card strings elif '*' in inmodels: self._files = glob.glob(inmodels) @@ -124,10 +137,10 @@ class csmodelmerge(ctools.cscript): self._models = gammalib.GModels() # Loop over model files - for file_ in self._files: + for f in self._files: # Construct container from XML file - models = gammalib.GModels(file_) + models = gammalib.GModels(f) # Log number of models to add if self._logTerse(): @@ -139,7 +152,7 @@ class csmodelmerge(ctools.cscript): else: self._log(gammalib.parformat('Add %d models from file' % nmodels)) - self._log(file_) + self._log(f) self._log('\n') # Extend model container by adding all models in the model file diff --git a/cscripts/csobs2caldb.py b/cscripts/csobs2caldb.py index 15e83c7..b7f4a18 100755 --- a/cscripts/csobs2caldb.py +++ b/cscripts/csobs2caldb.py @@ -46,17 +46,17 @@ class csobs2caldb(ctools.cscript): Constructor. """ # Set name and version - self._name = "csobs2caldb" - self._version = "1.1.0" + self._name = 'csobs2caldb' + self._version = '1.1.0' # Initialise members self._observation = gammalib.GCTAObservation() - self._mission = "cta" - self._caldb = "cta" - self._outfile = gammalib.GFilename("irf_file.fits") - self._base_dir = "" - self._cal_dir = "" - self._rsp_dir = "" + self._mission = 'cta' + self._caldb = 'cta' + self._outfile = gammalib.GFilename('irf_file.fits') + self._base_dir = '' + self._cal_dir = '' + self._rsp_dir = '' self._caldb_inx = gammalib.GFits() self._irf_fits = gammalib.GFits() @@ -73,7 +73,7 @@ class csobs2caldb(ctools.cscript): # Private methods def _get_parameters(self): """ - Get parameters from parfile. + Get parameters from parfile Raises: ValueError, IndexError, & RuntimeError. @@ -81,7 +81,7 @@ class csobs2caldb(ctools.cscript): # Load observation container from "inobs" parameter in case that # the observation container is still empty. if self._obs.is_empty(): - self._obs = gammalib.GObservations(self["inobs"].filename()) + self._obs = gammalib.GObservations(self['inobs'].filename()) # Raise an exception if the observation container is empty if self._obs.is_empty(): @@ -89,7 +89,7 @@ class csobs2caldb(ctools.cscript): 'parameter "inobs".') # Get index of observation to be used - index = self["index"].integer() + index = self['index'].integer() # Raise an exception if the index is not valid if index < 0 or index >= self._obs.size(): @@ -100,37 +100,37 @@ class csobs2caldb(ctools.cscript): self._observation = self._obs[index] # Make sure we have a CTA observation - if not self._observation.classname() == "GCTAObservation": + if not self._observation.classname() == 'GCTAObservation': raise RuntimeError('Input observation not of type ' '"GCTAObservation".') # Make sure we have an IRF response associated with the CTA # observation - if not self._observation.response().classname() == "GCTAResponseIrf": + if not self._observation.response().classname() == 'GCTAResponseIrf': raise RuntimeError('Response of input observation not of ' 'type "GCTAResponseIrf".') # Get calibration database name. If the "caldb" parameter is "NONE" # or empty then use the instrument name from the observation as # calibration database name. - self._caldb = self["caldb"].string() - if (self._caldb == "NONE" or len(self._caldb) == 0): + self._caldb = self['caldb'].string() + if (self._caldb == 'NONE' or len(self._caldb) == 0): self._caldb = self._observation.instrument().lower() # Get instrument response function file name - self._outfile = self["outfile"].filename() + self._outfile = self['outfile'].filename() # Make sure that remaining user parameters are queried now. We # do not store the actual parameter values as we do not want # too many instance attributes with enhances the maintenance # costs. - self["irf"].string() - self["rootdir"].string() + self['irf'].string() + self['rootdir'].string() # Write input parameters and header into logger if self._logTerse(): self._log_parameters() - self._log("\n") + self._log('\n') # Return return diff --git a/cscripts/cstsmapmerge.py b/cscripts/cstsmapmerge.py index e646d2e..7dffc26 100755 --- a/cscripts/cstsmapmerge.py +++ b/cscripts/cstsmapmerge.py @@ -68,11 +68,23 @@ class cstsmapmerge(ctools.cscript): """ # Get input maps string inmaps = self['inmaps'].string() - - # Handle ascii files + + # Handle ASCII files. If the file names given in the ASCII are + # relative filenames it is assumed that the filename is given + # relative to the location of the file. if '@' == inmaps[0]: - self._files = open(inmaps.replace('@','')).read().splitlines() - + filename = inmaps.replace('@','') + self._files = open(filename).read().splitlines() + dirname = os.path.dirname(filename) + files = [] + for f in self._files: + if f[0] != '/': + fname = dirname + '/' + f + else: + fname = f + files.append(fname) + self._files = files + # Handle wild card strings elif '*' in inmaps: self._files = glob.glob(inmaps) diff --git a/examples/Makefile.am b/examples/Makefile.am index 6bb953d..ad47ac2 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -1,7 +1,27 @@ -## Process this file with automake to produce Makefile.in +############################################################################# +# Makefile for ctools examples # +# ------------------------------------------------------------------------- # +# Copyright (C) 2016 Juergen Knoedlseder # +# ------------------------------------------------------------------------- # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################# -# Scripts to be distributed +# Scripts to be install scripts = README.md \ + generate_prod3_irfs.py \ make_pointings.py \ make_spectrum.py \ make_ts_distributions.py \ @@ -19,13 +39,14 @@ scripts = README.md \ show_response.py \ show_sensitivity.py \ show_spectrum.py \ - show_ts_distribution.py + show_ts_distribution.py \ + show_obs.py -# Set directories -scriptsdir = $(datadir)/examples/python -scripts_DATA = $(scripts) +# Set install directories +scriptsdir = $(datadir)/examples/python +scripts_DATA = $(scripts) -# Extra files to be distributed in the tar file +# Files to be distributed in the tar file EXTRA_DIST = $(scripts) # Add hook rule to make the examples executable diff --git a/examples/generate_prod3_irfs.py b/examples/generate_prod3_irfs.py index e70f144..6c44972 100755 --- a/examples/generate_prod3_irfs.py +++ b/examples/generate_prod3_irfs.py @@ -18,6 +18,7 @@ # along with this program. If not, see . # # ========================================================================== +import sys import gammalib import cscripts @@ -25,7 +26,7 @@ import cscripts # ======================= # # Set Prod3 DESY database # # ======================= # -def set_prod3_desy(): +def set_prod3_desy(datadir): """ Set Prod3 DESY database @@ -33,11 +34,19 @@ def set_prod3_desy(): the db list a number of calibrations can be defined for which IRFs should be generated. All calibrations will be added to the calibration database. + + Parameters + ---------- + datadir : str + Data directory + + Returns + ------- + db : list of dict + Database """ # Set database attributes - #path = '/project-data/cta/performance/prod3' - #file = 'DESY.d20160304.V5.ID0NIM2.prod3-paranalp05-NN.S.3HB1-ND-3.180000s.root' - path = 'data' + path = datadir file = 'irf.root' psftype = 'Gauss' oversample = 3 @@ -62,8 +71,14 @@ def set_prod3_desy(): # ======================== # if __name__ == '__main__': + # Get optional argument + if len(sys.argv) == 2: + datadir = sys.argv[1] + else: + datadir = 'data' + # Get database - entries = set_prod3_desy() + entries = set_prod3_desy(datadir) # Loop over entries for entry in entries: diff --git a/examples/make_spectrum.py b/examples/make_spectrum.py index b258186..938561e 100755 --- a/examples/make_spectrum.py +++ b/examples/make_spectrum.py @@ -33,17 +33,17 @@ except: # =============== # # Make a spectrum # # =============== # -def make_spectrum(): +def make_spectrum(datadir): """ Simulate events and generate a source spectrum Returns ------- - spectrum : `~gammalib.GFits` - Spectrum FITS file + datadir : str + Data directory """ # Set script parameters - model_name = 'data/crab.xml' + model_name = datadir+'/crab.xml' caldb = 'prod2' irf = 'South_0.5h' ra = 83.63 @@ -183,15 +183,18 @@ def plot_spectrum(spectrum, file=False): # ======================== # if __name__ == '__main__': - # Initialise option - file = False - - # Get any command line arguments - if (len(sys.argv) > 1): + # Get optional arguments + if len(sys.argv) >= 2: + datadir = sys.argv[1] + else: + datadir = 'data' + if len(sys.argv) >= 3: file = True + else: + file = False # Generate spectrum - spectrum = make_spectrum() + spectrum = make_spectrum(datadir) # If matplotlib is installed then plot spectrum if has_matplotlib: diff --git a/examples/make_ts_distributions.py b/examples/make_ts_distributions.py index a1412ca..fbed419 100755 --- a/examples/make_ts_distributions.py +++ b/examples/make_ts_distributions.py @@ -22,24 +22,19 @@ import sys import time import cscripts -# Optionally import processing module -try: - import processing - has_processing = True -except: - has_processing = False - # ====================== # # Create TS distribution # # ====================== # -def create_ts(loge, emin, emax, ntrials=100, duration=180000.0, - enumbins=0, log=False): +def create_ts(datadir, loge, emin, emax, ntrials=100, duration=180000.0, + enumbins=0, log=False): """ Create TS distribution. Parameters ---------- + datadir : str + Data directory loge : float Logarithm of mean energy (TeV) emin : float @@ -60,7 +55,7 @@ def create_ts(loge, emin, emax, ntrials=100, duration=180000.0, # Setup cstsdist tool tsdist = cscripts.cstsdist() - tsdist['inmodel'] = 'data/crab.xml' + tsdist['inmodel'] = datadir+'/crab.xml' tsdist['srcname'] = 'Crab' tsdist['outfile'] = outfile tsdist['ntrials'] = ntrials @@ -104,12 +99,14 @@ if __name__ == '__main__': enumbins = 0 duration = 180000.0 max_threads = 1 + datadir = 'data' # Parameter dictionnary pars = [{'option': '-n', 'value': ntrials}, {'option': '-e', 'value': enumbins}, {'option': '-d', 'value': duration}, - {'option': '-m', 'value': max_threads}] + {'option': '-m', 'value': max_threads}, + {'option': '-p', 'value': datadir}] # Gather parameters from command line i = 1 @@ -137,6 +134,7 @@ if __name__ == '__main__': enumbins = pars[1]['value'] duration = pars[2]['value'] max_threads = pars[3]['value'] + datadir = pars[4]['value'] # Loop over energy bands. The energy bands are those that are also # used for sensitivity computation. @@ -152,33 +150,6 @@ if __name__ == '__main__': else: loge = 'p'+str(abs(loge)) - # If processing support is available then start max_threads processes - # in parallel - if has_processing: - - # Wait until one thread has finished - while len(processing.activeChildren()) >= max_threads: - time.sleep(10) - - # Set arguments - args = (loge, emin, emax) - kwargs = {'ntrials': ntrials, 'enumbins': enumbins, - 'duration': duration} - - # Generate pull distribution - p = processing.Process(target=create_ts, args=args, kwargs=kwargs) - p.start() - print('Process emin=%.4f emax=%.4f started.' % (emin, emax)) - - # Wait a short time to allow process to start - time.sleep(1) - - # ... otherwise simply start a single process - else: - create_ts(loge, emin, emax, ntrials=ntrials, enumbins=enumbins, - duration=duration) - - # If processing support is available then wait until all threads finished - if has_processing: - while len(processing.activeChildren()) > 0: - time.sleep(10) + # Create TS + create_ts(datadir, loge, emin, emax, ntrials=ntrials, enumbins=enumbins, + duration=duration) diff --git a/examples/pipeline_binned_disk.py b/examples/pipeline_binned_disk.py index f89ca25..cf2948a 100755 --- a/examples/pipeline_binned_disk.py +++ b/examples/pipeline_binned_disk.py @@ -18,6 +18,7 @@ # along with this program. If not, see . # # ========================================================================== +import sys import gammalib import ctools from cscripts import obsutils @@ -218,11 +219,17 @@ if __name__ == '__main__': print('* CTA binned analysis pipeline *') print('********************************************') + # Get optional arguments + if len(sys.argv) == 2: + datadir = sys.argv[1] + else: + datadir = 'data' + # Setup observations obs = setup_observations() # Setup model - obs = setup_model(obs) + obs = setup_model(obs, model=datadir+'/crab.xml') # Run analysis pipeline - run_pipeline(obs) + run_pipeline(obs, model=datadir+'/crab.xml') diff --git a/examples/pipeline_binned_mem.py b/examples/pipeline_binned_mem.py index fa89ba4..ece32cb 100755 --- a/examples/pipeline_binned_mem.py +++ b/examples/pipeline_binned_mem.py @@ -18,6 +18,7 @@ # along with this program. If not, see . # # ========================================================================== +import sys import gammalib import ctools from cscripts import obsutils @@ -189,11 +190,17 @@ if __name__ == '__main__': print('* CTA binned analysis pipeline *') print('********************************************') + # Get optional arguments + if len(sys.argv) == 2: + datadir = sys.argv[1] + else: + datadir = 'data' + # Setup observations obs = setup_observations() # Setup model - obs = setup_model(obs) + obs = setup_model(obs, model=datadir+'/crab.xml') # Run analysis pipeline run_pipeline(obs) diff --git a/examples/pipeline_stacked_disk.py b/examples/pipeline_stacked_disk.py index 4db9d11..5a5ee87 100755 --- a/examples/pipeline_stacked_disk.py +++ b/examples/pipeline_stacked_disk.py @@ -18,6 +18,7 @@ # along with this program. If not, see . # # ========================================================================== +import sys import gammalib import ctools from cscripts import obsutils @@ -268,11 +269,17 @@ if __name__ == '__main__': print('* CTA stacked analysis pipeline *') print('********************************************') + # Get optional arguments + if len(sys.argv) == 2: + datadir = sys.argv[1] + else: + datadir = 'data' + # Setup observations obs = setup_observations() # Setup model - obs = setup_model(obs) + obs = setup_model(obs, model=datadir+'/crab.xml') # Run analysis pipeline - run_pipeline(obs) + run_pipeline(obs, model=datadir+'/crab.xml') diff --git a/examples/pipeline_stacked_mem.py b/examples/pipeline_stacked_mem.py index a0c6986..4fffe13 100755 --- a/examples/pipeline_stacked_mem.py +++ b/examples/pipeline_stacked_mem.py @@ -18,6 +18,7 @@ # along with this program. If not, see . # # ========================================================================== +import sys import gammalib import ctools from cscripts import obsutils @@ -241,11 +242,17 @@ if __name__ == '__main__': print('* CTA stacked analysis pipeline *') print('********************************************') + # Get optional arguments + if len(sys.argv) == 2: + datadir = sys.argv[1] + else: + datadir = 'data' + # Setup observations obs = setup_observations() # Setup model - obs = setup_model(obs) + obs = setup_model(obs, model=datadir+'/crab.xml') # Run analysis pipeline run_pipeline(obs) diff --git a/examples/pipeline_unbinned_disk.py b/examples/pipeline_unbinned_disk.py index 1f93093..350caea 100755 --- a/examples/pipeline_unbinned_disk.py +++ b/examples/pipeline_unbinned_disk.py @@ -18,6 +18,7 @@ # along with this program. If not, see . # # ========================================================================== +import sys import gammalib import ctools from cscripts import obsutils @@ -192,11 +193,17 @@ if __name__ == '__main__': print('* CTA unbinned analysis pipeline *') print('********************************************') + # Get optional arguments + if len(sys.argv) == 2: + datadir = sys.argv[1] + else: + datadir = 'data' + # Setup observations obs = setup_observations() # Setup model - obs = setup_model(obs) + obs = setup_model(obs, model=datadir+'/crab.xml') # Run analysis pipeline - run_pipeline(obs) + run_pipeline(obs, model=datadir+'/crab.xml') diff --git a/examples/pipeline_unbinned_mem.py b/examples/pipeline_unbinned_mem.py index 925a515..6835a7c 100755 --- a/examples/pipeline_unbinned_mem.py +++ b/examples/pipeline_unbinned_mem.py @@ -18,6 +18,7 @@ # along with this program. If not, see . # # ========================================================================== +import sys import gammalib import ctools from cscripts import obsutils @@ -174,11 +175,17 @@ if __name__ == '__main__': print('* CTA unbinned analysis pipeline *') print('********************************************') + # Get optional arguments + if len(sys.argv) == 2: + datadir = sys.argv[1] + else: + datadir = 'data' + # Setup observations obs = setup_observations() # Setup model - obs = setup_model(obs) + obs = setup_model(obs, model=datadir+'/crab.xml') # Run analysis pipeline run_pipeline(obs) diff --git a/examples/show_response.py b/examples/show_response.py index 468f736..39eeecb 100755 --- a/examples/show_response.py +++ b/examples/show_response.py @@ -339,13 +339,13 @@ if __name__ == '__main__': # Set response dictionary rsps = [ - {'dbname': 'irf', - 'rspname': 'cta_dummy_irf.dat', - 'name': 'Prod1 (Array E, MPIK)', + {'dbname': 'prod2', + 'rspname': 'South_0.5h', + 'name': 'Prod2 (30 min)', 'color': 'b'}, - {'dbname': 'irf', - 'rspname': 'irf_file.fits', - 'name': 'Prod2 (Aar, IFAE)', + {'dbname': 'prod2', + 'rspname': 'South_50h', + 'name': 'Prod2 (50 h)', 'color': 'r'} ] diff --git a/models/Makefile.am b/models/Makefile.am index d00a11e..004941f 100644 --- a/models/Makefile.am +++ b/models/Makefile.am @@ -1,17 +1,33 @@ -## Process this file with automake to produce Makefile.in +############################################################################# +# Makefile for models # +# ------------------------------------------------------------------------- # +# Copyright (C) 2016 Juergen Knoedlseder # +# ------------------------------------------------------------------------- # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################# -# Background rate files to distribute -#bkgs = bkg_dummy.txt -#bkgsdir = $(datadir)/models -#bkgs_DATA = $(bkgs) +# Models to install +models = crab.xml \ + crab_poly.xml \ + crab_profile.xml \ + disk.xml \ + gauss.xml \ + shell.xml -# Models to distribute -models = crab.xml \ - crab_poly.xml \ - crab_profile.xml \ - disk.xml \ - gauss.xml \ - shell.xml +# Install models modelsdir = $(datadir)/models models_DATA = $(models) diff --git a/pyext/Makefile.am b/pyext/Makefile.am index 050b1f1..8150e50 100755 --- a/pyext/Makefile.am +++ b/pyext/Makefile.am @@ -29,96 +29,140 @@ # Works only if Python is available if WITH_PYTHON +# Set wrapper directory depending on the whether the wrappers were actually +# shipped with the distribution of whether the wrappers have to be build +# using swig +if BUILD_WRAPPERS + wrapperdir = $(builddir) +else + wrapperdir = $(srcdir) +endif + # Test scripts to be distributed in $(pyexecdir)/ctools/tests testscripts = ctools/tests/__init__.py \ - ../test/testing.py \ - ../test/test_python_ctools.py \ - ../test/test_ctobssim.py \ - ../test/test_ctselect.py \ - ../test/test_ctbin.py \ - ../test/test_ctlike.py \ - ../test/test_cttsmap.py \ - ../test/test_ctmodel.py \ - ../test/test_ctskymap.py \ - ../test/test_ctexpcube.py \ - ../test/test_ctpsfcube.py \ - ../test/test_ctedispcube.py \ - ../test/test_ctbkgcube.py \ - ../test/test_ctmapcube.py \ - ../test/test_ctcubemask.py \ - ../test/test_ctbutterfly.py \ - ../test/test_ctulimit.py \ - ../test/test_cterror.py \ - ../test/test_pipelines.py -testdata = ../test/data/crab.xml \ - ../test/data/crab_events.fits.gz \ - ../test/data/crab_cntmap.fits.gz \ - ../test/data/exclusion.reg -testirf = ../test/irf/cta_dummy_irf.dat - -# Distribute scripts -EXTRA_DIST = $(testscripts) $(testdata) $(testirf) + $(top_srcdir)/test/testing.py \ + $(top_srcdir)/test/test_python_ctools.py \ + $(top_srcdir)/test/test_ctobssim.py \ + $(top_srcdir)/test/test_ctselect.py \ + $(top_srcdir)/test/test_ctbin.py \ + $(top_srcdir)/test/test_ctlike.py \ + $(top_srcdir)/test/test_cttsmap.py \ + $(top_srcdir)/test/test_ctmodel.py \ + $(top_srcdir)/test/test_ctskymap.py \ + $(top_srcdir)/test/test_ctexpcube.py \ + $(top_srcdir)/test/test_ctpsfcube.py \ + $(top_srcdir)/test/test_ctedispcube.py \ + $(top_srcdir)/test/test_ctbkgcube.py \ + $(top_srcdir)/test/test_ctmapcube.py \ + $(top_srcdir)/test/test_ctcubemask.py \ + $(top_srcdir)/test/test_ctbutterfly.py \ + $(top_srcdir)/test/test_ctulimit.py \ + $(top_srcdir)/test/test_cterror.py \ + $(top_srcdir)/test/test_pipelines.py + +# Test data to be distributed in $(pyexecdir)/ctools/tests/data +testdata = $(top_srcdir)/test/data/crab.xml \ + $(top_srcdir)/test/data/crab_events.fits.gz \ + $(top_srcdir)/test/data/crab_cntmap.fits.gz \ + $(top_srcdir)/test/data/exclusion.reg + +# Install test scripts and test data. Note that we don't need to prepend +# $(DESTDIR) here (not fully clear why, but that's the way it is) + testscriptsdir = $(pyexecdir)/ctools/tests testscripts_DATA = $(testscripts) testdatadir = $(pyexecdir)/ctools/tests/data testdata_DATA = $(testdata) -testirfdir = $(pyexecdir)/ctools/tests/irf -testirf_DATA = $(testirf) -# Set SWIG interface filename -SWIG_INTERFACE = ctools/tools.i +# If building of Python wrappers was requested then add them to the build +# source +if BUILD_WRAPPERS -# Dependencies. Obtain the list of dependencies by executing ls. -DEPFILES = $(shell ls *.Pi 2> /dev/null) -include $(DEPFILES) +# Set SWIG compile command +SWIGCOMPILE = $(SWIG) -c++ -python -Wall \ + -I$(DESTDIR)$(prefix)/share/gammalib/swig \ + -I$(GAMMALIB)/share/gammalib/swig \ + -I$(top_srcdir)/pyext -# Define the targets that should be built before anything else. -# These are honored by 'make all', 'make check' and 'make install'. -if HAVE_SWIG - BUILT_SOURCES = ctools/tools_wrap.cpp ctools/tools.py -endif +# Sources that are required for the build. All targets in the list will be +# built before anything. These are honored by 'make all', 'make check' and +# 'make install'. We use this here to make sure that all these targets are +# build by swig before we start compiling the Python modules. +BUILT_SOURCES = $(wrapperdir)/ctools/tools_wrap.cpp \ + $(wrapperdir)/ctools/tools.py -# Set files to be removed in clean. We remove only the SWIG interface files -# if SWIG is available to rebuild them. -if HAVE_SWIG - CLEAN_FILES = $(BUILT_SOURCES) -endif -CLEANFILES = $(CLEAN_FILES) $(DEPFILES) +# Add the wrappers to the files that will be deleted in a 'make clean' +CLEAN_FILES = $(BUILT_SOURCES) -# Set SWIG compile command -SWIGCOMPILE = $(SWIG) -c++ -python -Wall -I$(prefix)/share/gammalib/swig -I$(GAMMALIB)/share/gammalib/swig +# Rule to build SWIG wrappers +swig: $(BUILT_SOURCES) + +# Rule for building Python wrappers using SWIG. +ctools/tools.py: ctools/tools_wrap.cpp +ctools/tools_wrap.cpp: ctools/tools.i + if $(SWIGCOMPILE) -MMD -MF "tools.Tpi" -o ctools/tools_wrap.cpp $<; \ + then mv -f "tools.Tpi" "tools.Pi"; else rm -f "tools.Tpi"; exit 1; fi + +# ... otherwise, if building of Python wrappers has not been required then +# they are located in the source directory and we don't have to build them +# using swig +else +CLEAN_FILES = +BUILT_SOURCES = +endif # BUILD_WRAPPERS + +# Extra files to be distributed in the tar file +EXTRA_DIST = ctools/tests \ + $(wrapperdir)/ctools/tools_wrap.cpp \ + $(wrapperdir)/ctools/tools.py \ + $(testscripts) \ + $(testdata) \ + $(testirf) + +# Dependencies. Obtain the list of dependencies by executing ls. +DEPFILES = $(shell ls *.Pi 2> /dev/null) +include $(DEPFILES) +# Things we want to do when 'make' is invoked. all-local: build -# We build the python extension twice since the install step needs the result -# in a specific directory and the test make check has no access to the name -# of this specific directory. So we build one instance for checking, the other -# for installation. If we could get the name built by distutils we could avoid -# this. -build: ctools/tools_wrap.cpp ctools/tools.py +# Build the ctools extension module +build: $(BUILT_SOURCES) $(PYTHON) setup.py build if IS_ELCAPITAN -for f in build/ctools/ctools/_*.so; do \ echo "Post process module "$$f; \ install_name_tool -change $(libdir)/libctools.1.dylib @rpath/libctools.1.dylib $$f; \ - install_name_tool -change $(libdir)/libgamma.1.dylib @rpath/libgamma.1.dylib $$f; \ + install_name_tool -change $(libdir)/libgamma.2.dylib @rpath/libgamma.2.dylib $$f; \ install_name_tool -add_rpath $(libdir) $$f; \ - install_name_tool -add_rpath $(abs_top_srcdir)/src/.libs $$f; \ + install_name_tool -add_rpath $(abs_top_builddir)/src/.libs $$f; \ done endif +# Install the ctools Python module install-exec-local: - $(PYTHON) setup.py install --prefix=$(prefix) + $(PYTHON) setup.py install --prefix=$(DESTDIR)$(prefix) -clean-local: - rm -rf build _tools.so +# Uninstall the ctools Python module +uninstall-local: + rm -rf $(DESTDIR)$(pyexecdir)/ctools/*.py + rm -rf $(DESTDIR)$(pyexecdir)/ctools/*.pyc + rm -rf $(DESTDIR)$(pyexecdir)/ctools/*.so + rm -rf $(DESTDIR)$(pyexecdir)/ctools/__pycache__ + rm -rf $(DESTDIR)$(pyexecdir)/ctools/tests/*.pyc + rm -rf $(DESTDIR)$(pyexecdir)/ctools/tests/__pycache__ + rm -rf $(DESTDIR)$(pyexecdir)/ctools-@VERSION@*.egg-info -# Rule for building Python wrappers using SWIG. -if HAVE_SWIG -ctools/tools.py: ctools/tools_wrap.cpp -ctools/tools_wrap.cpp: $(SWIG_INTERFACE) - if $(SWIGCOMPILE) -MMD -MF "tools.Tpi" -o ctools/tools_wrap.cpp $<; \ - then mv -f "tools.Tpi" "tools.Pi"; else rm -f "tools.Tpi"; exit 1; fi -endif # HAVE_SWIG +# Set files to be removed in 'make clean' +CLEANFILES = $(CLEAN_FILES) $(DEPFILES) + +# Files to be removed in build directory +clean-local: + rm -rf build + rm -rf $(builddir)/ctools/*.py + rm -rf $(builddir)/ctools/*.pyc + rm -rf $(builddir)/ctools/*_wrap.cpp + rm -rf $(builddir)/ctools/_tools.so + rm -rf $(builddir)/ctools/__pycache__ endif # WITH_PYTHON diff --git a/pyext/setup.py.in b/pyext/setup.py.in index 5c62c16..af975fe 100644 --- a/pyext/setup.py.in +++ b/pyext/setup.py.in @@ -24,15 +24,25 @@ import glob import os import sys +# Define package name +pkg_name = 'ctools' + # Detect execution mode is_build = True if (len(sys.argv) >= 2): if (sys.argv[1] == 'install'): is_build = False if is_build: - sys.stdout.write("Python extension module building:\n") + print('Python extension module building:') else: - sys.stdout.write("Python extension module installation:\n") + print('Python extension module installation:') + +# Set prefix +prefix = '@prefix@' +if (len(sys.argv) >= 3): + if (sys.argv[2].find('--prefix') != -1): + start = sys.argv[2].find('=') + 1 + prefix = sys.argv[2][start:] # Darwin MacPorts kluge: Remove -L/opt/local/lib path from LDSHARED as this # overrides the GammaLib settings. Otherwise, MacPorts libraries would be @@ -52,33 +62,33 @@ if sys.platform.lower().startswith("darwin"): else: ldshared_rm += option + ' ' if (len(ldshared_rm) > 0): - sys.stdout.write("Removed following option(s) from LDSHARED: "+ldshared_rm+"\n") + print('Removed following option(s) from LDSHARED: %s' % (ldshared_rm)) # Set LDSHARED cvars['LDSHARED'] = ldshared_new # Set default include directories and data files -include_dirs = ['@prefix@/include/gammalib'] +include_dirs = [prefix+'/include/gammalib'] install_files = glob.glob('@top_srcdir@/pyext/*.i') library_dirs = ['../src/.libs'] runtime_library_dirs = ['../src/.libs'] libraries = ['ctools','gamma'] # Add install directory to runtime library path -if os.path.exists('@prefix@/lib'): - library_dirs.append('@prefix@/lib') - runtime_library_dirs.append('@prefix@/lib') +if os.path.exists(prefix+'/lib'): + library_dirs.append(prefix+'/lib') + runtime_library_dirs.append(prefix+'/lib') # Add application include files. The method we use here is not very # intelligent as it simple will add all names that start with 'ct' # in the src directory. Once we added the ctools script we had to # add an explicit filter to avoid appending those. -dirs = glob.glob('../src/ct*') +dirs = glob.glob('@top_srcdir@/src/ct*') for dir in dirs: if len(dir) > 0 and 'ctools' not in dir: path = os.path.abspath(dir) include_dirs.append(path) -include_dirs.append(os.path.abspath('../src/support')) +include_dirs.append(os.path.abspath('@top_srcdir@/src/support')) # Add extra libraries extra_libs = ('@PYTHON_EXTRA_LIBS@').split(',') @@ -104,7 +114,7 @@ for extra_include_dir in extra_include_dirs: include_dirs.append(dir) # Set data files to install. -data_files=[('@prefix@/share/ctools/swig', install_files)] +data_files=[(prefix+'/share/ctools/swig', install_files)] # Optionally enable OpenMP if '@OPENMP_TRUE@' != '#': @@ -123,6 +133,24 @@ if len('@COVERAGE_CXXFLAGS@') > 0: if '@IS_ELCAPITAN_TRUE@' != '#': extra_link_args.append('-headerpad_max_install_names') +# If this is a build then we may need to copy over a bunch of files +if is_build: + + # In case that wrappers were not built then copy the module wrapper files + # from the source to the build directory + if '@BUILD_WRAPPERS_FALSE@' != '#': + py_file = pkg_name+'/tools.py' + cpp_file = pkg_name+'/tools_wrap.cpp' + os.system('cp %s %s' % ('@srcdir@/'+cpp_file, '@builddir@/'+cpp_file)) + os.system('cp %s %s' % ('@srcdir@/'+py_file, '@builddir@/'+py_file)) + + # In case that the build directory is different from the source directory + # then copy all cscripts and parfiles from the source directory to the + # build directory + if '@top_srcdir@' != '@top_builddir@': + os.system('cp %s/cscripts/*.py %s/cscripts' % ('@top_srcdir@', '@top_builddir@')) + os.system('cp %s/cscripts/*.par %s/cscripts' % ('@top_srcdir@', '@top_builddir@')) + # Setup setup(name='@PACKAGE_NAME@', version='@PACKAGE_VERSION@', @@ -130,7 +158,6 @@ setup(name='@PACKAGE_NAME@', author='Juergen Knoedlseder', author_email='@PACKAGE_BUGREPORT@', url='http://cta.irap.omp.eu/ctools/', - py_modules=['ctools.tools'], ext_modules=[Extension('ctools._tools', ['ctools/tools_wrap.cpp'], include_dirs=include_dirs, library_dirs=library_dirs, @@ -138,10 +165,11 @@ setup(name='@PACKAGE_NAME@', runtime_library_dirs=runtime_library_dirs, extra_compile_args=extra_compile_args, extra_link_args=extra_link_args)], + py_modules=['ctools.tools'], data_files=data_files, license="GNU GPL v3", long_description="CTA science analysis tools", - platforms=["Linux", "Solaris", "Mac OS-X", "Unix", "BSD"], + platforms=['Linux', 'Solaris', 'Mac OS-X', 'Unix', 'BSD'], ) # Post-processing. A symbolic link is created to the directory containing the @@ -151,12 +179,12 @@ if is_build: try: os.chdir('build') os.remove('ctools') - sys.stdout.write("Removed symbolic link build/ctools.\n") + print('Removed symbolic link build/ctools.') except: pass try: path = glob.glob('lib.*') os.symlink(path[0], 'ctools') - sys.stdout.write("Created symbolic link build/ctools.\n") + print('Created symbolic link build/ctools.') except: - sys.stdout.write("WARNING: Failed to create symbolic link build/ctools.\n") + print('WARNING: Failed to create symbolic link build/ctools.') diff --git a/src/Makefile.am b/src/Makefile.am index 181ea7c..d56177f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,4 +1,23 @@ -## Process this file with automake to produce Makefile.in +############################################################################# +# Makefile.am for ctools module # +# ------------------------------------------------------------------------- # +# Copyright (C) 2016 Juergen Knoedlseder # +# ------------------------------------------------------------------------- # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################# # Darwin support MACOSX_DEPLOYMENT_TARGET=@CONFIGURE_MACOSX_DEPLOYMENT_TARGET@ @@ -60,10 +79,13 @@ scripts_DATA = $(scripts) # Things to install install-data-local: help-install +# Things to uninstall +uninstall-local: help-uninstall + # Install help files help-install: @$(mkinstalldirs) $(DESTDIR)$(datadir)/help && \ - for file in $(top_srcdir)/doc/source/reference_manual/c*.rst ; do \ + for file in $(top_srcdir)/doc/source/users/reference_manual/c*.rst ; do \ filename="$${file##*/}" ; \ basename="$${filename%%.*}" ; \ helpname="$$basename.txt" ; \ @@ -75,6 +97,10 @@ help-install: rm -rf $(DESTDIR)$(datadir)/help/"$$helpname".bak ; \ done +# Uninstall help files +help-uninstall: + rm -rf $(DESTDIR)$(datadir)/help + # Add hook rule to make scripts executable install-data-hook: @list='$(scripts_DATA)';\ diff --git a/src/ctbin/Makefile.am b/src/ctbin/Makefile.am index 3e695a0..2600a05 100644 --- a/src/ctbin/Makefile.am +++ b/src/ctbin/Makefile.am @@ -1,4 +1,23 @@ -## Process this file with automake to produce Makefile.in +############################################################################# +# Makefile.am for ctbin tool # +# ------------------------------------------------------------------------- # +# Copyright (C) 2016 Juergen Knoedlseder # +# ------------------------------------------------------------------------- # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################# # Set include directories INCLUDES = -I$(top_srcdir)/src/support @@ -7,7 +26,7 @@ INCLUDES = -I$(top_srcdir)/src/support bin_PROGRAMS = ctbin # Sources -sources = ctbin.cpp +sources = ctbin.cpp ctbin.hpp # Libtool library noinst_LTLIBRARIES = libctbin.la @@ -18,8 +37,11 @@ libctbin_la_LDFLAGS = @OPENMP_LIB_LDFLAGS@ ctbin_SOURCES = main.cpp ctbin_LDFLAGS = $(LIB_LINK_OPTION) @LDFLAGS@ ctbin_CPPFLAGS = @CPPFLAGS@ -ctbin_LDADD = libctbin.la $(top_srcdir)/src/support/libsupport.la +ctbin_LDADD = libctbin.la $(top_builddir)/src/support/libsupport.la # Parameter files pfilesdir = $(prefix)/syspfiles -pfiles_DATA = ctbin.par +pfiles_DATA = $(srcdir)/ctbin.par + +# Extra files to be distributed in the tar file +EXTRA_DIST = $(pfiles_DATA) diff --git a/src/ctbkgcube/Makefile.am b/src/ctbkgcube/Makefile.am index db6f5da..9fd0ff9 100644 --- a/src/ctbkgcube/Makefile.am +++ b/src/ctbkgcube/Makefile.am @@ -1,4 +1,23 @@ -## Process this file with automake to produce Makefile.in +############################################################################# +# Makefile.am for ctbkgcube tool # +# ------------------------------------------------------------------------- # +# Copyright (C) 2016 Juergen Knoedlseder # +# ------------------------------------------------------------------------- # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################# # Set include directories INCLUDES = -I$(top_srcdir)/src/support @@ -7,7 +26,7 @@ INCLUDES = -I$(top_srcdir)/src/support bin_PROGRAMS = ctbkgcube # Sources -sources = ctbkgcube.cpp +sources = ctbkgcube.cpp ctbkgcube.hpp # Libtool library noinst_LTLIBRARIES = libctbkgcube.la @@ -18,8 +37,11 @@ libctbkgcube_la_LDFLAGS = @OPENMP_LIB_LDFLAGS@ ctbkgcube_SOURCES = main.cpp ctbkgcube_LDFLAGS = $(LIB_LINK_OPTION) @LDFLAGS@ ctbkgcube_CPPFLAGS = @CPPFLAGS@ -ctbkgcube_LDADD = libctbkgcube.la $(top_srcdir)/src/support/libsupport.la +ctbkgcube_LDADD = libctbkgcube.la $(top_builddir)/src/support/libsupport.la # Parameter files pfilesdir = $(prefix)/syspfiles -pfiles_DATA = ctbkgcube.par +pfiles_DATA = $(srcdir)/ctbkgcube.par + +# Extra files to be distributed in the tar file +EXTRA_DIST = $(pfiles_DATA) diff --git a/src/ctbutterfly/Makefile.am b/src/ctbutterfly/Makefile.am index 2e4587f..d1fba36 100644 --- a/src/ctbutterfly/Makefile.am +++ b/src/ctbutterfly/Makefile.am @@ -1,4 +1,23 @@ -## Process this file with automake to produce Makefile.in +############################################################################# +# Makefile.am for ctbutterfly tool # +# ------------------------------------------------------------------------- # +# Copyright (C) 2016 Juergen Knoedlseder # +# ------------------------------------------------------------------------- # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################# # Set include directories INCLUDES = -I$(top_srcdir)/src/support @@ -7,7 +26,7 @@ INCLUDES = -I$(top_srcdir)/src/support bin_PROGRAMS = ctbutterfly # Sources -sources = ctbutterfly.cpp +sources = ctbutterfly.cpp ctbutterfly.hpp # Libtool library noinst_LTLIBRARIES = libctbutterfly.la @@ -18,8 +37,11 @@ libctbutterfly_la_LDFLAGS = @OPENMP_LIB_LDFLAGS@ ctbutterfly_SOURCES = main.cpp ctbutterfly_LDFLAGS = $(LIB_LINK_OPTION) @LDFLAGS@ ctbutterfly_CPPFLAGS = @CPPFLAGS@ -ctbutterfly_LDADD = libctbutterfly.la $(top_srcdir)/src/support/libsupport.la +ctbutterfly_LDADD = libctbutterfly.la $(top_builddir)/src/support/libsupport.la # Parameter files pfilesdir = $(prefix)/syspfiles -pfiles_DATA = ctbutterfly.par +pfiles_DATA = $(srcdir)/ctbutterfly.par + +# Extra files to be distributed in the tar file +EXTRA_DIST = $(pfiles_DATA) diff --git a/src/ctcubemask/Makefile.am b/src/ctcubemask/Makefile.am index 22f9ab3..250c50f 100644 --- a/src/ctcubemask/Makefile.am +++ b/src/ctcubemask/Makefile.am @@ -1,4 +1,23 @@ -## Process this file with automake to produce Makefile.in +############################################################################# +# Makefile.am for ctcubemask tool # +# ------------------------------------------------------------------------- # +# Copyright (C) 2016 Juergen Knoedlseder # +# ------------------------------------------------------------------------- # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################# # Set include directories INCLUDES = -I$(top_srcdir)/src/support @@ -7,7 +26,7 @@ INCLUDES = -I$(top_srcdir)/src/support bin_PROGRAMS = ctcubemask # Sources -sources = ctcubemask.cpp +sources = ctcubemask.cpp ctcubemask.hpp # Libtool library (only needed for python bindings) noinst_LTLIBRARIES = libctcubemask.la @@ -18,8 +37,11 @@ libctcubemask_la_LDFLAGS = @OPENMP_LIB_LDFLAGS@ ctcubemask_SOURCES = main.cpp ctcubemask_LDFLAGS = $(LIB_LINK_OPTION) @LDFLAGS@ ctcubemask_CPPFLAGS = @CPPFLAGS@ -ctcubemask_LDADD = libctcubemask.la $(top_srcdir)/src/support/libsupport.la +ctcubemask_LDADD = libctcubemask.la $(top_builddir)/src/support/libsupport.la # Parameter files pfilesdir = $(prefix)/syspfiles -pfiles_DATA = ctcubemask.par +pfiles_DATA = $(srcdir)/ctcubemask.par + +# Extra files to be distributed in the tar file +EXTRA_DIST = $(pfiles_DATA) diff --git a/src/ctedispcube/Makefile.am b/src/ctedispcube/Makefile.am index bf905d9..c39fe83 100644 --- a/src/ctedispcube/Makefile.am +++ b/src/ctedispcube/Makefile.am @@ -1,4 +1,23 @@ -## Process this file with automake to produce Makefile.in +############################################################################# +# Makefile.am for ctedispcube tool # +# ------------------------------------------------------------------------- # +# Copyright (C) 2016 Juergen Knoedlseder # +# ------------------------------------------------------------------------- # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################# # Set include directories INCLUDES = -I$(top_srcdir)/src/support @@ -7,7 +26,7 @@ INCLUDES = -I$(top_srcdir)/src/support bin_PROGRAMS = ctedispcube # Sources -sources = ctedispcube.cpp +sources = ctedispcube.cpp ctedispcube.hpp # Libtool library noinst_LTLIBRARIES = libctedispcube.la @@ -18,8 +37,11 @@ libctedispcube_la_LDFLAGS = @OPENMP_LIB_LDFLAGS@ ctedispcube_SOURCES = main.cpp ctedispcube_LDFLAGS = $(LIB_LINK_OPTION) @LDFLAGS@ ctedispcube_CPPFLAGS = @CPPFLAGS@ -ctedispcube_LDADD = libctedispcube.la $(top_srcdir)/src/support/libsupport.la +ctedispcube_LDADD = libctedispcube.la $(top_builddir)/src/support/libsupport.la # Parameter files pfilesdir = $(prefix)/syspfiles -pfiles_DATA = ctedispcube.par +pfiles_DATA = $(srcdir)/ctedispcube.par + +# Extra files to be distributed in the tar file +EXTRA_DIST = $(pfiles_DATA) diff --git a/src/cterror/Makefile.am b/src/cterror/Makefile.am index 50d07f0..306e333 100644 --- a/src/cterror/Makefile.am +++ b/src/cterror/Makefile.am @@ -1,4 +1,23 @@ -## Process this file with automake to produce Makefile.in +############################################################################# +# Makefile.am for cterror tool # +# ------------------------------------------------------------------------- # +# Copyright (C) 2016 Juergen Knoedlseder # +# ------------------------------------------------------------------------- # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################# # Set include directories INCLUDES = -I$(top_srcdir)/src/support @@ -7,7 +26,7 @@ INCLUDES = -I$(top_srcdir)/src/support bin_PROGRAMS = cterror # Sources -sources = cterror.cpp +sources = cterror.cpp cterror.hpp # Libtool library noinst_LTLIBRARIES = libcterror.la @@ -18,8 +37,11 @@ libcterror_la_LDFLAGS = @OPENMP_LIB_LDFLAGS@ cterror_SOURCES = main.cpp cterror_LDFLAGS = $(LIB_LINK_OPTION) @LDFLAGS@ cterror_CPPFLAGS = @CPPFLAGS@ -cterror_LDADD = libcterror.la $(top_srcdir)/src/support/libsupport.la +cterror_LDADD = libcterror.la $(top_builddir)/src/support/libsupport.la # Parameter files pfilesdir = $(prefix)/syspfiles -pfiles_DATA = cterror.par +pfiles_DATA = $(srcdir)/cterror.par + +# Extra files to be distributed in the tar file +EXTRA_DIST = $(pfiles_DATA) diff --git a/src/ctexpcube/Makefile.am b/src/ctexpcube/Makefile.am index 898afe6..09b5dc2 100644 --- a/src/ctexpcube/Makefile.am +++ b/src/ctexpcube/Makefile.am @@ -1,4 +1,23 @@ -## Process this file with automake to produce Makefile.in +############################################################################# +# Makefile.am for ctexpcube tool # +# ------------------------------------------------------------------------- # +# Copyright (C) 2016 Juergen Knoedlseder # +# ------------------------------------------------------------------------- # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################# # Set include directories INCLUDES = -I$(top_srcdir)/src/support @@ -7,7 +26,7 @@ INCLUDES = -I$(top_srcdir)/src/support bin_PROGRAMS = ctexpcube # Sources -sources = ctexpcube.cpp +sources = ctexpcube.cpp ctexpcube.hpp # Libtool library noinst_LTLIBRARIES = libctexpcube.la @@ -18,8 +37,11 @@ libctexpcube_la_LDFLAGS = @OPENMP_LIB_LDFLAGS@ ctexpcube_SOURCES = main.cpp ctexpcube_LDFLAGS = $(LIB_LINK_OPTION) @LDFLAGS@ ctexpcube_CPPFLAGS = @CPPFLAGS@ -ctexpcube_LDADD = libctexpcube.la $(top_srcdir)/src/support/libsupport.la +ctexpcube_LDADD = libctexpcube.la $(top_builddir)/src/support/libsupport.la # Parameter files pfilesdir = $(prefix)/syspfiles -pfiles_DATA = ctexpcube.par +pfiles_DATA = $(srcdir)/ctexpcube.par + +# Extra files to be distributed in the tar file +EXTRA_DIST = $(pfiles_DATA) diff --git a/src/ctlike/Makefile.am b/src/ctlike/Makefile.am index d795a3f..77bb7a6 100644 --- a/src/ctlike/Makefile.am +++ b/src/ctlike/Makefile.am @@ -1,4 +1,23 @@ -## Process this file with automake to produce Makefile.in +############################################################################# +# Makefile.am for ctlike tool # +# ------------------------------------------------------------------------- # +# Copyright (C) 2016 Juergen Knoedlseder # +# ------------------------------------------------------------------------- # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################# # Set include directories INCLUDES = -I$(top_srcdir)/src/support @@ -7,7 +26,7 @@ INCLUDES = -I$(top_srcdir)/src/support bin_PROGRAMS = ctlike # Sources -sources = ctlike.cpp +sources = ctlike.cpp ctlike.hpp # Libtool library noinst_LTLIBRARIES = libctlike.la @@ -18,8 +37,11 @@ libctlike_la_LDFLAGS = @OPENMP_LIB_LDFLAGS@ ctlike_SOURCES = main.cpp ctlike_LDFLAGS = $(LIB_LINK_OPTION) @LDFLAGS@ ctlike_CPPFLAGS = @CPPFLAGS@ -ctlike_LDADD = libctlike.la $(top_srcdir)/src/support/libsupport.la +ctlike_LDADD = libctlike.la $(top_builddir)/src/support/libsupport.la # Parameter files pfilesdir = $(prefix)/syspfiles -pfiles_DATA = ctlike.par +pfiles_DATA = $(srcdir)/ctlike.par + +# Extra files to be distributed in the tar file +EXTRA_DIST = $(pfiles_DATA) diff --git a/src/ctmapcube/Makefile.am b/src/ctmapcube/Makefile.am index 7d43f46..3d7cdbe 100644 --- a/src/ctmapcube/Makefile.am +++ b/src/ctmapcube/Makefile.am @@ -1,4 +1,23 @@ -## Process this file with automake to produce Makefile.in +############################################################################# +# Makefile.am for ctmapcube tool # +# ------------------------------------------------------------------------- # +# Copyright (C) 2016 Juergen Knoedlseder # +# ------------------------------------------------------------------------- # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################# # Set include directories INCLUDES = -I$(top_srcdir)/src/support @@ -7,7 +26,7 @@ INCLUDES = -I$(top_srcdir)/src/support bin_PROGRAMS = ctmapcube # Sources -sources = ctmapcube.cpp +sources = ctmapcube.cpp ctmapcube.hpp # Libtool library noinst_LTLIBRARIES = libctmapcube.la @@ -18,8 +37,11 @@ libctmapcube_la_LDFLAGS = @OPENMP_LIB_LDFLAGS@ ctmapcube_SOURCES = main.cpp ctmapcube_LDFLAGS = $(LIB_LINK_OPTION) @LDFLAGS@ ctmapcube_CPPFLAGS = @CPPFLAGS@ -ctmapcube_LDADD = libctmapcube.la $(top_srcdir)/src/support/libsupport.la +ctmapcube_LDADD = libctmapcube.la $(top_builddir)/src/support/libsupport.la # Parameter files pfilesdir = $(prefix)/syspfiles -pfiles_DATA = ctmapcube.par +pfiles_DATA = $(srcdir)/ctmapcube.par + +# Extra files to be distributed in the tar file +EXTRA_DIST = $(pfiles_DATA) diff --git a/src/ctmodel/Makefile.am b/src/ctmodel/Makefile.am index 65db5c8..65ec51e 100644 --- a/src/ctmodel/Makefile.am +++ b/src/ctmodel/Makefile.am @@ -1,4 +1,23 @@ -## Process this file with automake to produce Makefile.in +############################################################################# +# Makefile.am for ctmodel tool # +# ------------------------------------------------------------------------- # +# Copyright (C) 2016 Juergen Knoedlseder # +# ------------------------------------------------------------------------- # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################# # Set include directories INCLUDES = -I$(top_srcdir)/src/support @@ -7,7 +26,7 @@ INCLUDES = -I$(top_srcdir)/src/support bin_PROGRAMS = ctmodel # Sources -sources = ctmodel.cpp +sources = ctmodel.cpp ctmodel.hpp # Libtool library noinst_LTLIBRARIES = libctmodel.la @@ -18,8 +37,11 @@ libctmodel_la_LDFLAGS = @OPENMP_LIB_LDFLAGS@ ctmodel_SOURCES = main.cpp ctmodel_LDFLAGS = $(LIB_LINK_OPTION) @LDFLAGS@ ctmodel_CPPFLAGS = @CPPFLAGS@ -ctmodel_LDADD = libctmodel.la $(top_srcdir)/src/support/libsupport.la +ctmodel_LDADD = libctmodel.la $(top_builddir)/src/support/libsupport.la # Parameter files pfilesdir = $(prefix)/syspfiles -pfiles_DATA = ctmodel.par +pfiles_DATA = $(srcdir)/ctmodel.par + +# Extra files to be distributed in the tar file +EXTRA_DIST = $(pfiles_DATA) diff --git a/src/ctobssim/Makefile.am b/src/ctobssim/Makefile.am index 6f39ece..e84c7a9 100644 --- a/src/ctobssim/Makefile.am +++ b/src/ctobssim/Makefile.am @@ -1,4 +1,23 @@ -## Process this file with automake to produce Makefile.in +############################################################################# +# Makefile.am for ctobssim tool # +# ------------------------------------------------------------------------- # +# Copyright (C) 2016 Juergen Knoedlseder # +# ------------------------------------------------------------------------- # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################# # Set include directories INCLUDES = -I$(top_srcdir)/src/support @@ -7,7 +26,7 @@ INCLUDES = -I$(top_srcdir)/src/support bin_PROGRAMS = ctobssim # Sources -sources = ctobssim.cpp +sources = ctobssim.cpp ctobssim.hpp # Libtool library noinst_LTLIBRARIES = libctobssim.la @@ -18,8 +37,11 @@ libctobssim_la_LDFLAGS = @OPENMP_LIB_LDFLAGS@ ctobssim_SOURCES = main.cpp ctobssim_LDFLAGS = $(LIB_LINK_OPTION) @LDFLAGS@ ctobssim_CPPFLAGS = @CPPFLAGS@ -ctobssim_LDADD = libctobssim.la $(top_srcdir)/src/support/libsupport.la +ctobssim_LDADD = libctobssim.la $(top_builddir)/src/support/libsupport.la # Parameter files pfilesdir = $(prefix)/syspfiles -pfiles_DATA = ctobssim.par +pfiles_DATA = $(srcdir)/ctobssim.par + +# Extra files to be distributed in the tar file +EXTRA_DIST = $(pfiles_DATA) diff --git a/src/ctpsfcube/Makefile.am b/src/ctpsfcube/Makefile.am index 2ec6ade..6a745ee 100644 --- a/src/ctpsfcube/Makefile.am +++ b/src/ctpsfcube/Makefile.am @@ -1,4 +1,23 @@ -## Process this file with automake to produce Makefile.in +############################################################################# +# Makefile.am for ctpsfcube tool # +# ------------------------------------------------------------------------- # +# Copyright (C) 2016 Juergen Knoedlseder # +# ------------------------------------------------------------------------- # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################# # Set include directories INCLUDES = -I$(top_srcdir)/src/support @@ -7,7 +26,7 @@ INCLUDES = -I$(top_srcdir)/src/support bin_PROGRAMS = ctpsfcube # Sources -sources = ctpsfcube.cpp +sources = ctpsfcube.cpp ctpsfcube.hpp # Libtool library noinst_LTLIBRARIES = libctpsfcube.la @@ -18,8 +37,11 @@ libctpsfcube_la_LDFLAGS = @OPENMP_LIB_LDFLAGS@ ctpsfcube_SOURCES = main.cpp ctpsfcube_LDFLAGS = $(LIB_LINK_OPTION) @LDFLAGS@ ctpsfcube_CPPFLAGS = @CPPFLAGS@ -ctpsfcube_LDADD = libctpsfcube.la $(top_srcdir)/src/support/libsupport.la +ctpsfcube_LDADD = libctpsfcube.la $(top_builddir)/src/support/libsupport.la # Parameter files pfilesdir = $(prefix)/syspfiles -pfiles_DATA = ctpsfcube.par +pfiles_DATA = $(srcdir)/ctpsfcube.par + +# Extra files to be distributed in the tar file +EXTRA_DIST = $(pfiles_DATA) diff --git a/src/ctselect/Makefile.am b/src/ctselect/Makefile.am index 583e210..a1ae83d 100644 --- a/src/ctselect/Makefile.am +++ b/src/ctselect/Makefile.am @@ -1,4 +1,23 @@ -## Process this file with automake to produce Makefile.in +############################################################################# +# Makefile.am for ctselect tool # +# ------------------------------------------------------------------------- # +# Copyright (C) 2016 Juergen Knoedlseder # +# ------------------------------------------------------------------------- # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################# # Set include directories INCLUDES = -I$(top_srcdir)/src/support @@ -7,7 +26,7 @@ INCLUDES = -I$(top_srcdir)/src/support bin_PROGRAMS = ctselect # Sources -sources = ctselect.cpp +sources = ctselect.cpp ctselect.hpp # Libtool library (only needed for python bindings) noinst_LTLIBRARIES = libctselect.la @@ -18,8 +37,11 @@ libctselect_la_LDFLAGS = @OPENMP_LIB_LDFLAGS@ ctselect_SOURCES = main.cpp ctselect_LDFLAGS = $(LIB_LINK_OPTION) @LDFLAGS@ ctselect_CPPFLAGS = @CPPFLAGS@ -ctselect_LDADD = libctselect.la $(top_srcdir)/src/support/libsupport.la +ctselect_LDADD = libctselect.la $(top_builddir)/src/support/libsupport.la # Parameter files pfilesdir = $(prefix)/syspfiles -pfiles_DATA = ctselect.par +pfiles_DATA = $(srcdir)/ctselect.par + +# Extra files to be distributed in the tar file +EXTRA_DIST = $(pfiles_DATA) diff --git a/src/ctskymap/Makefile.am b/src/ctskymap/Makefile.am index 652d7e6..9625854 100644 --- a/src/ctskymap/Makefile.am +++ b/src/ctskymap/Makefile.am @@ -1,4 +1,23 @@ -## Process this file with automake to produce Makefile.in +############################################################################# +# Makefile.am for ctskymap tool # +# ------------------------------------------------------------------------- # +# Copyright (C) 2016 Juergen Knoedlseder # +# ------------------------------------------------------------------------- # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################# # Set include directories INCLUDES = -I$(top_srcdir)/src/support @@ -7,7 +26,7 @@ INCLUDES = -I$(top_srcdir)/src/support bin_PROGRAMS = ctskymap # Sources -sources = ctskymap.cpp +sources = ctskymap.cpp ctskymap.hpp # Libtool library noinst_LTLIBRARIES = libctskymap.la @@ -18,8 +37,11 @@ libctskymap_la_LDFLAGS = @OPENMP_LIB_LDFLAGS@ ctskymap_SOURCES = main.cpp ctskymap_LDFLAGS = $(LIB_LINK_OPTION) @LDFLAGS@ ctskymap_CPPFLAGS = @CPPFLAGS@ -ctskymap_LDADD = libctskymap.la $(top_srcdir)/src/support/libsupport.la +ctskymap_LDADD = libctskymap.la $(top_builddir)/src/support/libsupport.la # Parameter files pfilesdir = $(prefix)/syspfiles -pfiles_DATA = ctskymap.par +pfiles_DATA = $(srcdir)/ctskymap.par + +# Extra files to be distributed in the tar file +EXTRA_DIST = $(pfiles_DATA) diff --git a/src/cttsmap/Makefile.am b/src/cttsmap/Makefile.am index 2ed5c2b..502eee9 100644 --- a/src/cttsmap/Makefile.am +++ b/src/cttsmap/Makefile.am @@ -1,4 +1,23 @@ -## Process this file with automake to produce Makefile.in +############################################################################# +# Makefile.am for cttsmap tool # +# ------------------------------------------------------------------------- # +# Copyright (C) 2016 Juergen Knoedlseder # +# ------------------------------------------------------------------------- # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################# # Set include directories INCLUDES = -I$(top_srcdir)/src/support @@ -7,7 +26,7 @@ INCLUDES = -I$(top_srcdir)/src/support bin_PROGRAMS = cttsmap # Sources -sources = cttsmap.cpp +sources = cttsmap.cpp cttsmap.hpp # Libtool library noinst_LTLIBRARIES = libcttsmap.la @@ -18,8 +37,11 @@ libcttsmap_la_LDFLAGS = @OPENMP_LIB_LDFLAGS@ cttsmap_SOURCES = main.cpp cttsmap_LDFLAGS = $(LIB_LINK_OPTION) @LDFLAGS@ cttsmap_CPPFLAGS = @CPPFLAGS@ -cttsmap_LDADD = libcttsmap.la $(top_srcdir)/src/support/libsupport.la +cttsmap_LDADD = libcttsmap.la $(top_builddir)/src/support/libsupport.la # Parameter files pfilesdir = $(prefix)/syspfiles -pfiles_DATA = cttsmap.par +pfiles_DATA = $(srcdir)/cttsmap.par + +# Extra files to be distributed in the tar file +EXTRA_DIST = $(pfiles_DATA) diff --git a/src/ctulimit/Makefile.am b/src/ctulimit/Makefile.am index 6191d7f..29acd9f 100644 --- a/src/ctulimit/Makefile.am +++ b/src/ctulimit/Makefile.am @@ -1,4 +1,23 @@ -## Process this file with automake to produce Makefile.in +############################################################################# +# Makefile.am for ctulimit tool # +# ------------------------------------------------------------------------- # +# Copyright (C) 2016 Juergen Knoedlseder # +# ------------------------------------------------------------------------- # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################# # Set include directories INCLUDES = -I$(top_srcdir)/src/support @@ -7,7 +26,7 @@ INCLUDES = -I$(top_srcdir)/src/support bin_PROGRAMS = ctulimit # Sources -sources = ctulimit.cpp +sources = ctulimit.cpp ctulimit.hpp # Libtool library noinst_LTLIBRARIES = libctulimit.la @@ -18,8 +37,11 @@ libctulimit_la_LDFLAGS = @OPENMP_LIB_LDFLAGS@ ctulimit_SOURCES = main.cpp ctulimit_LDFLAGS = $(LIB_LINK_OPTION) @LDFLAGS@ ctulimit_CPPFLAGS = @CPPFLAGS@ -ctulimit_LDADD = libctulimit.la $(top_srcdir)/src/support/libsupport.la +ctulimit_LDADD = libctulimit.la $(top_builddir)/src/support/libsupport.la # Parameter files pfilesdir = $(prefix)/syspfiles -pfiles_DATA = ctulimit.par +pfiles_DATA = $(srcdir)/ctulimit.par + +# Extra files to be distributed in the tar file +EXTRA_DIST = $(pfiles_DATA) diff --git a/src/support/Makefile.am b/src/support/Makefile.am index e031dc9..98f1333 100644 --- a/src/support/Makefile.am +++ b/src/support/Makefile.am @@ -1,7 +1,26 @@ -## Process this file with automake to produce Makefile.in +############################################################################# +# Makefile.am for ctool base class # +# ------------------------------------------------------------------------- # +# Copyright (C) 2016 Juergen Knoedlseder # +# ------------------------------------------------------------------------- # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################# # Define sources for this directory -sources = ctool.cpp +sources = ctool.cpp ctool.hpp # Build libtool library noinst_LTLIBRARIES = libsupport.la diff --git a/test/Makefile.am b/test/Makefile.am index ef10ca1..067a2f1 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -1,4 +1,23 @@ -## Process this file with automake to produce Makefile.in +############################################################################# +# Makefile.am for ctools unit tests # +# ------------------------------------------------------------------------- # +# Copyright (C) 2016 Juergen Knoedlseder # +# ------------------------------------------------------------------------- # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################# # Darwin support MACOSX_DEPLOYMENT_TARGET=@CONFIGURE_MACOSX_DEPLOYMENT_TARGET@ @@ -6,7 +25,6 @@ MACOSX_DEPLOYMENT_TARGET=@CONFIGURE_MACOSX_DEPLOYMENT_TARGET@ # Optional python bindings if WITH_PYTHON - TEST_CSCRIPTS = test_cscripts.sh TEST_PYTHON_CTOOLS = test_python_ctools.sh TEST_PYTHON_CSCRIPTS = test_python_cscripts.sh TEST_PYTHON_EXAMPLES = test_examples.py @@ -15,13 +33,44 @@ endif # Set test environment TESTS_ENVIRONMENT = @RUNSHARED@=$(top_builddir)/src/.libs$(TEST_ENV_DIR):$(LIBDIR_GAMMALIB):$(@RUNSHARED@) \ - $(TEST_PYTHON_ENV) + $(TEST_PYTHON_ENV) \ + TEST_SRCDIR=$(abs_top_srcdir) \ + TEST_BUILDDIR=$(abs_top_builddir) \ + TEST_DATA=$(abs_top_srcdir)/test/data # Tests (these are the tests to be executed) TESTS = $(TEST_PYTHON_CTOOLS) \ $(TEST_PYTHON_CSCRIPTS) \ $(TEST_PYTHON_EXAMPLES) +# Create report directory +all-local: + mkdir -p reports + +# Files to be removed in build directory +clean-local: + rm -rf $(builddir)/*.fits + rm -rf $(builddir)/*.log + rm -rf $(builddir)/*.xml + rm -rf $(builddir)/*.eps + rm -rf $(builddir)/*.dat + rm -rf $(builddir)/*.reg + rm -rf $(builddir)/reports/*.xml + rm -rf $(builddir)/caldb + rm -rf $(builddir)/pfiles + rm -rf $(builddir)/prod3 + rm -rf $(builddir)/csroot2caldb_* + rm -rf $(builddir)/iactdata_* + +# Tests to be done on installed version +if WITH_PYTHON +installcheck-local: + @export CTOOLS=$(DESTDIR)$(prefix); \ + . $(DESTDIR)$(prefix)/bin/ctools-init.sh; \ + python -c 'import ctools; ctools.test()'; \ + python -c 'import cscripts; cscripts.test()' +endif + # Add Valgrind rule valgrind: @if type valgrind >/dev/null 2>&1; then \ diff --git a/test/data/iactdata/events.fits.gz b/test/data/iactdata/events.fits.gz new file mode 100644 index 0000000..6449c61 --- /dev/null +++ b/test/data/iactdata/events.fits.gz diff --git a/test/data/iactdata/hdu-index.fits.gz b/test/data/iactdata/hdu-index.fits.gz new file mode 100644 index 0000000..e7402a3 --- /dev/null +++ b/test/data/iactdata/hdu-index.fits.gz diff --git a/test/irf/irf_file.fits.gz b/test/data/iactdata/irf_file.fits.gz index e9e0aa4..e9e0aa4 100644 --- a/test/irf/irf_file.fits.gz +++ b/test/data/iactdata/irf_file.fits.gz diff --git a/test/iactdata/master.json b/test/data/iactdata/master.json index 51bb14c..51bb14c 100644 --- a/test/iactdata/master.json +++ b/test/data/iactdata/master.json diff --git a/test/iactdata/obs-index.fits.gz b/test/data/iactdata/obs-index.fits.gz index e209da4..e209da4 100644 --- a/test/iactdata/obs-index.fits.gz +++ b/test/data/iactdata/obs-index.fits.gz diff --git a/test/data/irf_file.fits.gz b/test/data/irf_file.fits.gz new file mode 100644 index 0000000..e9e0aa4 --- /dev/null +++ b/test/data/irf_file.fits.gz diff --git a/test/data/models.txt b/test/data/models.txt index 0561063..48de7d9 100644 --- a/test/data/models.txt +++ b/test/data/models.txt @@ -1,2 +1,2 @@ -data/model_cube_background.xml -data/model_cube_background2.xml +model_cube_background.xml +model_cube_background2.xml diff --git a/test/data/obs_unbinned.xml b/test/data/obs_unbinned.xml index fe07707..e6886a2 100644 --- a/test/data/obs_unbinned.xml +++ b/test/data/obs_unbinned.xml @@ -2,9 +2,9 @@ - - - - + + + + diff --git a/test/data/tsmaps.txt b/test/data/tsmaps.txt index 58654b1..652b3f9 100644 --- a/test/data/tsmaps.txt +++ b/test/data/tsmaps.txt @@ -1,2 +1,2 @@ -data/tsmap_0.fits -data/tsmap_1.fits +tsmap_0.fits +tsmap_1.fits diff --git a/test/data/workflow.xml b/test/data/workflow.xml index c050e49..2baeb5c 100644 --- a/test/data/workflow.xml +++ b/test/data/workflow.xml @@ -2,9 +2,9 @@ - - - + + + diff --git a/test/iactdata/hdu-index.fits.gz b/test/iactdata/hdu-index.fits.gz deleted file mode 100644 index a3dd5fe..0000000 --- a/test/iactdata/hdu-index.fits.gz +++ /dev/null diff --git a/test/irf/cta_dummy_irf.dat b/test/irf/cta_dummy_irf.dat deleted file mode 100644 index 0b6e757..0000000 --- a/test/irf/cta_dummy_irf.dat +++ /dev/null @@ -1,32 +0,0 @@ -log(E) Area r68 r80 ERes. BG Rate Diff Sens --1.7 261.6 0.3621 0.4908 0.5134 1.89924e-02 6.88237e-11 --1.5 5458.2 0.2712 0.3685 0.4129 1.00972e-01 1.72717e-11 --1.3 15590.0 0.1662 0.2103 0.2721 5.75623e-02 6.16963e-12 --1.1 26554.1 0.1253 0.1567 0.2611 2.13008e-02 2.89932e-12 --0.9 52100.5 0.1048 0.1305 0.1987 8.87292e-03 1.39764e-12 --0.7 66132.1 0.0827 0.1024 0.1698 1.09756e-03 6.03531e-13 --0.5 108656.8 0.0703 0.0867 0.1506 4.84287e-04 3.98147e-13 --0.3 129833.0 0.0585 0.0722 0.1338 1.57546e-04 3.23090e-13 --0.1 284604.3 0.0531 0.0656 0.1008 1.36703e-04 2.20178e-13 -0.1 263175.3 0.0410 0.0506 0.0831 2.09694e-05 1.87452e-13 -0.3 778048.6 0.0470 0.0591 0.0842 6.92374e-05 1.53976e-13 -0.5 929818.8 0.0391 0.0492 0.0650 1.45844e-05 1.18947e-13 -0.7 1078450.0 0.0335 0.0415 0.0541 1.15959e-05 1.51927e-13 -0.9 1448579.1 0.0317 0.0397 0.0516 4.71231e-06 1.42439e-13 -1.1 1899905.0 0.0290 0.0372 0.0501 8.14997e-06 1.96670e-13 -1.3 2476403.8 0.0285 0.0367 0.0538 5.91940e-06 2.20695e-13 -1.5 2832570.6 0.0284 0.0372 0.0636 7.33847e-06 3.22523e-13 -1.7 3534065.3 0.0290 0.0386 0.0731 1.34549e-05 4.84153e-13 -1.9 3250103.4 0.0238 0.0308 0.0729 4.42228e-06 6.26265e-13 -2.1 3916071.6 0.0260 0.0354 0.0908 2.26648e-06 7.69921e-13 ---------------------------------------------- -Notes - 1) log(E) = log10(E/TeV) - bin centre - 2) Eff Area - in square metres after background cut (no theta cut) - 3) Ang. Res - 68% containment radius of gamma-ray PSF post cuts - in degrees - 4) Ang. Res - 80% containment radius of gamma-ray PSF post cuts - in degrees - 5) Fractional Energy Resolution (rms) - 6) BG Rate - inside point-source selection region - post call cuts - in Hz - 7) Diff Sens - differential sensitivity for this bin expressed as E^2 dN/dE - - in erg cm^-2 s^-1 - for a 50 hours exposure - 5 sigma significance including - systematics and statistics and at least 10 photons. diff --git a/test/test_cscripts.sh.in b/test/test_cscripts.sh.in deleted file mode 100755 index eb1f73d..0000000 --- a/test/test_cscripts.sh.in +++ /dev/null @@ -1,577 +0,0 @@ -#! /bin/sh -# ========================================================================== -# This script tests all cscripts that are shipped with ctools -# -# Copyright (C) 2011-2016 Juergen Knoedlseder -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# -# ========================================================================== - -# -# Get echo command (to circumvent built-in echo on some systems) -# -ECHO=`which echo` - -# -# Print Header -# -$ECHO "" -$ECHO "*****************" -$ECHO "* Test cscripts *" -$ECHO "*****************" - - -# -# Remove any existing result files -# ================================ -rm -rf *.fits *.xml *.dat *.reg .coverage - - -# -# Creates pfiles directory -# ======================== -export PFILES=pfiles -export CALDB=$PWD/caldb -rm -rf $PFILES -mkdir -p $PFILES -cp -r ../src/*/*.par pfiles/ -cp -r ../cscripts/*.par pfiles/ -rm -rf $CALDB -mkdir -p $CALDB - - -# -# Test cscaldb -# ============ -$ECHO -n "Test cscaldb: " -chmod +x @abs_top_srcdir@/cscripts/cscaldb.py -@PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/cscaldb.py \ - chatter=4 > cscaldb.log -$ECHO -n "." -if [ -s "cscaldb.log" ] -then - $ECHO -n "." -else - $ECHO " cscaldb.log file is not valid" - exit 1 -fi -$ECHO " ok" - - -# -# Test csobs2caldb -# ================ -$ECHO -n "Test csobs2caldb: " -chmod +x @abs_top_srcdir@/cscripts/csobs2caldb.py -@PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/csobs2caldb.py \ - inobs="data/obs_unbinned.xml" \ - caldb="cta" \ - irf="Standard" \ - chatter=4 > csobs2caldb.log -$ECHO -n "." -if [ -s "$CALDB/data/cta/cta/bcf/Standard/irf_file.fits" ] -then - $ECHO -n "." -else - $ECHO " $CALDB/data/cta/cta/bcf/Standard/irf_file.fits file is not valid" - exit 1 -fi -$ECHO " ok" - - -# -# Test csobsdef -# ============= -$ECHO -n "Test csobsdef: " -chmod +x @abs_top_srcdir@/cscripts/csobsdef.py -@PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/csobsdef.py \ - inpnt="data/pntdef.dat" \ - outobs="obs.xml" \ - caldb="irf" \ - irf="cta_dummy_irf" \ - emin=0.1 \ - emax=100.0 \ - duration=1800.0 \ - rad=5.0 > csobsdef.log -$ECHO -n "." -if [ -s "obs.xml" ] -then - $ECHO -n "." -else - $ECHO " obs.xml file is not valid" - exit 1 -fi -$ECHO " ok" - - -# -# Test csobsinfo -# ============== -$ECHO -n "Test csobsinfo: " -chmod +x @abs_top_srcdir@/cscripts/csobsinfo.py -@PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/csobsinfo.py \ - inobs="obs.xml" \ - ds9file="obs.reg" \ - offset=yes \ - ra="83.6331" \ - dec="22.01" > csobsinfo.log -$ECHO -n "." -if [ -s "obs.reg" ] -then - $ECHO -n "." -else - $ECHO " obs.reg file is not valid" - exit 1 -fi -$ECHO " ok" - - -# -# Test csmodelinfo -# ================ -$ECHO -n "Test csmodelinfo: " -chmod +x @abs_top_srcdir@/cscripts/csmodelinfo.py -@PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/csmodelinfo.py \ - inmodel="data/crab.xml" \ - ds9file="model.reg" > csmodelinfo.log -$ECHO -n "." -if [ -s "model.reg" ] -then - $ECHO -n "." -else - $ECHO " model.reg file is not valid" - exit 1 -fi -$ECHO " ok" - - -# -# Test csmodelmerge -# ================= -$ECHO -n "Test csmodelmerge: " -# === space-separated === -chmod +x @abs_top_srcdir@/cscripts/csmodelmerge.py -@PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/csmodelmerge.py \ - inmodels="data/crab.xml data/source1.xml" \ - outmodel="merged_models.xml" > csmodelmerge.log -$ECHO -n "." -if [ -s "merged_models.xml" ] -then - $ECHO -n "." -else - $ECHO " merged_models.xml file is not valid" - exit 1 -fi -# === semi-colon separated === -@PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/csmodelmerge.py \ - inmodels="data/crab.xml;data/source1.xml" \ - outmodel="merged_models2.xml" > csmodelmerge.log -$ECHO -n "." -if [ -s "merged_models2.xml" ] -then - $ECHO -n "." -else - $ECHO " merged_models2.xml file is not valid" - exit 1 -fi -# === wildcard string === -@PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/csmodelmerge.py \ - inmodels="data/model_cube_background*.xml" \ - outmodel="merged_models3.xml" > csmodelmerge.log -$ECHO -n "." -if [ -s "merged_models3.xml" ] -then - $ECHO -n "." -else - $ECHO " merged_models3.xml file is not valid" - exit 1 -fi -# === ascii-file === -ls data/model_cube_background* > models.txt -@PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/csmodelmerge.py \ - inmodels="@models.txt" \ - outmodel="merged_models4.xml" > csmodelmerge.log -$ECHO -n "." -if [ -s "merged_models4.xml" ] -then - $ECHO -n "." -else - $ECHO " merged_models4.xml file is not valid" - exit 1 -fi -$ECHO " ok" -rm models.txt - - -# -# Test cstsmapmerge -# ================= -$ECHO -n "Test cstsmapmerge: " -# === semi-colon separated === -chmod +x @abs_top_srcdir@/cscripts/cstsmapmerge.py -@PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/cstsmapmerge.py \ - inmaps="data/tsmap_0.fits;data/tsmap_1.fits" \ - outmap="merged_tsmap1.fits" > cstsmapmerge.log -$ECHO -n "." -if [ -s "merged_tsmap1.fits" ] -then - $ECHO -n "." -else - $ECHO " merged_tsmap1.fits file is not valid" - exit 1 -fi -# === space-separated === -@PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/cstsmapmerge.py \ - inmaps="data/tsmap_0.fits data/tsmap_1.fits" \ - outmap="merged_tsmap2.fits" > cstsmapmerge.log -$ECHO -n "." -if [ -s "merged_tsmap2.fits" ] -then - $ECHO -n "." -else - $ECHO " merged_tsmap2.fits file is not valid" - exit 1 -fi -# === wildcard string === -@PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/cstsmapmerge.py \ - inmaps="data/tsmap_*.fits" \ - outmap="merged_tsmap3.fits" > cstsmapmerge.log -$ECHO -n "." -if [ -s "merged_tsmap3.fits" ] -then - $ECHO -n "." -else - $ECHO " merged_tsmap3.fits file is not valid" - exit 1 -fi -# === ascii-file === -#ls data/tsmap_*.fits > tsmaps.txt -@PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/cstsmapmerge.py \ - inmaps="@data/tsmaps.txt" \ - outmap="merged_tsmap4.fits" > cstsmapmerge.log -$ECHO -n "." -if [ -s "merged_tsmap4.fits" ] -then - $ECHO -n "." -else - $ECHO " merged_tsmap4.fits file is not valid" - exit 1 -fi -$ECHO " ok" -rm tsmaps.txt - - -# -# Test cspull -# =========== -$ECHO -n "Test cspull: " -chmod +x @abs_top_srcdir@/cscripts/cspull.py -@PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/cspull.py \ - inmodel="data/crab.xml" \ - outfile="pull.dat" \ - ntrials="3" \ - caldb="cta" \ - irf="Standard" \ - ra=83.6331 \ - dec=22.0145 \ - emin=0.1 \ - emax=100.0 \ - enumbins=0 \ - tmax=1800.0 \ - deadc=0.95 \ - rad=5.0 \ - npix=200 \ - debug=yes \ - binsz=0.05 > cspull.log -$ECHO -n "." -if [ -s "pull.dat" ] -then - $ECHO -n "." -else - $ECHO " pull.dat file is not valid" - exit 1 -fi -$ECHO " ok" - - -# -# Test cssens -# =========== -$ECHO -n "Test cssens: " -chmod +x @abs_top_srcdir@/cscripts/cssens.py -@PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/cssens.py \ - inmodel="data/crab.xml" \ - srcname="Crab" \ - caldb="irf" \ - irf="cta_dummy_irf" \ - duration=1800.0 \ - rad=3.0 \ - emin=1.0 \ - emax=10.0 \ - bins=1 > cssens.log -$ECHO -n "." -if [ -s "sensitivity.dat" ] -then - $ECHO -n "." -else - $ECHO " sensitivity.dat file is not valid" - exit 1 -fi -$ECHO " ok" - - -# -# Test cstsdist -# ============= -$ECHO -n "Test cstsdist: " -chmod +x @abs_top_srcdir@/cscripts/cstsdist.py -@PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/cstsdist.py \ - inmodel="data/crab.xml" \ - srcname="Crab" \ - outfile="ts.dat" \ - ntrials="1" \ - caldb="irf" \ - irf="cta_dummy_irf" \ - ra=83.63 \ - dec=22.01 \ - emin=0.1 \ - emax=100.0 \ - enumbins=0 \ - tmax=1800.0 \ - rad=5.0 \ - npix=200 \ - binsz=0.05 > cstsdist.log -$ECHO -n "." -if [ -s "ts.dat" ] -then - $ECHO -n "." -else - $ECHO " ts.dat file is not valid" - exit 1 -fi -$ECHO " ok" - - -# -# Test csresmap -# ============= -$ECHO -n "Test csresmap: " -chmod +x @abs_top_srcdir@/cscripts/csresmap.py -@PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/csresmap.py \ - inobs="data/crab_events.fits" \ - outmap="resmap.fits" \ - inmodel="data/crab.xml" \ - caldb="irf" \ - irf="cta_dummy_irf" \ - nxpix=50 \ - nypix=50 \ - binsz=0.02 \ - coordsys="CEL" \ - xref=83.63 \ - yref=22.01 \ - proj="CAR" \ - binsz=0.05 \ - algorithm="SUBDIV" > csresmap.log -$ECHO -n "." -if [ -s "resmap.fits" ] -then - $ECHO -n "." -else - $ECHO " resmap.fits file is not valid" - exit 1 -fi -$ECHO " ok" - - -# -# Test csspec -# =========== -$ECHO -n "Test csspec: " -# === Unbinned === -chmod +x @abs_top_srcdir@/cscripts/csspec.py -@PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/csspec.py \ - inobs="data/crab_events.fits" \ - inmodel="data/crab.xml" \ - caldb="irf" \ - irf="cta_dummy_irf" \ - ebinalg="LOG" \ - enumbins=5 \ - srcname="Crab" \ - emin=0.1 \ - emax=100.0 \ - outfile="spectrum.fits" > csspec.log -$ECHO -n "." -if [ -s "spectrum.fits" ] -then - $ECHO -n "." -else - $ECHO " spectrum.fits file is not valid" - exit 1 -fi -# === Binned === -@PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/csspec.py \ - inobs="data/crab_cntmap_small.fits.gz" \ - expcube="data/crab_expcube.fits.gz" \ - psfcube="data/crab_psfcube.fits.gz" \ - edispcube="data/crab_edispcube.fits.gz" \ - bkgcube="data/crab_bkgcube.fits.gz" \ - inmodel="data/crab_bkgcube.xml" \ - ebinalg="LOG" \ - enumbins=2 \ - emin=0.1 \ - emax=100.0 \ - srcname="Crab" \ - outfile="spectrum_binned.fits" > csspec.log -$ECHO -n "." -if [ -s "spectrum_binned.fits" ] -then - $ECHO -n "." -else - $ECHO " spectrum_binned.fits file is not valid" - exit 1 -fi -$ECHO " ok" - - -# -# Test cslightcrv -# =============== -$ECHO -n "Test cslightcrv: " -# === unbinned === -chmod +x @abs_top_srcdir@/cscripts/cslightcrv.py -@PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/cslightcrv.py \ - inobs="data/crab_events.fits" \ - inmodel="data/crab.xml" \ - srcname="Crab" \ - caldb="irf" \ - irf="cta_dummy_irf" \ - tbinalg="LIN" \ - tmin=51544.5 \ - tmax=51544.53 \ - tbins=3 \ - enumbins=0 \ - emin=0.1 \ - emax=100.0 \ - outfile="lightcurve.fits" > cslightcrv.log -$ECHO -n "." -if [ -s "lightcurve.fits" ] -then - $ECHO -n "." -else - $ECHO " lightcurve.fits file is not valid" - exit 1 -fi -# === binned === -@PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/cslightcrv.py \ - inobs="data/crab_events.fits" \ - inmodel="data/crab.xml" \ - srcname="Crab" \ - caldb="irf" \ - irf="cta_dummy_irf" \ - tbinalg="GTI" \ - enumbins=2 \ - emin=0.1 \ - emax=100.0 \ - coordsys="CEL" \ - proj="CAR" \ - xref=83.63 \ - yref=22.01 \ - nxpix=10 \ - nypix=10 \ - binsz=0.1 \ - outfile="lightcurve_binned.fits" > cslightcrv.log -$ECHO -n "." -if [ -s "lightcurve_binned.fits" ] -then - $ECHO -n "." -else - $ECHO " lightcurve_binned.fits file is not valid" - exit 1 -fi -$ECHO " ok" - - -# -# Optional tests for Python 2.6++ (scripts needing json module) -# ============================================================= -python_version=`echo @PYTHON_VERSION@ | sed 's/\(10\.[[0-9]]*\).*/\1/' | sed -e 's/\.//g'` -if [ $python_version -ge 26 ]; then - - # - # Test csfindobs - # ============== - $ECHO -n "Test csfindobs: " - chmod +x @abs_top_srcdir@/cscripts/csfindobs.py - @PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/csfindobs.py \ - datapath="iactdata/" \ - prodname="unit-test" \ - ra="83.6331" \ - dec="22.01" \ - rad="1.0" \ - outfile="iactrunlist.dat" > csfindobs.log - $ECHO -n "." - if [ -s "iactrunlist.dat" ] - then - $ECHO -n "." - else - $ECHO " iactdata/runlist.txt file is not valid" - exit 1 - fi - $ECHO " ok" - - - # - # Test csiactcopy - # =============== - $ECHO -n "Test csiactcopy: " - chmod +x @abs_top_srcdir@/cscripts/csiactcopy.py - @PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/csiactcopy.py \ - remote_master="iactdata/master.json" \ - outpath="iactdata_test" \ - prodname="unit-test" > csiactcopy.log - $ECHO -n "." - if [ -s "iactdata_test/master.json" ] - then - $ECHO -n "." - else - $ECHO " iactdata_test/master.json file is not valid" - exit 1 - fi - $ECHO " ok" - - - # - # Test csiactobs - # ============== - $ECHO -n "Test csiactobs: " - chmod +x @abs_top_srcdir@/cscripts/csiactobs.py - @PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/csiactobs.py \ - datapath="iactdata/" \ - prodname="unit-test" \ - infile="iactrunlist.dat" \ - bkgpars="1" \ - outobs="obs2.xml" \ - outmodel="bkgmodels.xml" > csiactobs.log - $ECHO -n "." - if [ -s "obs2.xml" ] - then - $ECHO -n "." - else - $ECHO " obs.xml file is not valid" - exit 1 - fi - $ECHO " ok" - -fi # Python 2.6+ specific tests diff --git a/test/test_csfindobs.py b/test/test_csfindobs.py index 32c9384..723818b 100755 --- a/test/test_csfindobs.py +++ b/test/test_csfindobs.py @@ -42,6 +42,9 @@ class Test(test): # Call base class constructor test.__init__(self) + # Set data members + self._datapath = self._datadir + '/iactdata' + # Return return @@ -69,7 +72,7 @@ class Test(test): csfindobs = self._script('csfindobs') # Setup csfindobs command - cmd = csfindobs+' datapath="iactdata/"'+ \ + cmd = csfindobs+' datapath="'+self._datapath+'"'+ \ ' prodname="unit-test"'+ \ ' ra=83.63 dec=22.01 rad=1.0'+ \ ' outfile="runlist_cmd1.dat"'+ \ @@ -107,7 +110,7 @@ class Test(test): """ # Set-up csfindobs findobs = cscripts.csfindobs() - findobs['datapath'] = 'iactdata/' + findobs['datapath'] = self._datapath findobs['prodname'] = 'unit-test' findobs['outfile'] = 'runlist_py1.dat' findobs['ra'] = 83.63 diff --git a/test/test_csiactcopy.py b/test/test_csiactcopy.py index ed03ef6..5464cdc 100755 --- a/test/test_csiactcopy.py +++ b/test/test_csiactcopy.py @@ -42,6 +42,9 @@ class Test(test): # Call base class constructor test.__init__(self) + # Set data members + self._remote = self._datadir + '/iactdata/master.json' + # Return return @@ -69,7 +72,7 @@ class Test(test): csiactcopy = self._script('csiactcopy') # Setup csiactcopy command - cmd = csiactcopy+' remote_master="iactdata/master.json"'+ \ + cmd = csiactcopy+' remote_master="'+self._remote+'"'+ \ ' prodname="unit-test"'+ \ ' outpath="iactdata_cmd1"'+ \ ' logfile="csiactcopy_cmd1.log" chatter=1' @@ -105,7 +108,7 @@ class Test(test): """ # Set-up csiactcopy findobs = cscripts.csiactcopy() - findobs['remote_master'] = 'iactdata/master.json' + findobs['remote_master'] = self._remote findobs['prodname'] = 'unit-test' findobs['outpath'] = 'iactdata_py1' findobs['logfile'] = 'csiactcopy_py1.log' @@ -134,17 +137,17 @@ class Test(test): # Check for existence of files self.test_assert(hdu_index_name.exists(), - 'Check is file "hdu-index.fits" exists.') + 'Check if file "hdu-index.fits" exists.') self.test_assert(obs_index_name.exists(), - 'Check is file "obs-index.fits" exists.') + 'Check if file "obs-index.fits" exists.') self.test_assert(master_name.exists(), - 'Check is file "master.json" exists.') + 'Check if file "master.json" exists.') # Check if index files are FITS file self.test_assert(hdu_index_name.is_fits(), - 'Check is file "hdu-index.fits" is FITS file.') + 'Check if file "hdu-index.fits" is FITS file.') self.test_assert(obs_index_name.is_fits(), - 'Check is file "obs-index.fits" is FITS file.') + 'Check if file "obs-index.fits" is FITS file.') # Return return diff --git a/test/test_csiactdata.py b/test/test_csiactdata.py index f07bc41..47f1db6 100755 --- a/test/test_csiactdata.py +++ b/test/test_csiactdata.py @@ -42,6 +42,9 @@ class Test(test): # Call base class constructor test.__init__(self) + # Set data members + self._datapath = self._datadir + '/iactdata' + # Return return @@ -69,7 +72,7 @@ class Test(test): csiactdata = self._script('csiactdata') # Setup csiactdata command - cmd = csiactdata+' datapath="iactdata"'+ \ + cmd = csiactdata+' datapath="'+self._datapath+'"'+ \ ' logfile="csiactdata_cmd1.log" chatter=1' # Check if execution of wrong command fails @@ -98,7 +101,7 @@ class Test(test): """ # Set-up csiactdata iactdata = cscripts.csiactdata() - iactdata['datapath'] = 'iactdata' + iactdata['datapath'] = self._datapath iactdata['logfile'] = 'csiactdata_py1.log' iactdata['chatter'] = 2 diff --git a/test/test_csiactobs.py b/test/test_csiactobs.py index 0873db0..0c961f9 100755 --- a/test/test_csiactobs.py +++ b/test/test_csiactobs.py @@ -42,6 +42,9 @@ class Test(test): # Call base class constructor test.__init__(self) + # Set data members + self._datapath = self._datadir + '/iactdata' + # Return return @@ -69,7 +72,7 @@ class Test(test): csiactobs = self._script('csiactobs') # Setup csiactobs command - cmd = csiactobs+' datapath="iactdata"'+ \ + cmd = csiactobs+' datapath="'+self._datapath+'"'+ \ ' prodname="unit-test"'+ \ ' infile="runlist_cmd1.dat"'+ \ ' bkgpars=1'+\ @@ -114,7 +117,7 @@ class Test(test): """ # Set-up csiactobs iactobs = cscripts.csiactobs() - iactobs['datapath'] = 'iactdata' + iactobs['datapath'] = self._datapath iactobs['prodname'] = 'unit-test' iactobs['infile'] = 'runlist_py1.dat' iactobs['bkgpars'] = 1 @@ -151,7 +154,7 @@ class Test(test): # Check number of observations self.test_value(obs.size(), 1, 'Check for single observation in XML file') - self.test_assert(obs[0].eventfile().file() == 'crab_events.fits.gz', + self.test_assert(obs[0].eventfile().file() == 'events.fits.gz', 'Check event file name') self.test_assert(obs[0].eventfile().extname() == 'EVENTS', 'Check event extension name') diff --git a/test/test_cslightcrv.py b/test/test_cslightcrv.py index a085b85..2b160d7 100755 --- a/test/test_cslightcrv.py +++ b/test/test_cslightcrv.py @@ -42,10 +42,6 @@ class Test(test): # Call base class constructor test.__init__(self) - # Set members - self._events_name = 'data/crab_events.fits' - self._model_name = 'data/crab.xml' - # Return return @@ -73,9 +69,9 @@ class Test(test): cslightcrv = self._script('cslightcrv') # Setup cslightcrv command - cmd = cslightcrv+' inobs="'+self._events_name+'"'+ \ - ' inmodel="'+self._model_name+'"'+ \ - ' srcname="Crab" caldb="prod2" irf="South_0.5h"'+ \ + cmd = cslightcrv+' inobs="'+self._events+'"'+ \ + ' inmodel="'+self._model+'" srcname="Crab"'+ \ + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \ ' tbinalg="LIN" tmin=51544.50 tmax=51544.53'+ \ ' tbins=3 enumbins=0 emin=0.1 emax=100.0'+ \ ' outfile="lightcurve_cmd1.fits"'+ \ @@ -94,8 +90,8 @@ class Test(test): # Setup cslightcrv command cmd = cslightcrv+' inobs="events_that_do_not_exist.fits"'+ \ - ' inmodel="'+self._model_name+'"'+ \ - ' srcname="Crab" caldb="prod2" irf="South_0.5h"'+ \ + ' inmodel="'+self._model+'" srcname="Crab"'+ \ + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \ ' tbinalg="LIN" tmin=51544.50 tmax=51544.53'+ \ ' tbins=3 enumbins=0 emin=0.1 emax=100.0'+ \ ' outfile="lightcurve_cmd1.fits"'+ \ @@ -115,11 +111,11 @@ class Test(test): """ # Set-up unbinned cslightcrv lcrv = cscripts.cslightcrv() - lcrv['inobs'] = self._events_name - lcrv['inmodel'] = self._model_name + lcrv['inobs'] = self._events + lcrv['inmodel'] = self._model lcrv['srcname'] = 'Crab' - lcrv['caldb'] = 'prod2' - lcrv['irf'] = 'South_0.5h' + lcrv['caldb'] = self._caldb + lcrv['irf'] = self._irf lcrv['tbinalg'] = 'LIN' lcrv['tmin'] = 51544.50 lcrv['tmax'] = 51544.53 @@ -152,11 +148,11 @@ class Test(test): # Set-up unbinned cslightcrv lcrv = cscripts.cslightcrv() - lcrv['inobs'] = self._events_name - lcrv['inmodel'] = self._model_name + lcrv['inobs'] = self._events + lcrv['inmodel'] = self._model lcrv['srcname'] = 'Crab' - lcrv['caldb'] = 'prod2' - lcrv['irf'] = 'South_0.5h' + lcrv['caldb'] = self._caldb + lcrv['irf'] = self._irf lcrv['tbinalg'] = 'FILE' lcrv['tbinfile'] = 'cslightcrv_py2.dat' lcrv['enumbins'] = 0 @@ -176,17 +172,17 @@ class Test(test): # Now we setup an observation container on input. We attached the # model to the observation container so that cslightcrv should # no longer query for the parameter. - cta = gammalib.GCTAObservation(self._events_name) + cta = gammalib.GCTAObservation(self._events) obs = gammalib.GObservations() obs.append(cta) - obs.models(self._model_name) + obs.models(self._model) # Set-up unbinned cslightcrv from observation container. Now use # the GTI algorithm so that we test all timing algorithms. lcrv = cscripts.cslightcrv(obs) lcrv['srcname'] = 'Crab' - lcrv['caldb'] = 'prod2' - lcrv['irf'] = 'South_0.5h' + lcrv['caldb'] = self._caldb + lcrv['irf'] = self._irf lcrv['tbinalg'] = 'GTI' lcrv['enumbins'] = 0 lcrv['emin'] = 0.1 @@ -203,11 +199,11 @@ class Test(test): # Finally we set-up a binned cslightcrv lcrv = cscripts.cslightcrv() - lcrv['inobs'] = self._events_name - lcrv['inmodel'] = self._model_name + lcrv['inobs'] = self._events + lcrv['inmodel'] = self._model lcrv['srcname'] = 'Crab' - lcrv['caldb'] = 'prod2' - lcrv['irf'] = 'South_0.5h' + lcrv['caldb'] = self._caldb + lcrv['irf'] = self._irf lcrv['tbinalg'] = 'LIN' lcrv['tmin'] = 51544.50 lcrv['tmax'] = 51544.53 diff --git a/test/test_csmodelinfo.py b/test/test_csmodelinfo.py index b6030c0..d26ec73 100755 --- a/test/test_csmodelinfo.py +++ b/test/test_csmodelinfo.py @@ -37,14 +37,11 @@ class Test(test): # Constructor def __init__(self): """ - Constructor. + Constructor """ # Call base class constructor test.__init__(self) - # Set members - self._model_name = "data/crab.xml" - # Return return @@ -72,7 +69,7 @@ class Test(test): csmodelinfo = self._script('csmodelinfo') # Setup csmodelinfo command - cmd = csmodelinfo+' inmodel="'+self._model_name+'"'+ \ + cmd = csmodelinfo+' inmodel="'+self._model+'"'+ \ ' ds9file="model_cmd1.reg"'+ \ ' logfile="csmodelinfo_cmd1.log" chatter=1' @@ -106,7 +103,7 @@ class Test(test): """ # Set-up csmodelinfo modelinfo = cscripts.csmodelinfo() - modelinfo['inmodel'] = self._model_name + modelinfo['inmodel'] = self._model modelinfo['ds9file'] = 'csmodelinfo_py1.reg' modelinfo['logfile'] = 'csmodelinfo_py1.log' modelinfo['chatter'] = 2 @@ -121,7 +118,7 @@ class Test(test): # Set-up csmodelinfo modelinfo = cscripts.csmodelinfo() - modelinfo['inmodel'] = self._model_name + modelinfo['inmodel'] = self._model modelinfo['ds9file'] = 'csmodelinfo_py2.reg' modelinfo['logfile'] = 'csmodelinfo_py2.log' modelinfo['chatter'] = 3 diff --git a/test/test_csmodelmerge.py b/test/test_csmodelmerge.py index 53f63a3..4def7bb 100755 --- a/test/test_csmodelmerge.py +++ b/test/test_csmodelmerge.py @@ -42,6 +42,12 @@ class Test(test): # Call base class constructor test.__init__(self) + # Set members + self._model1 = self._datadir + '/crab.xml' + self._model2 = self._datadir + '/model_cube_background.xml' + self._model3 = self._datadir + '/model_cube_background*.xml' + self._model4 = '@' + self._datadir + '/models.txt' + # Return return @@ -69,8 +75,8 @@ class Test(test): csmodelmerge = self._script('csmodelmerge') # Setup csmodelmerge command - cmd = csmodelmerge+' inmodels="data/crab.xml data/model_cube_background.xml"'+ \ - ' outmodel="mergedmodel_cmd1.xml"'+ \ + cmd = csmodelmerge+' inmodels="'+self._model1+' '+self._model2+'"'+ \ + ' outmodel="csmodelmerge_cmd1.xml"'+ \ ' logfile="csmodelmerge_cmd1.log" chatter=1' # Check if execution of wrong command fails @@ -82,11 +88,11 @@ class Test(test): 'Check successful execution from command line') # Check model file - self._check_model_file('mergedmodel_cmd1.xml', 3) + self._check_model_file('csmodelmerge_cmd1.xml', 3) # Setup csmodelmerge command cmd = csmodelmerge+' inmodels="model_that_does_not_exist.xml"'+ \ - ' outmodel="mergedmodel_cmd2.xml"'+ \ + ' outmodel="csmodelmerge_cmd2.xml"'+ \ ' logfile="csmodelmerge_cmd2.log"' # Check if execution failed @@ -103,8 +109,8 @@ class Test(test): """ # Set-up csmodelmerge for space-separated input modelmerge = cscripts.csmodelmerge() - modelmerge['inmodels'] = 'data/crab.xml data/model_cube_background.xml' - modelmerge['outmodel'] = 'mergedmodel_py1.xml' + modelmerge['inmodels'] = self._model1+' '+self._model2 + modelmerge['outmodel'] = 'csmodelmerge_py1.xml' modelmerge['logfile'] = 'csmodelmerge_py1.log' modelmerge['chatter'] = 2 @@ -114,12 +120,12 @@ class Test(test): modelmerge.save() # Check model file - self._check_model_file('mergedmodel_py1.xml', 3) + self._check_model_file('csmodelmerge_py1.xml', 3) # Set-up csmodelmerge for semi-colon separated input modelmerge = cscripts.csmodelmerge() - modelmerge['inmodels'] = 'data/crab.xml;data/model_cube_background.xml' - modelmerge['outmodel'] = 'mergedmodel_py2.xml' + modelmerge['inmodels'] = self._model1+';'+self._model2 + modelmerge['outmodel'] = 'csmodelmerge_py2.xml' modelmerge['logfile'] = 'csmodelmerge_py2.log' modelmerge['chatter'] = 3 @@ -127,12 +133,12 @@ class Test(test): modelmerge.execute() # Check model file - self._check_model_file('mergedmodel_py2.xml', 3) + self._check_model_file('csmodelmerge_py2.xml', 3) # Set-up csmodelmerge for wildcard input modelmerge = cscripts.csmodelmerge() - modelmerge['inmodels'] = 'data/model_cube_background*.xml' - modelmerge['outmodel'] = 'mergedmodel_py3.xml' + modelmerge['inmodels'] = self._model3 + modelmerge['outmodel'] = 'csmodelmerge_py3.xml' modelmerge['logfile'] = 'csmodelmerge_py3.log' modelmerge['chatter'] = 4 @@ -140,12 +146,12 @@ class Test(test): modelmerge.execute() # Check model file - self._check_model_file('mergedmodel_py3.xml', 2) + self._check_model_file('csmodelmerge_py3.xml', 2) # Set-up csmodelmerge for ASCII file modelmerge = cscripts.csmodelmerge() - modelmerge['inmodels'] = '@data/models.txt' - modelmerge['outmodel'] = 'mergedmodel_py4.xml' + modelmerge['inmodels'] = self._model4 + modelmerge['outmodel'] = 'csmodelmerge_py4.xml' modelmerge['logfile'] = 'csmodelmerge_py4.log' modelmerge['chatter'] = 4 @@ -153,7 +159,7 @@ class Test(test): modelmerge.execute() # Check model file - self._check_model_file('mergedmodel_py4.xml', 2) + self._check_model_file('csmodelmerge_py4.xml', 2) # Return return diff --git a/test/test_csobs2caldb.py b/test/test_csobs2caldb.py index b8a69b7..9904a96 100755 --- a/test/test_csobs2caldb.py +++ b/test/test_csobs2caldb.py @@ -44,7 +44,7 @@ class Test(test): test.__init__(self) # Set members - self._inobs = 'data/obs_unbinned.xml' + self._inobs = self._datadir + '/obs_unbinned.xml' # Clean calibration database os.system('rm -rf caldb >/dev/null 2>&1') diff --git a/test/test_csobsdef.py b/test/test_csobsdef.py index 5c14c54..6f8866b 100755 --- a/test/test_csobsdef.py +++ b/test/test_csobsdef.py @@ -42,6 +42,9 @@ class Test(test): # Call base class constructor test.__init__(self) + # Set members + self._pntdef = self._datadir + '/pntdef.dat' + # Return return @@ -69,9 +72,9 @@ class Test(test): csobsdef = self._script('csobsdef') # Setup csobsdef command - cmd = csobsdef+' inpnt="data/pntdef.dat"'+ \ + cmd = csobsdef+' inpnt="'+self._pntdef+'"'+ \ ' outobs="csobsdef_cmd1.xml"'+ \ - ' caldb="prod2" irf="South_0.5h"'+ \ + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \ ' emin=0.1 emax=100.0 duration=1800.0 rad=5.0'+ \ ' logfile="csobsdef_cmd1.log" chatter=1' @@ -89,7 +92,7 @@ class Test(test): # Setup csobsdef command cmd = csobsdef+' inpnt="obs_definition_that_does_not_exist.dat"'+ \ ' outobs="csobsdef_cmd1.xml"'+ \ - ' caldb="prod2" irf="South_0.5h"'+ \ + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \ ' emin=0.1 emax=100.0 duration=1800.0 rad=5.0'+ \ ' logfile="csobsdef_cmd2.log"' @@ -107,10 +110,10 @@ class Test(test): """ # Set-up csobsdef obsdef = cscripts.csobsdef() - obsdef['inpnt'] = 'data/pntdef.dat' + obsdef['inpnt'] = self._pntdef obsdef['outobs'] = 'csobsdef_py1.xml' - obsdef['caldb'] = 'prod2' - obsdef['irf'] = 'South_0.5h' + obsdef['caldb'] = self._caldb + obsdef['irf'] = self._irf obsdef['emin'] = 0.1 obsdef['emax'] = 100.0 obsdef['duration'] = 1800.0 @@ -128,10 +131,10 @@ class Test(test): # Set-up csobsdef obsdef = cscripts.csobsdef() - obsdef['inpnt'] = 'data/pntdef.dat' + obsdef['inpnt'] = self._pntdef obsdef['outobs'] = 'csobsdef_py2.xml' - obsdef['caldb'] = 'prod2' - obsdef['irf'] = 'South_0.5h' + obsdef['caldb'] = self._caldb + obsdef['irf'] = self._irf obsdef['emin'] = 0.1 obsdef['emax'] = 100.0 obsdef['duration'] = 1800.0 @@ -146,14 +149,14 @@ class Test(test): self._check_obsdef_file('csobsdef_py2.xml') # Load CSV table - csv = gammalib.GCsv('data/pntdef.dat', ',') + csv = gammalib.GCsv(self._pntdef, ',') # Set-up csobsdef obsdef = cscripts.csobsdef() obsdef.pntdef(csv) obsdef['outobs'] = 'csobsdef_py3.xml' - obsdef['caldb'] = 'prod2' - obsdef['irf'] = 'South_0.5h' + obsdef['caldb'] = self._caldb + obsdef['irf'] = self._irf obsdef['emin'] = 0.1 obsdef['emax'] = 100.0 obsdef['duration'] = 1800.0 diff --git a/test/test_csobsinfo.py b/test/test_csobsinfo.py index 6017844..1012e65 100755 --- a/test/test_csobsinfo.py +++ b/test/test_csobsinfo.py @@ -42,6 +42,9 @@ class Test(test): # Call base class constructor test.__init__(self) + # Set members + self._inobs = self._datadir + '/obs_unbinned.xml' + # Return return @@ -69,7 +72,7 @@ class Test(test): csobsinfo = self._script('csobsinfo') # Setup csobsinfo command - cmd = csobsinfo+' inobs="data/obs_unbinned.xml"'+ \ + cmd = csobsinfo+' inobs="'+self._inobs+'"'+ \ ' ds9file="csobsinfo_cmd1.reg"'+ \ ' offset=yes ra=83.63 dec=22.01'+ \ ' logfile="csobsinfo_cmd1.log" chatter=1' @@ -105,7 +108,7 @@ class Test(test): """ # Set-up csobsinfo obsinfo = cscripts.csobsinfo() - obsinfo['inobs'] = 'data/obs_unbinned.xml' + obsinfo['inobs'] = self._inobs obsinfo['ds9file'] = 'csobsinfo_py1.reg' obsinfo['offset'] = True obsinfo['ra'] = 83.63 @@ -123,7 +126,7 @@ class Test(test): # Set-up csobsinfo obsinfo = cscripts.csobsinfo() - obsinfo['inobs'] = 'data/obs_unbinned.xml' + obsinfo['inobs'] = self._inobs obsinfo['ds9file'] = 'csobsinfo_py2.reg' obsinfo['offset'] = True obsinfo['ra'] = 83.63 diff --git a/test/test_cspull.py b/test/test_cspull.py index b202ec6..ea281dc 100755 --- a/test/test_cspull.py +++ b/test/test_cspull.py @@ -42,6 +42,10 @@ class Test(test): # Call base class constructor test.__init__(self) + # Set members + self._inobs = self._datadir + '/obs_stacked.xml' + self._stacked_model = self._datadir + '/crab_bkgcube.xml' + # Return return @@ -69,9 +73,10 @@ class Test(test): cspull = self._script('cspull') # Setup cspull command - cmd = cspull+' inmodel="data/crab.xml"'+ \ + cmd = cspull+' inmodel="'+self._model+'"'+ \ ' outfile="cspull_cmd1.dat"'+ \ - ' ntrials=3 caldb="prod2" irf="South_0.5h"'+ \ + ' ntrials=3'+ \ + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \ ' ra=83.6331 dec=22.0145 emin=0.1 emax=100.0'+ \ ' enumbins=0 tmax=1800.0 deadc=0.95 rad=5.0'+ \ ' npix=200 binsz=0.05'+ \ @@ -91,7 +96,8 @@ class Test(test): # Setup cspull command cmd = cspull+' inmodel="model_that_does_not_exist.xml"'+ \ ' outfile="cspull_cmd1.dat"'+ \ - ' ntrials=3 caldb="prod2" irf="South_0.5h"'+ \ + ' ntrials=3'+ \ + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \ ' ra=83.6331 dec=22.0145 emin=0.1 emax=100.0'+ \ ' enumbins=0 tmax=1800.0 deadc=0.95 rad=5.0'+ \ ' npix=200 binsz=0.05'+ \ @@ -111,11 +117,11 @@ class Test(test): """ # Set-up unbinned cspull pull = cscripts.cspull() - pull['inmodel'] = 'data/crab.xml' + pull['inmodel'] = self._model pull['outfile'] = 'cspull_py1.dat' pull['ntrials'] = 3 - pull['caldb'] = 'prod2' - pull['irf'] = 'South_0.5h' + pull['caldb'] = self._caldb + pull['irf'] = self._irf pull['ra'] = 83.6331 pull['dec'] = 22.0145 pull['emin'] = 0.1 @@ -137,11 +143,11 @@ class Test(test): # Set-up binned cspull pull = cscripts.cspull() - pull['inmodel'] = 'data/crab.xml' + pull['inmodel'] = self._model pull['outfile'] = 'cspull_py2.dat' pull['ntrials'] = 3 - pull['caldb'] = 'prod2' - pull['irf'] = 'South_0.5h' + pull['caldb'] = self._caldb + pull['irf'] = self._irf pull['ra'] = 83.6331 pull['dec'] = 22.0145 pull['emin'] = 0.1 @@ -165,12 +171,12 @@ class Test(test): # Set-up cspull from event list pull = cscripts.cspull() - pull['inobs'] = 'data/crab_events.fits' - pull['inmodel'] = 'data/crab.xml' + pull['inobs'] = self._events + pull['inmodel'] = self._model pull['outfile'] = 'cspull_py3.dat' pull['ntrials'] = 3 - pull['caldb'] = 'prod2' - pull['irf'] = 'South_0.5h' + pull['caldb'] = self._caldb + pull['irf'] = self._irf pull['enumbins'] = 0 pull['logfile'] = 'cspull_py3.log' pull['chatter'] = 4 @@ -182,17 +188,17 @@ class Test(test): self._check_pull_file('cspull_py3.dat') # Build observation container with unbinned observation - cta = gammalib.GCTAObservation('data/crab_events.fits') + cta = gammalib.GCTAObservation(self._events) obs = gammalib.GObservations() obs.append(cta) # Set-up cspull from observation container with unbinned observation pull = cscripts.cspull(obs) - pull['inmodel'] = 'data/crab.xml' + pull['inmodel'] = self._model pull['outfile'] = 'cspull_py4.dat' pull['ntrials'] = 3 - pull['caldb'] = 'prod2' - pull['irf'] = 'South_0.5h' + pull['caldb'] = self._caldb + pull['irf'] = self._irf pull['enumbins'] = 0 pull['logfile'] = 'cspull_py4.log' pull['chatter'] = 4 @@ -205,12 +211,12 @@ class Test(test): # Set-up stacked cspull pull = cscripts.cspull() - pull['inobs'] = 'data/obs_stacked.xml' - pull['inmodel'] = 'data/crab_bkgcube.xml' + pull['inobs'] = self._inobs + pull['inmodel'] = self._stacked_model pull['outfile'] = 'cspull_py5.dat' pull['ntrials'] = 3 - pull['caldb'] = 'prod2' - pull['irf'] = 'South_0.5h' + pull['caldb'] = self._caldb + pull['irf'] = self._irf pull['enumbins'] = 0 pull['logfile'] = 'cspull_py5.log' pull['chatter'] = 4 diff --git a/test/test_csresmap.py b/test/test_csresmap.py index 18975da..1944d38 100755 --- a/test/test_csresmap.py +++ b/test/test_csresmap.py @@ -69,10 +69,10 @@ class Test(test): csresmap = self._script('csresmap') # Setup csresmap command - cmd = csresmap+' inobs="data/crab_events.fits"'+ \ + cmd = csresmap+' inobs="'+self._events+'"'+ \ ' outmap="csresmap_cmd1.fits"'+ \ - ' inmodel="data/crab.xml"'+ \ - ' caldb="prod2" irf="South_0.5h"' + \ + ' inmodel="'+self._model+'"'+ \ + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \ ' emin=0.1 emax=100.0 enumbins=20'+ \ ' nxpix=50 nypix=50 binsz=0.02'+ \ ' coordsys="CEL" proj="CAR" xref=83.63 yref=22.01'+ \ @@ -93,8 +93,8 @@ class Test(test): # Setup csresmap command cmd = csresmap+' inobs="event_file_that_does_not_exist.fits"'+ \ ' outmap="csresmap_cmd1.fits"'+ \ - ' inmodel="data/crab.xml"'+ \ - ' caldb="prod2" irf="South_0.5h"' + \ + ' inmodel="'+self._model+'"'+ \ + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \ ' emin=0.1 emax=100.0 enumbins=20'+ \ ' nxpix=50 nypix=50 binsz=0.02'+ \ ' coordsys="CEL" proj="CAR" xref=83.63 yref=22.01'+ \ @@ -115,11 +115,11 @@ class Test(test): """ # Set-up csresmap for event list resmap = cscripts.csresmap() - resmap['inobs'] = 'data/crab_events.fits' + resmap['inobs'] = self._events resmap['outmap'] = 'csresmap_py1.fits' - resmap['inmodel'] = 'data/crab.xml' - resmap['caldb'] = 'prod2' - resmap['irf'] = 'South_0.5h' + resmap['inmodel'] = self._model + resmap['caldb'] = self._caldb + resmap['irf'] = self._irf resmap['emin'] = 0.1 resmap['emax'] = 100.0 resmap['enumbins'] = 20 @@ -144,15 +144,15 @@ class Test(test): # Set-up csresmap for counts cube resmap = cscripts.csresmap() - resmap['inobs'] = 'data/crab_cntmap.fits' + resmap['inobs'] = self._cntcube resmap['modcube'] = 'NONE' resmap['expcube'] = 'NONE' resmap['psfcube'] = 'NONE' resmap['edispcube'] = 'NONE' resmap['bkgcube'] = 'NONE' - resmap['caldb'] = 'prod2' - resmap['irf'] = 'South_0.5h' - resmap['inmodel'] = 'data/crab.xml' + resmap['caldb'] = self._caldb + resmap['irf'] = self._irf + resmap['inmodel'] = self._model resmap['outmap'] = 'csresmap_py2.fits' resmap['algorithm'] = 'SUBDIV' resmap['logfile'] = 'csresmap_py2.log' diff --git a/test/test_csroot2caldb.py b/test/test_csroot2caldb.py index 1f80cfc..d25293e 100644 --- a/test/test_csroot2caldb.py +++ b/test/test_csroot2caldb.py @@ -38,11 +38,14 @@ class Test(test): # Constructor def __init__(self): """ - Constructor. + Constructor """ # Call base class constructor test.__init__(self) + # Set members + self._infile = self._datadir + '/irf.root' + # Clean calibration database os.system('rm -rf csroot2caldb_* >/dev/null 2>&1') @@ -73,7 +76,7 @@ class Test(test): csroot2caldb = self._script('csroot2caldb') # Setup csroot2caldb command - cmd = csroot2caldb+' infile="data/irf.root"'+ \ + cmd = csroot2caldb+' infile="'+self._infile+'"'+ \ ' outdir="csroot2caldb_cmd1"'+ \ ' inst=prod3 id=South_50h version=prod3'+ \ ' analysis=DESY'+ \ @@ -97,7 +100,7 @@ class Test(test): """ # Set-up csroot2caldb caldb = cscripts.csroot2caldb() - caldb['infile'] = 'data/irf.root' + caldb['infile'] = self._infile caldb['outdir'] = 'csroot2caldb_py1' caldb['inst'] = 'prod3' caldb['id'] = 'South_50h' diff --git a/test/test_cssens.py b/test/test_cssens.py index b27fdce..47bbf8a 100755 --- a/test/test_cssens.py +++ b/test/test_cssens.py @@ -69,8 +69,9 @@ class Test(test): cssens = self._script('cssens') # Setup cssens command - cmd = cssens+' inmodel="data/crab.xml"'+ \ - ' srcname="Crab" caldb="prod2" irf="South_0.5h"' + \ + cmd = cssens+' inmodel="'+self._model+'"'+ \ + ' srcname="Crab"'+ \ + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \ ' duration=1800.0 rad=3.0 emin=1.0 emax=10.0 bins=1'+ \ ' outfile="cssens_cmd1.dat"'+ \ ' logfile="cssens_cmd1.log" chatter=1' @@ -88,7 +89,8 @@ class Test(test): # Setup cssens command cmd = cssens+' inmodel="model_that_does_not_exist.xml"'+ \ - ' srcname="Crab" caldb="prod2" irf="South_0.5h"' + \ + ' srcname="Crab"'+ \ + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \ ' duration=1800.0 rad=3.0 emin=1.0 emax=10.0 bins=1'+ \ ' outfile="cssens_cmd2.dat"'+ \ ' logfile="cssens_cmd2.log" chatter=2' @@ -108,10 +110,10 @@ class Test(test): # Set-up cssens sens = cscripts.cssens() sens['inobs'] = 'NONE' - sens['inmodel'] = 'data/crab.xml' + sens['inmodel'] = self._model sens['srcname'] = 'Crab' - sens['caldb'] = 'prod2' - sens['irf'] = 'South_0.5h' + sens['caldb'] = self._caldb + sens['irf'] = self._irf sens['outfile'] = 'cssens_py1.dat' sens['duration'] = 1800.0 sens['rad'] = 3.0 @@ -141,8 +143,10 @@ class Test(test): results = gammalib.GCsv(filename, ',') # Check dimensions - self.test_value(results.nrows(), 2, 'Check for 2 rows in sensitivity file') - self.test_value(results.ncols(), 7, 'Check for 7 columns in sensitivity file') + self.test_value(results.nrows(), 2, + 'Check for 2 rows in sensitivity file') + self.test_value(results.ncols(), 7, + 'Check for 7 columns in sensitivity file') # Return return diff --git a/test/test_csspec.py b/test/test_csspec.py index 26b3d04..4bf7382 100755 --- a/test/test_csspec.py +++ b/test/test_csspec.py @@ -42,6 +42,13 @@ class Test(test): # Call base class constructor test.__init__(self) + # Set members + self._inobs = self._datadir + '/crab_cntmap_small.fits' + self._expcube = self._datadir + '/crab_expcube.fits' + self._psfcube = self._datadir + '/crab_psfcube.fits' + self._edispcube = self._datadir + '/crab_edispcube.fits' + self._bkgcube = self._datadir + '/crab_bkgcube.fits' + # Return return @@ -69,9 +76,10 @@ class Test(test): csspec = self._script('csspec') # Setup csspec command - cmd = csspec+' inobs="data/crab_events.fits"'+ \ - ' inmodel="data/crab.xml"'+ \ - ' srcname="Crab" caldb="prod2" irf="South_0.5h"' + \ + cmd = csspec+' inobs="'+self._events+'"'+ \ + ' inmodel="'+self._model+'"'+ \ + ' srcname="Crab"'+ \ + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \ ' ebinalg="LOG" enumbins=5 emin=0.1 emax=100.0'+ \ ' outfile="csspec_cmd1.fits"'+ \ ' logfile="csspec_cmd1.log" chatter=1' @@ -89,8 +97,9 @@ class Test(test): # Setup csspec command cmd = csspec+' inobs="input_file_that_does_not_exist.fits"'+ \ - ' inmodel="data/crab.xml"'+ \ - ' srcname="Crab" caldb="prod2" irf="South_0.5h"' + \ + ' inmodel="'+self._model+'"'+ \ + ' srcname="Crab"'+ \ + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \ ' ebinalg="LOG" enumbins=5 emin=0.1 emax=100.0'+ \ ' outfile="csspec_cmd2.fits"'+ \ ' logfile="csspec_cmd2.log" chatter=1' @@ -109,11 +118,11 @@ class Test(test): """ # Set-up unbinned csspec spec = cscripts.csspec() - spec['inobs'] = 'data/crab_events.fits' - spec['inmodel'] = 'data/crab.xml' + spec['inobs'] = self._events + spec['inmodel'] = self._model spec['srcname'] = 'Crab' - spec['caldb'] = 'prod2' - spec['irf'] = 'South_0.5h' + spec['caldb'] = self._caldb + spec['irf'] = self._irf spec['outfile'] = 'csspec_py1.fits' spec['ebinalg'] = 'LOG' spec['enumbins'] = 5 @@ -132,12 +141,12 @@ class Test(test): # Set-up binned csspec spec = cscripts.csspec() - spec['inobs'] = 'data/crab_cntmap_small.fits' - spec['expcube'] = 'data/crab_expcube.fits' - spec['psfcube'] = 'data/crab_psfcube.fits' - spec['edispcube'] = 'data/crab_edispcube.fits' - spec['bkgcube'] = 'data/crab_bkgcube.fits' - spec['inmodel'] = 'data/crab.xml' + spec['inobs'] = self._inobs + spec['expcube'] = self._expcube + spec['psfcube'] = self._psfcube + spec['edispcube'] = self._edispcube + spec['bkgcube'] = self._bkgcube + spec['inmodel'] = self._model spec['srcname'] = 'Crab' spec['outfile'] = 'csspec_py2.fits' spec['ebinalg'] = 'LOG' @@ -168,8 +177,10 @@ class Test(test): spectrum = fits['SPECTRUM'] # Check dimensions - self.test_value(spectrum.nrows(), bins, 'Check for %d rows in spectrum' % bins) - self.test_value(spectrum.ncols(), 8, 'Check for 8 columns in spectrum') + self.test_value(spectrum.nrows(), bins, + 'Check for %d rows in spectrum' % bins) + self.test_value(spectrum.ncols(), 8, + 'Check for 8 columns in spectrum') # Return return diff --git a/test/test_cstsdist.py b/test/test_cstsdist.py index 55a476f..a0e9a81 100755 --- a/test/test_cstsdist.py +++ b/test/test_cstsdist.py @@ -69,8 +69,9 @@ class Test(test): cstsdist = self._script('cstsdist') # Setup cstsdist command - cmd = cstsdist+' inmodel="data/crab.xml"'+ \ - ' srcname="Crab" caldb="prod2" irf="South_0.5h"' + \ + cmd = cstsdist+' inmodel="'+self._model+'"'+ \ + ' srcname="Crab"'+ \ + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \ ' ntrials=1 ra=83.63 dec=22.01 emin=0.1 emax=100.0'+ \ ' enumbins=0 tmax=1800.0 rad=5.0 npix=200 npix=200'+ \ ' binsz=0.05'+ \ @@ -90,7 +91,8 @@ class Test(test): # Setup cstsdist command cmd = cstsdist+' inmodel="model_that_does_not_exist.xml"'+ \ - ' srcname="Crab" caldb="prod2" irf="South_0.5h"' + \ + ' srcname="Crab"'+ \ + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \ ' ntrials=1 ra=83.63 dec=22.01 emin=0.1 emax=100.0'+ \ ' enumbins=0 tmax=1800.0 rad=5.0 npix=200 npix=200'+ \ ' binsz=0.05'+ \ @@ -111,10 +113,10 @@ class Test(test): """ # Set-up cstsdist tsdist = cscripts.cstsdist() - tsdist['inmodel'] = 'data/crab.xml' + tsdist['inmodel'] = self._model tsdist['srcname'] = 'Crab' - tsdist['caldb'] = 'prod2' - tsdist['irf'] = 'South_0.5h' + tsdist['caldb'] = self._caldb + tsdist['irf'] = self._irf tsdist['outfile'] = 'cstsdist_py1.dat' tsdist['ntrials'] = 1 tsdist['ra'] = 83.63 diff --git a/test/test_cstsmapmerge.py b/test/test_cstsmapmerge.py index f8b83cb..c5217f3 100755 --- a/test/test_cstsmapmerge.py +++ b/test/test_cstsmapmerge.py @@ -42,6 +42,12 @@ class Test(test): # Call base class constructor test.__init__(self) + # Set members + self._map0 = self._datadir + '/tsmap_0.fits' + self._map1 = self._datadir + '/tsmap_1.fits' + self._mapstar = self._datadir + '/tsmap_*.fits' + self._mapat = '@' + self._datadir + '/tsmaps.txt' + # Return return @@ -69,7 +75,7 @@ class Test(test): cstsmapmerge = self._script('cstsmapmerge') # Setup cstsmapmerge command - cmd = cstsmapmerge+' inmaps="data/tsmap_0.fits;data/tsmap_1.fits"'+ \ + cmd = cstsmapmerge+' inmaps="'+self._map0+';'+self._map1+'"'+ \ ' outmap="cstsmapmerge_cmd1.fits"'+ \ ' logfile="cstsmapmerge_cmd1.log" chatter=1' @@ -103,7 +109,7 @@ class Test(test): """ # Set-up semi-colon separated cstsmapmerge merge = cscripts.cstsmapmerge() - merge['inmaps'] = 'data/tsmap_0.fits;data/tsmap_1.fits' + merge['inmaps'] = self._map0+';'+self._map1 merge['outmap'] = 'cstsmapmerge_py1.fits' merge['logfile'] = 'cstsmapmerge_py1.log' merge['chatter'] = 2 @@ -118,7 +124,7 @@ class Test(test): # Set-up space-separated cstsmapmerge merge = cscripts.cstsmapmerge() - merge['inmaps'] = 'data/tsmap_0.fits data/tsmap_1.fits' + merge['inmaps'] = self._map0+' '+self._map1 merge['outmap'] = 'cstsmapmerge_py2.fits' merge['logfile'] = 'cstsmapmerge_py2.log' merge['chatter'] = 3 @@ -131,7 +137,7 @@ class Test(test): # Set-up wildcard string cstsmapmerge merge = cscripts.cstsmapmerge() - merge['inmaps'] = 'data/tsmap_*.fits' + merge['inmaps'] = self._mapstar merge['outmap'] = 'cstsmapmerge_py3.fits' merge['logfile'] = 'cstsmapmerge_py3.log' merge['chatter'] = 4 @@ -144,7 +150,7 @@ class Test(test): # Set-up ASCII file cstsmapmerge merge = cscripts.cstsmapmerge() - merge['inmaps'] = '@data/tsmaps.txt' + merge['inmaps'] = self._mapat merge['outmap'] = 'cstsmapmerge_py4.fits' merge['logfile'] = 'cstsmapmerge_py4.log' merge['chatter'] = 4 diff --git a/test/test_cstsmapsplit.py b/test/test_cstsmapsplit.py index ae289d5..ee0ffaa 100755 --- a/test/test_cstsmapsplit.py +++ b/test/test_cstsmapsplit.py @@ -69,11 +69,11 @@ class Test(test): cstsmapsplit = self._script('cstsmapsplit') # Setup cstsmapsplit command - cmd = cstsmapsplit+' inobs="data/crab_events.fits"'+ \ - ' inmodel="data/crab.xml"'+ \ + cmd = cstsmapsplit+' inobs="'+self._events+'"'+ \ + ' inmodel="'+self._model+'"'+ \ ' srcname="Crab"'+ \ - ' caldb="prod2"'+ \ - ' irf="South_0.5h"'+ \ + ' caldb="'+self._caldb+'"'+ \ + ' irf="'+self._irf+'"'+ \ ' outmap="tsmap.fits"'+ \ ' nxpix=5'+ \ ' nypix=5'+ \ @@ -99,11 +99,11 @@ class Test(test): self._check_cmdfile('cstsmapsplit_cmd1.dat') # Setup cstsmapsplit command - cmd = cstsmapsplit+' inobs="data/crab_events.fits"'+ \ - ' inmodel="data/crab.xml"'+ \ + cmd = cstsmapsplit+' inobs="'+self._events+'"'+ \ + ' inmodel="'+self._model+'"'+ \ ' srcname="Does_not_exist"'+ \ - ' caldb="prod2"'+ \ - ' irf="South_0.5h"'+ \ + ' caldb="'+self._caldb+'"'+ \ + ' irf="'+self._irf+'"'+ \ ' outmap="tsmap.fits"'+ \ ' nxpix=5'+ \ ' nypix=5'+ \ @@ -131,11 +131,11 @@ class Test(test): """ # Set-up cstsmapsplit tsmapsplit = cscripts.cstsmapsplit() - tsmapsplit['inobs'] = 'data/crab_events.fits' - tsmapsplit['inmodel'] = 'data/crab.xml' + tsmapsplit['inobs'] = self._events + tsmapsplit['inmodel'] = self._model tsmapsplit['srcname'] = 'Crab' - tsmapsplit['caldb'] = 'prod2' - tsmapsplit['irf'] = 'South_0.5h' + tsmapsplit['caldb'] = self._caldb + tsmapsplit['irf'] = self._irf tsmapsplit['outmap'] = 'tsmap.fits' tsmapsplit['bins_per_job'] = 5 tsmapsplit['compute_null'] = False diff --git a/test/test_csworkflow.py b/test/test_csworkflow.py index d63b3ed..6ca91b2 100755 --- a/test/test_csworkflow.py +++ b/test/test_csworkflow.py @@ -42,6 +42,9 @@ class Test(test): # Call base class constructor test.__init__(self) + # Set members + self._workflow = self._datadir + '/workflow.xml' + # Return return @@ -72,7 +75,7 @@ class Test(test): gammalib.GFilename('wf_crab_results.xml').remove() # Setup csworkflow command - cmd = csworkflow+' inflow="data/workflow.xml"'+ \ + cmd = csworkflow+' inflow="'+self._workflow+'"'+ \ ' logfile="csworkflow_cmd1.log" chatter=1' # Check if execution of wrong command fails @@ -99,7 +102,7 @@ class Test(test): # Set-up csworkflow workflow = cscripts.csworkflow() - workflow['inflow'] = 'data/workflow.xml' + workflow['inflow'] = self._workflow workflow['logfile'] = 'csworkflow_py1.log' workflow['chatter'] = 2 @@ -115,7 +118,7 @@ class Test(test): # Set-up csworkflow workflow = cscripts.csworkflow() - workflow['inflow'] = 'data/workflow.xml' + workflow['inflow'] = self._workflow workflow['logfile'] = 'csworkflow_py2.log' workflow['chatter'] = 3 @@ -140,13 +143,13 @@ class Test(test): self.test_value(models['Crab'][2].value(), 5.71055e-16, 1.0e-5, 'Crab prefactor') self.test_value(models['Crab'][3].value(), - -2.50996, 1.0e-5, 'Crab index') + -2.47559, 1.0e-5, 'Crab index') self.test_value(models['Background'][0].value(), - 2.98499, 1.0e-5, 'Background model sigma') + 3.00491, 1.0e-5, 'Background model sigma') self.test_value(models['Background'][1].value(), 6.27131e-05, 1.0e-5, 'Background model prefactor') self.test_value(models['Background'][2].value(), - -1.85037, 1.0e-5, 'Background model index') + -1.83164, 1.0e-5, 'Background model index') # Return return diff --git a/test/test_ctbin.py b/test/test_ctbin.py index 6b91bf0..8fe5532 100755 --- a/test/test_ctbin.py +++ b/test/test_ctbin.py @@ -42,9 +42,6 @@ class Test(test): # Call base class constructor test.__init__(self) - # Set members - self._events_name = 'data/crab_events.fits' - # Return return @@ -72,7 +69,7 @@ class Test(test): ctbin = self._tool('ctbin') # Setup ctbin command - cmd = ctbin+' inobs="'+self._events_name+'"'+ \ + cmd = ctbin+' inobs="'+self._events+'"'+ \ ' outcube="cntmap_cmd1.fits"'+\ ' emin=0.1 emax=100.0 enumbins=20 ebinalg="LOG"'+ \ ' nxpix=200 nypix=200 binsz=0.02 coordsys="CEL"'+ \ @@ -111,7 +108,7 @@ class Test(test): """ # Set-up ctbin bin = ctools.ctbin() - bin['inobs'] = self._events_name + bin['inobs'] = self._events bin['outcube'] = 'cntmap.fits' bin['ebinalg'] = 'LOG' bin['emin'] = 0.1 @@ -157,7 +154,7 @@ class Test(test): self._check_cube(evt, 5542) # Prepare observation container for stacked analysis - cta = gammalib.GCTAObservation(self._events_name) + cta = gammalib.GCTAObservation(self._events) obs = gammalib.GObservations() cta.id('0001') obs.append(cta) diff --git a/test/test_ctbkgcube.py b/test/test_ctbkgcube.py index 601c9d8..eeb7c6b 100755 --- a/test/test_ctbkgcube.py +++ b/test/test_ctbkgcube.py @@ -65,12 +65,12 @@ class Test(test): ctbkgcube = self._tool('ctbkgcube') # Setup ctbkgcube command - cmd = ctbkgcube+' inobs="data/crab_events.fits"'+ \ - ' inmodel="data/crab.xml"'+ \ + cmd = ctbkgcube+' inobs="'+self._events+'"'+ \ + ' inmodel="'+self._model+'"'+ \ ' incube="NONE"'+ \ ' outcube="ctbkgcube_cmd1.fits"'+ \ ' outmodel="ctbkgcube_cmd1.xml"'+ \ - ' caldb="prod2" irf="South_0.5h"'+ \ + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \ ' ebinalg="LOG" emin=0.1 emax=100.0 enumbins=20'+ \ ' nxpix=10 nypix=10 binsz=0.4'+ \ ' coordsys="CEL" proj="CAR" xref=83.63 yref=22.01'+ \ @@ -89,11 +89,11 @@ class Test(test): # Setup ctbkgcube command cmd = ctbkgcube+' inobs="event_file_that_does_not_exist.fits"'+ \ - ' inmodel="data/crab.xml"'+ \ + ' inmodel="'+self._model+'"'+ \ ' incube="NONE"'+ \ ' outcube="ctbkgcube_cmd2.fits"'+ \ ' outmodel="ctbkgcube_cmd2.xml"'+ \ - ' caldb="prod2" irf="South_0.5h"'+ \ + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \ ' ebinalg="LOG" emin=0.1 emax=100.0 enumbins=20'+ \ ' nxpix=10 nypix=10 binsz=0.4'+ \ ' coordsys="CEL" proj="CAR" xref=83.63 yref=22.01'+ \ @@ -113,13 +113,13 @@ class Test(test): """ # Set-up ctbkgcube bkgcube = ctools.ctbkgcube() - bkgcube['inobs'] = 'data/crab_events.fits' - bkgcube['inmodel'] = 'data/crab.xml' + bkgcube['inobs'] = self._events + bkgcube['inmodel'] = self._model bkgcube['incube'] = 'NONE' bkgcube['outcube'] = 'ctbkgcube_py1.fits' bkgcube['outmodel'] = 'ctbkgcube_py1.xml' - bkgcube['caldb'] = 'prod2' - bkgcube['irf'] = 'South_0.5h' + bkgcube['caldb'] = self._caldb + bkgcube['irf'] = self._irf bkgcube['ebinalg'] = 'LOG' bkgcube['emin'] = 0.1 bkgcube['emax'] = 100 diff --git a/test/test_ctbutterfly.py b/test/test_ctbutterfly.py index 71554c0..a6875f3 100755 --- a/test/test_ctbutterfly.py +++ b/test/test_ctbutterfly.py @@ -28,12 +28,12 @@ from testing import test # =============================== # class Test(test): """ - Test class for ctbutterfly tool. + Test class for ctbutterfly tool """ # Constructor def __init__(self): """ - Constructor. + Constructor """ # Call base class constructor test.__init__(self) @@ -44,7 +44,7 @@ class Test(test): # Set test functions def set(self): """ - Set all test functions. + Set all test functions """ # Set test name self.name('ctbutterfly') @@ -59,16 +59,16 @@ class Test(test): # Test ctbutterfly on command line def _test_cmd(self): """ - Test ctbutterfly on the command line. + Test ctbutterfly on the command line """ # Set tool name ctbutterfly = self._tool('ctbutterfly') # Setup ctbutterfly command - cmd = ctbutterfly+' inobs="data/crab_events.fits"'+\ - ' outfile="ctbutterfly_cmd1.txt"'+ \ - ' inmodel="data/crab.xml" srcname="Crab"'+ \ - ' caldb="prod2" irf="South_0.5h"'+ \ + cmd = ctbutterfly+' inobs="'+self._events+'"'+\ + ' outfile="ctbutterfly_cmd1.dat"'+ \ + ' inmodel="'+self._model +'" srcname="Crab"'+ \ + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \ ' emin=0.1 emax=100.0'+ \ ' logfile="ctbutterfly_cmd1.log" chatter=1' @@ -81,13 +81,13 @@ class Test(test): 'Check successful execution from command line') # Check result file - self._check_result_file('ctbutterfly_cmd1.txt') + self._check_result_file('ctbutterfly_cmd1.dat') # Setup ctbutterfly command cmd = ctbutterfly+' inobs="event_file_that_does_not_exist.fits"'+\ - ' outfile="ctbutterfly_cmd2.txt"'+ \ - ' inmodel="data/crab.xml" srcname="Crab"'+ \ - ' caldb="prod2" irf="South_0.5h"'+ \ + ' outfile="ctbutterfly_cmd2.dat"'+ \ + ' inmodel="'+self._model +'" srcname="Crab"'+ \ + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \ ' emin=0.1 emax=100.0'+ \ ' logfile="ctbutterfly_cmd2.log" chatter=1' @@ -105,14 +105,14 @@ class Test(test): """ # Set-up ctbutterfly butterfly = ctools.ctbutterfly() - butterfly['inobs'] = 'data/crab_events.fits' - butterfly['inmodel'] = 'data/crab.xml' + butterfly['inobs'] = self._events + butterfly['inmodel'] = self._model butterfly['srcname'] = 'Crab' - butterfly['caldb'] = 'prod2' - butterfly['irf'] = 'South_0.5h' + butterfly['caldb'] = self._caldb + butterfly['irf'] = self._irf butterfly['emin'] = 0.1 butterfly['emax'] = 100.0 - butterfly['outfile'] = 'ctbutterfly_py1.txt' + butterfly['outfile'] = 'ctbutterfly_py1.dat' butterfly['logfile'] = 'ctbutterfly_py1.log' butterfly['chatter'] = 2 @@ -122,7 +122,7 @@ class Test(test): butterfly.save() # Check result file - self._check_result_file('ctbutterfly_py1.txt') + self._check_result_file('ctbutterfly_py1.dat') # Return return @@ -136,8 +136,10 @@ class Test(test): results = gammalib.GCsv(filename) # Check dimensions - self.test_value(results.nrows(), 100, 'Check for 100 rows in butterfly file') - self.test_value(results.ncols(), 4, 'Check for 4 columns in butterfly file') + self.test_value(results.nrows(), 100, + 'Check for 100 rows in butterfly file') + self.test_value(results.ncols(), 4, + 'Check for 4 columns in butterfly file') # Return return diff --git a/test/test_ctcubemask.py b/test/test_ctcubemask.py index f271a7d..0d1f502 100755 --- a/test/test_ctcubemask.py +++ b/test/test_ctcubemask.py @@ -38,6 +38,9 @@ class Test(test): # Call base class constructor test.__init__(self) + # Set members + self._exclusion = self._datadir + '/exclusion.reg' + # Return return @@ -65,8 +68,8 @@ class Test(test): ctcubemask = self._tool('ctcubemask') # Setup ctcubemask command - cmd = ctcubemask+' inobs="data/crab_cntmap.fits"'+ \ - ' regfile="data/exclusion.reg"'+ \ + cmd = ctcubemask+' inobs="'+self._cntcube+'"'+ \ + ' regfile="'+self._exclusion+'"'+ \ ' outcube="ctcubemask_cmd1.fits"'+ \ ' ra=83.63 dec=22.01 rad=2.0'+ \ ' emin=0.1 emax=100.0'+ \ @@ -85,7 +88,7 @@ class Test(test): # Setup ctcubemask command cmd = ctcubemask+' inobs="counts_cube_that_does_not_exist.fits"'+ \ - ' regfile="data/exclusion.reg"'+ \ + ' regfile="'+self._exclusion+'"'+ \ ' outcube="ctcubemask_cmd2.fits"'+ \ ' ra=83.63 dec=22.01 rad=2.0'+ \ ' emin=0.1 emax=100.0'+ \ @@ -105,8 +108,8 @@ class Test(test): """ # Set-up ctcubemask mask = ctools.ctcubemask() - mask['inobs'] = 'data/crab_cntmap.fits' - mask['regfile'] = 'data/exclusion.reg' + mask['inobs'] = self._cntcube + mask['regfile'] = self._exclusion mask['outcube'] = 'ctcubemask_py1.fits' mask['ra'] = 83.63 mask['dec'] = 22.01 diff --git a/test/test_ctedispcube.py b/test/test_ctedispcube.py index 825fcc5..ac29b05 100755 --- a/test/test_ctedispcube.py +++ b/test/test_ctedispcube.py @@ -65,10 +65,10 @@ class Test(test): ctedispcube = self._tool('ctedispcube') # Setup ctedispcube command - cmd = ctedispcube+' inobs="data/crab_events.fits"'+ \ + cmd = ctedispcube+' inobs="'+self._events+'"'+ \ ' incube="NONE"'+ \ ' outcube="ctedispcube_cmd1.fits"'+ \ - ' caldb="prod2" irf="South_0.5h"'+ \ + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \ ' ebinalg="LOG" emin=0.1 emax=100.0 enumbins=20'+ \ ' nxpix=10 nypix=10 binsz=0.4'+ \ ' coordsys="CEL" proj="CAR" xref=83.63 yref=22.01'+ \ @@ -90,7 +90,7 @@ class Test(test): cmd = ctedispcube+' inobs="events_that_do_not_exist.fits"'+ \ ' incube="NONE"'+ \ ' outcube="ctedispcube_cmd2.fits"'+ \ - ' caldb="prod2" irf="South_0.5h"'+ \ + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \ ' ebinalg="LOG" emin=0.1 emax=100.0 enumbins=20'+ \ ' nxpix=10 nypix=10 binsz=0.4'+ \ ' coordsys="CEL" proj="CAR" xref=83.63 yref=22.01'+ \ @@ -111,11 +111,11 @@ class Test(test): """ # Set-up ctedispcube edispcube = ctools.ctedispcube() - edispcube['inobs'] = 'data/crab_events.fits' + edispcube['inobs'] = self._events edispcube['incube'] = 'NONE' edispcube['outcube'] = 'ctedispcube_py1.fits' - edispcube['caldb'] = 'prod2' - edispcube['irf'] = 'South_0.5h' + edispcube['caldb'] = self._caldb + edispcube['irf'] = self._irf edispcube['ebinalg'] = 'LOG' edispcube['emin'] = 0.1 edispcube['emax'] = 100 diff --git a/test/test_cterror.py b/test/test_cterror.py index dd38ec5..cfd563e 100755 --- a/test/test_cterror.py +++ b/test/test_cterror.py @@ -38,13 +38,6 @@ class Test(test): # Call base class constructor test.__init__(self) - # Set members - self.events_name = 'data/crab_events.fits' - self.model_name = 'data/crab.xml' - self.result_name = 'cterror_result.xml' - self.caldb = 'irf' - self.irf = 'cta_dummy_irf' - # Return return @@ -72,9 +65,9 @@ class Test(test): cterror = self._tool('cterror') # Setup cterror command - cmd = cterror+' inobs="data/crab_events.fits"'+ \ - ' inmodel="data/crab.xml" srcname="Crab"'+ \ - ' caldb="prod2" irf="South_0.5h"'+ \ + cmd = cterror+' inobs="'+self._events+'"'+ \ + ' inmodel="'+self._model+'" srcname="Crab"'+ \ + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \ ' outmodel="cterror_cmd1.xml"'+ \ ' logfile="cterror_cmd1.log" chatter=1' @@ -91,8 +84,8 @@ class Test(test): # Setup cterror command cmd = cterror+' inobs="event_file_that_does_not_exist.fits"'+ \ - ' inmodel="data/crab.xml" srcname="Crab"'+ \ - ' caldb="prod2" irf="South_0.5h"'+ \ + ' inmodel="'+self._model+'" srcname="Crab"'+ \ + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \ ' outmodel="cterror_cmd2.xml"'+ \ ' logfile="cterror_cmd2.log" chatter=1' @@ -110,12 +103,12 @@ class Test(test): """ # Set-up cterror error = ctools.cterror() - error['inobs'] = 'data/crab_events.fits' - error['inmodel'] = 'data/crab.xml' + error['inobs'] = self._events + error['inmodel'] = self._model error['outmodel'] = 'cterror_py1.xml' error['srcname'] = 'Crab' - error['caldb'] = 'prod2' - error['irf'] = 'South_0.5h' + error['caldb'] = self._caldb + error['irf'] = self._irf error['logfile'] = 'cterror_py1.log' error['chatter'] = 2 diff --git a/test/test_ctexpcube.py b/test/test_ctexpcube.py index 81e3236..1e545ce 100755 --- a/test/test_ctexpcube.py +++ b/test/test_ctexpcube.py @@ -65,10 +65,10 @@ class Test(test): ctexpcube = self._tool('ctexpcube') # Setup ctexpcube command - cmd = ctexpcube+' inobs="data/crab_events.fits"'+ \ + cmd = ctexpcube+' inobs="'+self._events+'"'+ \ ' incube="NONE"'+ \ ' outcube="ctexpcube_cmd1.fits"'+ \ - ' caldb="prod2" irf="South_0.5h"'+ \ + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \ ' ebinalg="LOG" emin=0.1 emax=100.0 enumbins=20'+ \ ' nxpix=200 nypix=200 binsz=0.02'+ \ ' coordsys="CEL" proj="CAR" xref=83.63 yref=22.01'+ \ @@ -89,7 +89,7 @@ class Test(test): cmd = ctexpcube+' inobs="event_file_that_does_not_exist.fits"'+ \ ' incube="NONE"'+ \ ' outcube="ctexpcube_cmd2.fits"'+ \ - ' caldb="prod2" irf="South_0.5h"'+ \ + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \ ' ebinalg="LOG" emin=0.1 emax=100.0 enumbins=20'+ \ ' nxpix=200 nypix=200 binsz=0.02'+ \ ' coordsys="CEL" proj="CAR" xref=83.63 yref=22.01'+ \ @@ -109,11 +109,11 @@ class Test(test): """ # Set-up ctexpcube expcube = ctools.ctexpcube() - expcube['inobs'] = 'data/crab_events.fits' + expcube['inobs'] = self._events expcube['incube'] = 'NONE' expcube['outcube'] = 'ctexpcube_py1.fits' - expcube['caldb'] = 'prod2' - expcube['irf'] = 'South_0.5h' + expcube['caldb'] = self._caldb + expcube['irf'] = self._irf expcube['ebinalg'] = 'LOG' expcube['emin'] = 0.1 expcube['emax'] = 100 diff --git a/test/test_ctlike.py b/test/test_ctlike.py index 538a019..84729a3 100755 --- a/test/test_ctlike.py +++ b/test/test_ctlike.py @@ -65,9 +65,9 @@ class Test(test): ctlike = self._tool('ctlike') # Setup ctlike command - cmd = ctlike+' inobs="data/crab_events.fits"'+ \ - ' inmodel="data/crab.xml"'+ \ - ' caldb="prod2" irf="South_0.5h"'+ \ + cmd = ctlike+' inobs="'+self._events+'"'+ \ + ' inmodel="'+self._model+'"'+ \ + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \ ' outmodel="ctlike_cmd1.xml"'+ \ ' logfile="ctlike_cmd1.log" chatter=1' @@ -84,8 +84,8 @@ class Test(test): # Setup ctlike command cmd = ctlike+' inobs="event_file_that_does_not_exist.fits"'+ \ - ' inmodel="data/crab.xml"'+ \ - ' caldb="prod2" irf="South_0.5h"'+ \ + ' inmodel="'+self._model+'"'+ \ + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \ ' outmodel="ctlike_cmd2.xml"'+ \ ' logfile="ctlike_cmd2.log" chatter=1' @@ -103,10 +103,10 @@ class Test(test): """ # Set-up ctlike like = ctools.ctlike() - like['inobs'] = 'data/crab_events.fits' - like['inmodel'] = 'data/crab.xml' - like['caldb'] = 'prod2' - like['irf'] = 'South_0.5h' + like['inobs'] = self._events + like['inmodel'] = self._model + like['caldb'] = self._caldb + like['irf'] = self._irf like['outmodel'] = 'ctlike_py1.xml' like['logfile'] = 'ctlike_py1.log' like['chatter'] = 2 diff --git a/test/test_ctmapcube.py b/test/test_ctmapcube.py index c59b703..22137ee 100644 --- a/test/test_ctmapcube.py +++ b/test/test_ctmapcube.py @@ -42,9 +42,6 @@ class Test(test): # Call base class constructor test.__init__(self) - # Set members - self._model_name = 'data/crab.xml' - # Return return @@ -72,7 +69,7 @@ class Test(test): ctmapcube = self._tool('ctmapcube') # Setup ctmapcube command - cmd = ctmapcube+' inmodel="'+self._model_name+'"'+ \ + cmd = ctmapcube+' inmodel="'+self._model+'"'+ \ ' outcube="ctmapcube_cmd1.fits"'+\ ' emin=0.1 emax=100.0 enumbins=20 ebinalg=LOG'+ \ ' nxpix=200 nypix=200 binsz=0.02 coordsys=CEL'+ \ @@ -112,7 +109,7 @@ class Test(test): """ # Set-up ctmapcube mapcube = ctools.ctmapcube() - mapcube['inmodel'] = self._model_name + mapcube['inmodel'] = self._model mapcube['outcube'] = 'ctmapcube_py1.fits' mapcube['ebinalg'] = 'LOG' mapcube['emin'] = 0.1 diff --git a/test/test_ctmodel.py b/test/test_ctmodel.py index c40a460..7c28c60 100755 --- a/test/test_ctmodel.py +++ b/test/test_ctmodel.py @@ -68,8 +68,8 @@ class Test(test): cmd = ctmodel+' incube="NONE" inobs="NONE" expcube="NONE"'+\ ' psfcube="NONE" bkgcube="NONE"'+ \ ' outcube="ctmodel_cmd1.fits"'+ \ - ' inmodel="data/crab.xml"'+ \ - ' caldb="prod2" irf="South_0.5h"'+ \ + ' inmodel="'+self._model+'"'+ \ + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \ ' rad=5.0 ra=83.63 dec=22.01 tmin=0.0 tmax=1800'+ \ ' emin=0.1 emax=100.0 enumbins=20 nxpix=200 nypix=200'+ \ ' binsz=0.02 coordsys="CEL" proj="CAR"'+ \ @@ -92,7 +92,7 @@ class Test(test): ' psfcube="NONE" bkgcube="NONE"'+ \ ' outcube="ctmodel_cmd2.fits"'+ \ ' inmodel="model_that_does_not_exist.xml"'+ \ - ' caldb="prod2" irf="South_0.5h"'+ \ + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \ ' rad=5.0 ra=83.63 dec=22.01 tmin=0.0 tmax=1800'+ \ ' emin=0.1 emax=100.0 enumbins=20 nxpix=200 nypix=200'+ \ ' binsz=0.02 coordsys="CEL" proj="CAR"'+ \ @@ -115,13 +115,13 @@ class Test(test): model = ctools.ctmodel() model['incube'] = 'NONE' model['outcube'] = 'ctmodel_py1.fits' - model['inmodel'] = 'data/crab.xml' + model['inmodel'] = self._model model['inobs'] = 'NONE' model['expcube'] = 'NONE' model['psfcube'] = 'NONE' model['bkgcube'] = 'NONE' - model['caldb'] = 'prod2' - model['irf'] = 'South_0.5h' + model['caldb'] = self._caldb + model['irf'] = self._irf model['rad'] = 5 model['ra'] = 83.63 model['dec'] = 22.01 diff --git a/test/test_ctobssim.py b/test/test_ctobssim.py index 674fe84..fe55cac 100755 --- a/test/test_ctobssim.py +++ b/test/test_ctobssim.py @@ -43,11 +43,6 @@ class Test(test): # Call base class constructor test.__init__(self) - # Set members - self._model_name = 'data/crab.xml' - self._caldb = 'irf' - self._irf = 'cta_dummy_irf' - # Return return @@ -75,8 +70,9 @@ class Test(test): ctobssim = self._tool('ctobssim') # Setup ctobssim command - cmd = ctobssim+' inmodel="data/crab.xml" outevents="events.fits"'+ \ - ' caldb="irf" irf="cta_dummy_irf" '+ \ + cmd = ctobssim+' inmodel="'+self._model+'" '+ \ + ' outevents="events.fits"'+ \ + ' caldb="'+self._caldb+'" irf="'+self._irf+'" '+ \ ' ra=83.63 dec=22.01 rad=10.0'+ \ ' tmin=0.0 tmax=1800.0 emin=0.1 emax=100.0' @@ -90,12 +86,12 @@ class Test(test): # Load counts cube and check content. evt = gammalib.GCTAEventList('events.fits') - self._test_list(evt, 4119) + self._test_list(evt, 6881) # Setup ctobssim command cmd = ctobssim+' inmodel="model_that_does_not_exist.xml"'+ \ ' outevents="events.fits"'+ \ - ' caldb="irf" irf="cta_dummy_irf" '+ \ + ' caldb="'+self._caldb+'" irf="'+self._irf+'" '+ \ ' ra=83.63 dec=22.01 rad=10.0'+ \ ' tmin=0.0 tmax=1800.0 emin=0.1 emax=100.0' @@ -113,7 +109,7 @@ class Test(test): """ # Set-up ctobssim sim = ctools.ctobssim() - sim['inmodel'] = self._model_name + sim['inmodel'] = self._model sim['outevents'] = 'events.fits' sim['caldb'] = self._caldb sim['irf'] = self._irf @@ -130,14 +126,14 @@ class Test(test): # Check content of observation self._test_observation(sim) - self._test_list(sim.obs()[0].events(), 4119) + self._test_list(sim.obs()[0].events(), 6881) # Save events sim.save() # Load counts cube and check content. evt = gammalib.GCTAEventList('events.fits') - self._test_list(evt, 4119) + self._test_list(evt, 6881) # Set-up observation container pnts = [{'ra': 83.63, 'dec': 21.01}, @@ -149,17 +145,17 @@ class Test(test): # Set-up ctobssim from observation container sim = ctools.ctobssim(obs) sim['outevents'] = 'sim_events.xml' - sim['inmodel'] = self._model_name + sim['inmodel'] = self._model # Run tool sim.run() # Retrieve observation and check content self._test_observation(sim, nobs=4, pnts=pnts) - self._test_list(sim.obs()[0].events(), 4063) - self._test_list(sim.obs()[1].events(), 4059) - self._test_list(sim.obs()[2].events(), 4010) - self._test_list(sim.obs()[3].events(), 4138) + self._test_list(sim.obs()[0].events(), 6003) + self._test_list(sim.obs()[1].events(), 6084) + self._test_list(sim.obs()[2].events(), 5955) + self._test_list(sim.obs()[3].events(), 6030) # Save events sim.save() @@ -168,10 +164,10 @@ class Test(test): obs = gammalib.GObservations('sim_events.xml') # Retrieve observation and check content - self._test_list(obs[0].events(), 4063) - self._test_list(obs[1].events(), 4059) - self._test_list(obs[2].events(), 4010) - self._test_list(obs[3].events(), 4138) + self._test_list(obs[0].events(), 6003) + self._test_list(obs[1].events(), 6084) + self._test_list(obs[2].events(), 5955) + self._test_list(obs[3].events(), 6030) # Set-up ctobssim with invalid event file sim = ctools.ctobssim() diff --git a/test/test_ctools.sh b/test/test_ctools.sh deleted file mode 100755 index 5b292eb..0000000 --- a/test/test_ctools.sh +++ /dev/null @@ -1,695 +0,0 @@ -#! /bin/sh -# ========================================================================== -# This script tests all ctools -# -# Copyright (C) 2011-2016 Juergen Knoedlseder -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# -# ========================================================================== - -# -# Get echo command (to circumvent built-in echo on some systems) -# -ECHO=`which echo` - -# -# Print Header -# -$ECHO "***************" -$ECHO "* Test ctools *" -$ECHO "***************" - -# -# Define executables -# ================== -ctbin=../src/ctbin/ctbin -ctlike=../src/ctlike/ctlike -cttsmap=../src/cttsmap/cttsmap -ctmodel=../src/ctmodel/ctmodel -ctobssim=../src/ctobssim/ctobssim -ctselect=../src/ctselect/ctselect -ctskymap=../src/ctskymap/ctskymap -ctexpcube=../src/ctexpcube/ctexpcube -ctpsfcube=../src/ctpsfcube/ctpsfcube -ctedispcube=../src/ctedispcube/ctedispcube -ctbkgcube=../src/ctbkgcube/ctbkgcube -ctcubemask=../src/ctcubemask/ctcubemask -ctbutterfly=../src/ctbutterfly/ctbutterfly -ctulimit=../src/ctulimit/ctulimit -cterror=../src/cterror/cterror - - -# -# Remove any existing result files -# ================================ -rm -rf *.fits *.xml -rm -rf ulimit.dat butterfly.txt - - -# -# Creates pfiles directory -# ======================== -rm -rf pfiles -mkdir -p pfiles -cp -r ../src/*/*.par pfiles/ -export PFILES=pfiles - - -# -# Test ctobssim -# ============= -$ECHO -n "Test ctobssim: " - -# -# Run 1 -$ctobssim inmodel="data/crab.xml" \ - outevents="events.fits" \ - caldb="irf" \ - irf="cta_dummy_irf" \ - ra=83.63 \ - dec=22.01 \ - rad=10.0 \ - tmin=0.0 \ - tmax=1800.0 \ - emin=0.1 \ - emax=100.0 -$ECHO -n "." -if [ -s "events.fits" ] -then - $ECHO -n "." -else - echo " events.fits file is not found" - exit 1 -fi -$ECHO " ok" - - -# -# Test ctskymap -# ============= -$ECHO -n "Test ctskymap: " -$ctskymap inobs="events.fits" \ - outmap="skymap.fits" \ - emin=0.1 \ - emax=100.0 \ - nxpix=200 \ - nypix=200 \ - binsz=0.02 \ - coordsys="CEL" \ - xref=83.63 \ - yref=22.01 \ - proj="CAR" -$ECHO -n "." -if [ -s "skymap.fits" ] -then - $ECHO -n "." -else - $ECHO " skymap.fits file is not found" - exit 1 -fi -$ECHO " ok" - - -# -# Test ctbin -# ========== -$ECHO -n "Test ctbin: " -# -# Run 1 -$ctbin inobs="events.fits" \ - outcube="cntmap1.fits" \ - emin=0.1 \ - emax=100.0 \ - enumbins=20 \ - ebinalg="LOG" \ - nxpix=200 \ - nypix=200 \ - binsz=0.02 \ - coordsys="CEL" \ - xref=83.63 \ - yref=22.01 \ - proj="CAR" -$ECHO -n "." -if [ -s "cntmap1.fits" ] -then - $ECHO -n "." -else - $ECHO " cntmap1.fits file is not found" - exit 1 -fi -# -# Run 2 -$ctbin inobs="events.fits" \ - outcube="cntmap2.fits" \ - emin=0.3 \ - emax=8.0 \ - enumbins=7 \ - ebinalg="LOG" \ - nxpix=30 \ - nypix=30 \ - binsz=0.05 \ - coordsys="CEL" \ - xref=86.63 \ - yref=22.01 \ - proj="CAR" -$ECHO -n "." -if [ -s "cntmap2.fits" ] -then - $ECHO -n "." -else - $ECHO " cntmap2.fits file is not found" - exit 1 -fi -$ECHO " ok" - -# -# Test ctexpcube -# ============== -$ECHO -n "Test ctexpcube: " -# -# Run 1 -$ctexpcube inobs="data/crab_events.fits" \ - incube="NONE" \ - outcube="expcube1.fits" \ - caldb="irf" \ - irf="cta_dummy_irf" \ - emin=0.1 \ - emax=100.0 \ - enumbins=20 \ - nxpix=200 \ - nypix=200 \ - binsz=0.02 \ - coordsys="CEL" \ - xref=83.63 \ - yref=22.01 \ - proj="CAR" -$ECHO -n "." -if [ -s "expcube1.fits" ] -then -$ECHO -n "." -else -$ECHO " expcube1.fits file is not found" -exit 1 -fi -# -# Run 2 -$ctexpcube inobs="events.fits" \ - incube="cntmap2.fits" \ - outcube="expcube2.fits" \ - caldb="irf" \ - irf="cta_dummy_irf" -$ECHO -n "." -if [ -s "expcube2.fits" ] -then -$ECHO -n "." -else -$ECHO " expcube2.fits file is not found" -exit 1 -fi -$ECHO " ok" - - -# -# Test ctpsfcube -# ============== -$ECHO -n "Test ctpsfcube: " -# -# Run 1 -$ctpsfcube inobs="data/crab_events.fits" \ - incube="NONE" \ - outcube="psfcube1.fits" \ - caldb="irf" \ - irf="cta_dummy_irf" \ - emin=0.1 \ - emax=100.0 \ - enumbins=20 \ - nxpix=10 \ - nypix=10 \ - binsz=0.4 \ - coordsys="CEL" \ - xref=83.63 \ - yref=22.01 \ - proj="CAR" \ - amax=0.3 \ - anumbins=10 -$ECHO -n "." -if [ -s "psfcube1.fits" ] -then -$ECHO -n "." -else -$ECHO " psfcube1.fits file is not found" -exit 1 -fi -# -# Run 2 -$ctpsfcube inobs="events.fits" \ - incube="cntmap2.fits" \ - outcube="psfcube2.fits" \ - caldb="irf" \ - irf="cta_dummy_irf" \ - amax=0.3 \ - anumbins=2 -$ECHO -n "." -if [ -s "psfcube2.fits" ] -then -$ECHO -n "." -else -$ECHO " psfcube2.fits file is not found" -exit 1 -fi -$ECHO " ok" - - -# -# Test ctedispcube -# ============== -$ECHO -n "Test ctedispcube: " -# -# Run 1 -$ctedispcube inobs="data/crab_events.fits" \ - incube="NONE" \ - outcube="edispcube1.fits" \ - caldb="irf" \ - irf="cta_dummy_irf" \ - emin=0.1 \ - emax=100.0 \ - enumbins=20 \ - nxpix=10 \ - nypix=10 \ - binsz=0.4 \ - coordsys="CEL" \ - xref=83.63 \ - yref=22.01 \ - proj="CAR" \ - migramax=3.0 \ - migrabins=10 -$ECHO -n "." -if [ -s "edispcube1.fits" ] -then -$ECHO -n "." -else -$ECHO " edispcube1.fits file is not found" -exit 1 -fi -# -# Run 2 -$ctedispcube inobs="events.fits" \ - incube="cntmap2.fits" \ - outcube="edispcube2.fits" \ - caldb="irf" \ - irf="cta_dummy_irf" \ - migramax=3.0 \ - migrabins=3 -$ECHO -n "." -if [ -s "edispcube2.fits" ] -then -$ECHO -n "." -else -$ECHO " edispcube2.fits file is not found" -exit 1 -fi -$ECHO " ok" - - -# -# Test ctbkgcube -# ============== -$ECHO -n "Test ctbkgcube: " -# -# Run 1 -$ctbkgcube inobs="data/crab_events.fits" \ - inmodel="data/crab.xml" \ - incube="NONE" \ - outcube="bkgcube1.fits" \ - outmodel="bkgcube1.xml" \ - caldb="irf" \ - irf="cta_dummy_irf" \ - emin=0.1 \ - emax=100.0 \ - enumbins=20 \ - nxpix=10 \ - nypix=10 \ - binsz=0.4 \ - coordsys="CEL" \ - xref=83.63 \ - yref=22.01 \ - proj="CAR" -$ECHO -n "." -if [ -s "bkgcube1.fits" ] -then -$ECHO -n "." -else -$ECHO " bkgcube1.fits file is not found" -exit 1 -fi -if [ -s "bkgcube1.xml" ] -then -$ECHO -n "." -else -$ECHO " bkgcube1.xml file is not found" -exit 1 -fi -# -# Run 2 -$ctbkgcube inobs="events.fits" \ - inmodel="data/crab.xml" \ - incube="cntmap2.fits" \ - caldb="irf" \ - irf="cta_dummy_irf" \ - outcube="bkgcube2.fits" \ - outmodel="bkgcube2.xml" -$ECHO -n "." -if [ -s "bkgcube2.fits" ] -then -$ECHO -n "." -else -$ECHO " bkgcube2.fits file is not found" -exit 1 -fi -if [ -s "bkgcube2.fits" ] -then -$ECHO -n "." -else -$ECHO " bkgcube2.xml file is not found" -exit 1 -fi -$ECHO " ok" - - -# -# Test ctmodel -# ============ -$ECHO -n "Test ctmodel: " -# -# Run 1 -$ctmodel inobs="cntmap1.fits" \ - incube="cntmap1.fits" \ - outcube="modmap1.fits" \ - expcube="NONE" \ - psfcube="NONE" \ - bkgcube="NONE" \ - edispcube="NONE" \ - caldb="irf" \ - irf="cta_dummy_irf" \ - inmodel="data/crab.xml" -$ECHO -n "." -if [ -s "modmap1.fits" ] -then - $ECHO -n "." -else - $ECHO " modmap1.fits file is not found" - exit 1 -fi - -# -# Run 2 -$ctmodel inobs="cntmap2.fits" \ - incube="cntmap2.fits" \ - outcube="modmap2.fits" \ - expcube="expcube2.fits" \ - psfcube="psfcube2.fits" \ - edispcube="edispcube2.fits" \ - bkgcube="bkgcube2.fits" \ - caldb="irf" \ - irf="cta_dummy_irf" \ - inmodel="bkgcube2.xml" -$ECHO -n "." -if [ -s "modmap2.fits" ] -then -$ECHO -n "." -else -$ECHO " modmap2.fits file is not found" -exit 1 -fi - -# -# Run 3 -$ctmodel inobs="NONE" \ - incube="NONE" \ - outcube="modmap3.fits" \ - expcube="NONE" \ - psfcube="NONE" \ - edispcube="NONE" \ - bkgcube="NONE" \ - caldb="irf" \ - irf="cta_dummy_irf" \ - inmodel="data/crab.xml" \ - ra=83.63 \ - dec=22.01 \ - rad=10.0 \ - tmin=0.0 \ - tmax=1800.0 \ - emin=0.1 \ - emax=100.0 \ - enumbins=20 \ - nxpix=200 \ - nypix=200 \ - binsz=0.02 \ - coordsys="CEL" \ - xref=83.63 \ - yref=22.01 \ - proj="CAR" -$ECHO -n "." -if [ -s "modmap3.fits" ] -then - $ECHO -n "." -else - $ECHO " modmap3.fits file is not found" - exit 1 -fi -$ECHO " ok" - - -# -# Test ctselect -# ============= -$ECHO -n "Test ctselect: " -$ctselect inobs="events.fits" \ - outobs="selected_events.fits" \ - ra=83.63 \ - dec=22.01 \ - rad=10.0 \ - tmin=0.0 \ - tmax=1800.0 \ - emin=0.1 \ - emax=100.0 -$ECHO -n "." -if [ -s "selected_events.fits" ] -then - $ECHO -n "." -else - $ECHO " selected_events.fits file is not found" - exit 1 -fi -$ECHO " ok" - - -# -# Test ctlike -# =========== -$ECHO -n "Test ctlike: " -# -# Run 1 -$ctlike inobs="cntmap1.fits" \ - inmodel="data/crab.xml" \ - outmodel="results_binned.xml" \ - expcube="NONE" \ - psfcube="NONE" \ - edispcube="NONE" \ - bkgcube="NONE" \ - caldb="irf" \ - irf="cta_dummy_irf" -$ECHO -n "." -if [ -s "results_binned.xml" ] -then - $ECHO -n "." -else - $ECHO " results_binned.xml file is not found" - exit 1 -fi -# -# Run 2 -$ctlike inobs="selected_events.fits" \ - inmodel="data/crab.xml" \ - outmodel="results_unbinned.xml" \ - caldb="irf" \ - irf="cta_dummy_irf" -$ECHO -n "." -if [ -s "results_unbinned.xml" ] -then - $ECHO -n "." -else - $ECHO " results_unbinned.xml file is not found" - exit 1 -fi - -# -# Run 3 -$ctlike inobs="cntmap2.fits" \ - inmodel="bkgcube2.xml" \ - outmodel="results_binned_cube_background.xml" \ - expcube="expcube2.fits" \ - psfcube="psfcube2.fits" \ - edispcube="NONE" \ - bkgcube="bkgcube2.fits" \ - caldb="irf" \ - irf="cta_dummy_irf" -$ECHO -n "." -if [ -s "results_binned_cube_background.xml" ] -then - $ECHO -n "." -else - $ECHO " results_binned_cube_background.xml file is not found" - exit 1 -fi - - -# -# Run 4 -$ctlike inobs="cntmap2.fits" \ - inmodel="bkgcube2.xml" \ - outmodel="results_binned_cube_background_edisp.xml" \ - expcube="expcube2.fits" \ - psfcube="psfcube2.fits" \ - edispcube="edispcube2.fits" \ - bkgcube="bkgcube2.fits" \ - edisp="yes" - caldb="irf" \ - irf="cta_dummy_irf" -$ECHO -n "." -if [ -s "results_binned_cube_background_edisp.xml" ] -then - $ECHO -n "." -else - $ECHO " results_binned_cube_background_edisp.xml file is not found" - exit 1 -fi -$ECHO " ok" - - -# -# Test cttsmap -# ============ -$ECHO -n "Test cttsmap: " -$cttsmap inobs="selected_events.fits" \ - inmodel="data/crab.xml" \ - srcname="Crab" \ - caldb="irf" \ - irf="cta_dummy_irf" \ - outmap="tsmap.fits" \ - nxpix=5 \ - nypix=5 \ - binsz=0.05 \ - coordsys="CEL" \ - xref=83.63 \ - yref=22.01 \ - proj="CAR" -$ECHO -n "." -if [ -s "tsmap.fits" ] -then - $ECHO -n "." -else - $ECHO " tsmap.fits file is not found" - exit 1 -fi -$ECHO " ok" - - -# -# Test ctcubemask -# =============== -$ECHO -n "Test ctcubemask: " -$ctcubemask inobs="data/crab_cntmap.fits" \ - regfile="data/exclusion.reg" \ - outcube="filtered_cube.fits" \ - ra=83.63 \ - dec=22.01 \ - rad=2.0 \ - emin=0.1 \ - emax=100.0 -$ECHO -n "." -if [ -s "filtered_cube.fits" ] -then - $ECHO -n "." -else - $ECHO " filtered_cube.fits file is not found" - exit 1 -fi -$ECHO " ok" - - -# -# Test ctbutterfly -# =============== -$ECHO -n "Test ctbutterfly: " -$ctbutterfly inobs="data/crab_events.fits.gz" \ - inmodel="data/crab.xml" \ - srcname="Crab" \ - outfile="butterfly.txt" \ - caldb="irf" \ - irf="cta_dummy_irf" \ - emin=0.1 \ - emax=100.0 -$ECHO -n "." -if [ -s "butterfly.txt" ] -then - $ECHO -n "." -else - $ECHO " butterfly.txt file is not found" - exit 1 -fi -$ECHO " ok" - - -# -# Test ctulimit -# =============== -$ECHO -n "Test ctulimit: " -$ctulimit inobs="data/crab_events.fits.gz" \ - inmodel="data/crab.xml" \ - srcname="Crab" \ - caldb="irf" \ - irf="cta_dummy_irf" -$ECHO -n "." -if [ -s "ctulimit.log" ] -then - $ECHO -n "." -else - $ECHO " ctulimit.log file is not found" - exit 1 -fi -$ECHO " ok" - - -# -# Test cterror -# ============ -$ECHO -n "Test cterror: " -$cterror inobs="data/crab_events.fits.gz" \ - inmodel="data/crab.xml" \ - outmodel="results_error.xml" \ - srcname="Crab" \ - caldb="irf" \ - irf="cta_dummy_irf" -$ECHO -n "." -if [ -s "cterror.log" ] -then - $ECHO -n "." -else - $ECHO " cterror.log file is not found" - exit 1 -fi -$ECHO " ok" - diff --git a/test/test_ctpsfcube.py b/test/test_ctpsfcube.py index 1953a64..405a508 100755 --- a/test/test_ctpsfcube.py +++ b/test/test_ctpsfcube.py @@ -65,10 +65,10 @@ class Test(test): ctpsfcube = self._tool('ctpsfcube') # Setup ctpsfcube command - cmd = ctpsfcube+' inobs="data/crab_events.fits"'+ \ + cmd = ctpsfcube+' inobs="'+self._events+'"'+ \ ' incube="NONE"'+ \ ' outcube="ctpsfcube_cmd1.fits"'+ \ - ' caldb="prod2" irf="South_0.5h"'+ \ + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \ ' ebinalg="LOG" emin=0.1 emax=100.0 enumbins=20'+ \ ' nxpix=200 nypix=200 binsz=0.02'+ \ ' coordsys="CEL" proj="CAR" xref=83.63 yref=22.01'+ \ @@ -90,7 +90,7 @@ class Test(test): cmd = ctpsfcube+' inobs="event_file_that_does_not_exist.fits"'+ \ ' incube="NONE"'+ \ ' outcube="ctpsfcube_cmd2.fits"'+ \ - ' caldb="prod2" irf="South_0.5h"'+ \ + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \ ' ebinalg="LOG" emin=0.1 emax=100.0 enumbins=20'+ \ ' nxpix=200 nypix=200 binsz=0.02'+ \ ' coordsys="CEL" proj="CAR" xref=83.63 yref=22.01'+ \ @@ -111,11 +111,11 @@ class Test(test): """ # Set-up ctpsfcube psfcube = ctools.ctpsfcube() - psfcube['inobs'] = 'data/crab_events.fits' + psfcube['inobs'] = self._events psfcube['incube'] = 'NONE' psfcube['outcube'] = 'ctpsfcube_py1.fits' - psfcube['caldb'] = 'prod2' - psfcube['irf'] = 'South_0.5h' + psfcube['caldb'] = self._caldb + psfcube['irf'] = self._irf psfcube['ebinalg'] = 'LOG' psfcube['emin'] = 0.1 psfcube['emax'] = 100 diff --git a/test/test_ctselect.py b/test/test_ctselect.py index c85f140..8522cd4 100755 --- a/test/test_ctselect.py +++ b/test/test_ctselect.py @@ -65,7 +65,7 @@ class Test(test): ctselect = self._tool('ctselect') # Setup ctselect command - cmd = ctselect+' inobs="data/crab_events.fits"'+ \ + cmd = ctselect+' inobs="'+self._events+'"'+ \ ' outobs="ctselect_cmd1.fits"'+ \ ' ra=83.63 dec=22.01 rad=3.0'+ \ ' tmin=0.0 tmax=1800.0'+ \ @@ -105,7 +105,7 @@ class Test(test): """ # Set-up ctselect select = ctools.ctselect() - select['inobs'] = 'data/crab_events.fits' + select['inobs'] = self._events select['outobs'] = 'ctselect_py1.fits' select['ra'] = 83.63 select['dec'] = 22.01 diff --git a/test/test_ctskymap.py b/test/test_ctskymap.py index 10a71bf..bb361ad 100755 --- a/test/test_ctskymap.py +++ b/test/test_ctskymap.py @@ -65,7 +65,7 @@ class Test(test): ctskymap = self._tool('ctskymap') # Setup ctskymap command - cmd = ctskymap+' inobs="data/crab_events.fits"'+\ + cmd = ctskymap+' inobs="'+self._events+'"'+\ ' outmap="ctskymap_cmd1.fits"'+ \ ' emin=0.1 emax=100.0 nxpix=200 nypix=200'+ \ ' binsz=0.02 coordsys="CEL" proj="CAR"'+ \ @@ -105,7 +105,7 @@ class Test(test): """ # Set-up ctskymap skymap = ctools.ctskymap() - skymap['inobs'] = 'data/crab_events.fits' + skymap['inobs'] = self._events skymap['outmap'] = 'ctskymap_py1.fits' skymap['emin'] = 0.1 skymap['emax'] = 100 diff --git a/test/test_cttsmap.py b/test/test_cttsmap.py index c1a4ea1..925694c 100755 --- a/test/test_cttsmap.py +++ b/test/test_cttsmap.py @@ -33,7 +33,7 @@ class Test(test): # Constructor def __init__(self): """ - Constructor. + Constructor """ # Call base class constructor test.__init__(self) @@ -65,9 +65,9 @@ class Test(test): cttsmap = self._tool('cttsmap') # Setup cttsmap command - cmd = cttsmap+' inobs="data/crab_events.fits"'+ \ - ' inmodel="data/crab.xml" srcname="Crab"'+ \ - ' caldb="prod2" irf="South_0.5h"'+ \ + cmd = cttsmap+' inobs="'+self._events+'"'+ \ + ' inmodel="'+self._model+'" srcname="Crab"'+ \ + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \ ' outmap="cttsmap_cmd1.fits"'+ \ ' nxpix=5 nypix=5 binsz=0.02'+ \ ' coordsys="CEL" proj="CAR" xref=83.63 yref=22.01'+ \ @@ -86,8 +86,8 @@ class Test(test): # Setup cttsmap command cmd = cttsmap+' inobs="event_file_that_does_not_exist.fits"'+ \ - ' inmodel="data/crab.xml" srcname="Crab"'+ \ - ' caldb="prod2" irf="South_0.5h"'+ \ + ' inmodel="'+self._model+'" srcname="Crab"'+ \ + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \ ' outmap="cttsmap_cmd2.fits"'+ \ ' nxpix=5 nypix=5 binsz=0.02'+ \ ' coordsys="CEL" proj="CAR" xref=83.63 yref=22.01'+ \ @@ -107,11 +107,11 @@ class Test(test): """ # Set-up cttsmap tsmap = ctools.cttsmap() - tsmap['inobs'] = 'data/crab_events.fits' - tsmap['inmodel'] = 'data/crab.xml' + tsmap['inobs'] = self._events + tsmap['inmodel'] = self._model tsmap['srcname'] = 'Crab' - tsmap['caldb'] = 'prod2' - tsmap['irf'] = 'South_0.5h' + tsmap['caldb'] = self._caldb + tsmap['irf'] = self._irf tsmap['outmap'] = 'cttsmap_py1.fits' tsmap['nxpix'] = 5 tsmap['nypix'] = 5 diff --git a/test/test_ctulimit.py b/test/test_ctulimit.py index 72d1e20..44a6ba5 100755 --- a/test/test_ctulimit.py +++ b/test/test_ctulimit.py @@ -65,9 +65,9 @@ class Test(test): ctulimit = self._tool('ctulimit') # Setup ctulimit command - cmd = ctulimit+' inobs="data/crab_events.fits"'+ \ - ' inmodel="data/crab.xml" srcname="Crab"'+ \ - ' caldb="prod2" irf="South_0.5h"'+ \ + cmd = ctulimit+' inobs="'+self._events+'"'+ \ + ' inmodel="'+self._model+'" srcname="Crab"'+ \ + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \ ' logfile="ctulimit_cmd1.log" chatter=1' # Check if execution of wrong command fails @@ -83,8 +83,8 @@ class Test(test): # Setup ctulimit command cmd = ctulimit+' inobs="event_file_that_does_not_exist.fits"'+ \ - ' inmodel="data/crab.xml" srcname="Crab"'+ \ - ' caldb="prod2" irf="South_0.5h"'+ \ + ' inmodel="'+self._model+'" srcname="Crab"'+ \ + ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \ ' logfile="ctulimit_cmd2.log" chatter=1' # Check if execution failed @@ -101,11 +101,11 @@ class Test(test): """ # Set-up ctulimit ulimit = ctools.ctulimit() - ulimit['inobs'] = 'data/crab_events.fits' - ulimit['inmodel'] = 'data/crab.xml' + ulimit['inobs'] = self._events + ulimit['inmodel'] = self._model ulimit['srcname'] = 'Crab' - ulimit['caldb'] = 'prod2' - ulimit['irf'] = 'South_0.5h' + ulimit['caldb'] = self._caldb + ulimit['irf'] = self._irf ulimit['logfile'] = 'ctulimit_py1.log' ulimit['chatter'] = 2 diff --git a/test/test_examples.py.in b/test/test_examples.py.in index 2d75d79..b6c2cf3 100755 --- a/test/test_examples.py.in +++ b/test/test_examples.py.in @@ -40,6 +40,9 @@ class Test(gammalib.GPythonTestSuite): # Call base class constructor gammalib.GPythonTestSuite.__init__(self) + # Set test data directory + self._datadir = os.environ['TEST_DATA'] + # Return return @@ -58,7 +61,7 @@ class Test(gammalib.GPythonTestSuite): String with name to be used for logging """ # Setup command - cmd = '@PYTHON_COVERAGE@../examples/' + name + '.py' + cmd = '@PYTHON_COVERAGE@@top_srcdir@/examples/' + name + '.py' if len(args) > 0: cmd += ' ' + args @@ -89,26 +92,46 @@ class Test(gammalib.GPythonTestSuite): self.name('examples') # Append tests - self.append(self.test_generate_prod3_irfs, 'Test generate_prod3_irfs.py') - self.append(self.test_make_pointings, 'Test make_pointings.py') - self.append(self.test_make_spectrum, 'Test make_spectrum.py') - self.append(self.test_make_ts_distributions, 'Test make_ts_distributions.py') - self.append(self.test_pipeline_binned_disk, 'Test pipeline_binned_disk.py') - self.append(self.test_pipeline_binned_mem, 'Test pipeline_binned_mem.py') - self.append(self.test_pipeline_stacked_disk, 'Test pipeline_stacked_disk.py') - self.append(self.test_pipeline_stacked_mem, 'Test pipeline_stacked_mem.py') - self.append(self.test_pipeline_unbinned_disk, 'Test pipeline_unbinned_disk.py') - self.append(self.test_pipeline_unbinned_mem, 'Test pipeline_unbinned_mem.py') - self.append(self.test_show_butterfly, 'Test show_butterfly.py') - self.append(self.test_show_model, 'Test show_model.py') - self.append(self.test_show_pha, 'Test show_pha.py') - self.append(self.test_show_pull_evolution, 'Test show_pull_evolution.py') - self.append(self.test_show_pull_histogram, 'Test show_pull_histogram.py') - self.append(self.test_show_response, 'Test test_show_response.py') - self.append(self.test_show_sensitivity, 'Test test_show_sensitivity.py') - self.append(self.test_show_spectrum, 'Test test_show_spectrum.py') - self.append(self.test_show_ts_distribution, 'Test show_ts_distribution.py') - self.append(self.test_show_obs, 'Test show_obs.py') + self.append(self.test_generate_prod3_irfs, + 'Test generate_prod3_irfs.py') + self.append(self.test_make_pointings, + 'Test make_pointings.py') + self.append(self.test_make_spectrum, + 'Test make_spectrum.py') + self.append(self.test_make_ts_distributions, + 'Test make_ts_distributions.py') + self.append(self.test_pipeline_binned_disk, + 'Test pipeline_binned_disk.py') + self.append(self.test_pipeline_binned_mem, + 'Test pipeline_binned_mem.py') + self.append(self.test_pipeline_stacked_disk, + 'Test pipeline_stacked_disk.py') + self.append(self.test_pipeline_stacked_mem, + 'Test pipeline_stacked_mem.py') + self.append(self.test_pipeline_unbinned_disk, + 'Test pipeline_unbinned_disk.py') + self.append(self.test_pipeline_unbinned_mem, + 'Test pipeline_unbinned_mem.py') + self.append(self.test_show_butterfly, + 'Test show_butterfly.py') + self.append(self.test_show_model, + 'Test show_model.py') + self.append(self.test_show_pha, + 'Test show_pha.py') + self.append(self.test_show_pull_evolution, + 'Test show_pull_evolution.py') + self.append(self.test_show_pull_histogram, + 'Test show_pull_histogram.py') + self.append(self.test_show_response, + 'Test test_show_response.py') + self.append(self.test_show_sensitivity, + 'Test test_show_sensitivity.py') + self.append(self.test_show_spectrum, + 'Test test_show_spectrum.py') + self.append(self.test_show_ts_distribution, + 'Test show_ts_distribution.py') + self.append(self.test_show_obs, + 'Test show_obs.py') # Return return @@ -138,7 +161,8 @@ class Test(gammalib.GPythonTestSuite): Test generate_prod3_irfs """ # Execute script - self._execute_python('generate_prod3_irfs') + self._execute_python('generate_prod3_irfs', + args=self._datadir) # Return return @@ -149,7 +173,8 @@ class Test(gammalib.GPythonTestSuite): Test make_spectrum """ # Execute script - self._execute_python('make_spectrum', args='eps') + self._execute_python('make_spectrum', + args=self._datadir+' eps') # Return return @@ -160,7 +185,8 @@ class Test(gammalib.GPythonTestSuite): Test make_ts_distributions """ # Execute script - self._execute_python('make_ts_distributions', args='-n 2 -e 0 -d 1800') + self._execute_python('make_ts_distributions', + args='-n 2 -e 0 -d 1800 -p '+self._datadir) # Return return @@ -171,7 +197,7 @@ class Test(gammalib.GPythonTestSuite): Test pipeline_binned_disk """ # Execute script - self._execute_python('pipeline_binned_disk') + self._execute_python('pipeline_binned_disk', args=self._datadir) # Return return @@ -182,7 +208,7 @@ class Test(gammalib.GPythonTestSuite): Test pipeline_binned_mem """ # Execute script - self._execute_python('pipeline_binned_mem') + self._execute_python('pipeline_binned_mem', args=self._datadir) # Return return @@ -193,7 +219,7 @@ class Test(gammalib.GPythonTestSuite): Test pipeline_stacked_disk """ # Execute script - self._execute_python('pipeline_stacked_disk') + self._execute_python('pipeline_stacked_disk', args=self._datadir) # Return return @@ -204,7 +230,7 @@ class Test(gammalib.GPythonTestSuite): Test pipeline_stacked_mem """ # Execute script - self._execute_python('pipeline_stacked_mem') + self._execute_python('pipeline_stacked_mem', args=self._datadir) # Return return @@ -215,7 +241,7 @@ class Test(gammalib.GPythonTestSuite): Test pipeline_unbinned_disk """ # Execute script - self._execute_python('pipeline_unbinned_disk') + self._execute_python('pipeline_unbinned_disk', args=self._datadir) # Return return @@ -226,7 +252,7 @@ class Test(gammalib.GPythonTestSuite): Test pipeline_unbinned_mem """ # Execute script - self._execute_python('pipeline_unbinned_mem') + self._execute_python('pipeline_unbinned_mem', args=self._datadir) # Return return @@ -238,7 +264,7 @@ class Test(gammalib.GPythonTestSuite): """ # Execute script self._execute_python('show_butterfly', - args='data/butterfly.txt ' + args=self._datadir+'/butterfly.txt ' 'example_show_butterfly.eps') # Return @@ -251,7 +277,8 @@ class Test(gammalib.GPythonTestSuite): """ # Execute script self._execute_python('show_model', - args='data/crab.xml Crab example_show_model.eps') + args=self._datadir+'/crab.xml ' + 'Crab example_show_model.eps') # Return return @@ -263,7 +290,8 @@ class Test(gammalib.GPythonTestSuite): """ # Execute script self._execute_python('show_pha', - args='data/pha.fits example_show_pha.eps') + args=self._datadir+'/pha.fits ' + 'example_show_pha.eps') # Return return @@ -275,7 +303,8 @@ class Test(gammalib.GPythonTestSuite): """ # Execute script self._execute_python('show_pull_evolution', - args='data/pull.dat Pull_Crab_Prefactor ' + args=self._datadir+'/pull.dat ' + 'Pull_Crab_Prefactor ' 'example_show_pull_evolution.eps') # Return @@ -288,7 +317,8 @@ class Test(gammalib.GPythonTestSuite): """ # Execute script self._execute_python('show_pull_histogram', - args='data/pull.dat Pull_Crab_Prefactor 50 ' + args=self._datadir+'/pull.dat ' + 'Pull_Crab_Prefactor 50 ' 'example_show_pull_histogram.eps') # Return @@ -312,7 +342,7 @@ class Test(gammalib.GPythonTestSuite): """ # Execute script self._execute_python('show_sensitivity', - args='data/sensitivity.dat ' + args=self._datadir+'/sensitivity.dat ' 'example_show_sensitivity.eps') # Return @@ -325,7 +355,7 @@ class Test(gammalib.GPythonTestSuite): """ # Execute script self._execute_python('show_spectrum', - args='data/spectrum.fits ' + args=self._datadir+'/spectrum.fits ' 'example_show_spectrum.eps') # Return @@ -338,7 +368,7 @@ class Test(gammalib.GPythonTestSuite): """ # Execute script self._execute_python('show_ts_distribution', - args='data/ts.dat -n 100 ' + args=self._datadir+'/ts.dat -n 100 ' '-f example_show_ts_distribution.eps') # Return @@ -351,7 +381,8 @@ class Test(gammalib.GPythonTestSuite): """ # Execute script self._execute_python('show_obs', - args='obs_selected.xml example_show_obs.eps') + args=self._datadir+'/obs_unbinned.xml ' + 'example_show_obs.eps') # Return return @@ -363,7 +394,7 @@ class Test(gammalib.GPythonTestSuite): if __name__ == '__main__': # Set calibration database - os.environ['CALDB'] = '../caldb' + os.environ['CALDB'] = '%s/caldb' % (os.environ['TEST_SRCDIR']) # Set PFILES environment variable try: @@ -373,8 +404,8 @@ if __name__ == '__main__': os.environ['PFILES'] = 'pfiles' # Copy over pfiles - os.system('cp -r ../src/*/*.par pfiles/') - os.system('cp -r ../cscripts/*.par pfiles/') + os.system('cp -r %s/src/*/*.par pfiles/' % (os.environ['TEST_SRCDIR'])) + os.system('cp -r %s/cscripts/*.par pfiles/' % (os.environ['TEST_SRCDIR'])) # Allocate test suites suites = gammalib.GTestSuites('Examples testing') diff --git a/test/test_pipelines.py b/test/test_pipelines.py index e684e52..2e50c1b 100755 --- a/test/test_pipelines.py +++ b/test/test_pipelines.py @@ -18,6 +18,7 @@ # along with this program. If not, see . # # ========================================================================== +import os import gammalib import ctools @@ -27,30 +28,40 @@ import ctools # ============================ # class Test(gammalib.GPythonTestSuite): """ - Test class for pipelines. + Test class for pipelines """ # Constructor def __init__(self): """ - Constructor. + Constructor """ # Call base class constructor gammalib.GPythonTestSuite.__init__(self) + # Set test data directory + self._datadir = os.environ['TEST_DATA'] + + # Set some standard test data + self._model = self._datadir + '/crab.xml' + self._caldb = 'prod2' + self._irf = 'South_0.5h' + # Return return # Set test functions def set(self): """ - Set all test functions. + Set all test functions """ # Set test name - self.name("pipelines") + self.name('pipelines') # Append tests - self.append(self.test_unbinned_fits, "Test unbinned pipeline with FITS file saving") - self.append(self.test_unbinned_mem, "Test unbinned in-memory pipeline") + self.append(self.test_unbinned_fits, + 'Test unbinned pipeline with FITS file saving') + self.append(self.test_unbinned_mem, + 'Test unbinned in-memory pipeline') # Return return @@ -58,15 +69,15 @@ class Test(gammalib.GPythonTestSuite): # Test unbinned pipeline with FITS file saving def test_unbinned_fits(self): """ - Test unbinned pipeline with FITS file saving. + Test unbinned pipeline with FITS file saving """ # Set script parameters - model_name = "data/crab.xml" - events_name = "events.fits" - selected_events_name = "selected_events.fits" - result_name = "results.xml" - caldb = "irf" - irf = "cta_dummy_irf" + model_name = self._model + events_name = 'events.fits' + selected_events_name = 'selected_events.fits' + result_name = 'results.xml' + caldb = self._caldb + irf = self._irf ra = 83.63 dec = 22.01 rad_sim = 10.0 @@ -78,116 +89,90 @@ class Test(gammalib.GPythonTestSuite): # Simulate events sim = ctools.ctobssim() - sim["inmodel"] = model_name - sim["outevents"] = events_name - sim["caldb"] = caldb - sim["irf"] = irf - sim["ra"] = ra - sim["dec"] = dec - sim["rad"] = rad_sim - sim["tmin"] = tstart - sim["tmax"] = tstop - sim["emin"] = emin - sim["emax"] = emax - self.test_try("Execute ctobssim") - try: - sim.execute() - self.test_try_success() - except: - self.test_try_failure("Exception occured in ctobssim.") + sim['inmodel'] = model_name + sim['outevents'] = events_name + sim['caldb'] = caldb + sim['irf'] = irf + sim['ra'] = ra + sim['dec'] = dec + sim['rad'] = rad_sim + sim['tmin'] = tstart + sim['tmax'] = tstop + sim['emin'] = emin + sim['emax'] = emax + sim.execute() # Select events select = ctools.ctselect() - select["inobs"] = events_name - select["outobs"] = selected_events_name - select["ra"] = ra - select["dec"] = dec - select["rad"] = rad_select - select["tmin"] = tstart - select["tmax"] = tstop - select["emin"] = emin - select["emax"] = emax - self.test_try("Execute ctselect") - try: - select.execute() - self.test_try_success() - except: - self.test_try_failure("Exception occured in ctselect.") + select['inobs'] = events_name + select['outobs'] = selected_events_name + select['ra'] = ra + select['dec'] = dec + select['rad'] = rad_select + select['tmin'] = tstart + select['tmax'] = tstop + select['emin'] = emin + select['emax'] = emax + select.execute() # Perform maximum likelihood fitting like = ctools.ctlike() - like["inobs"] = selected_events_name - like["inmodel"] = model_name - like["outmodel"] = result_name - like["caldb"] = caldb - like["irf"] = irf - self.test_try("Execute ctlike") - try: - like.execute() - self.test_try_success() - except: - self.test_try_failure("Exception occured in ctlike.") + like['inobs'] = selected_events_name + like['inmodel'] = model_name + like['outmodel'] = result_name + like['caldb'] = caldb + like['irf'] = irf + like.execute() + # Return + return # Test unbinned in-memory pipeline def test_unbinned_mem(self): """ - Test unbinned in-memory pipeline. + Test unbinned in-memory pipeline """ # Set script parameters - model_name = "data/crab.xml" - caldb = "irf" - irf = "cta_dummy_irf" - ra = 83.63 - dec = 22.01 - rad_sim = 10.0 - tstart = 0.0 - tstop = 1800.0 - emin = 0.1 - emax = 100.0 - rad_select = 3.0 + model_name = self._model + caldb = self._caldb + irf = self._irf + ra = 83.63 + dec = 22.01 + rad_sim = 10.0 + tstart = 0.0 + tstop = 1800.0 + emin = 0.1 + emax = 100.0 + rad_select = 3.0 # Simulate events sim = ctools.ctobssim() - sim["inmodel"] = model_name - sim["caldb"] = caldb - sim["irf"] = irf - sim["ra"] = ra - sim["dec"] = dec - sim["rad"] = rad_sim - sim["tmin"] = tstart - sim["tmax"] = tstop - sim["emin"] = emin - sim["emax"] = emax - self.test_try("Run ctobssim") - try: - sim.run() - self.test_try_success() - except: - self.test_try_failure("Exception occured in ctobssim.") + sim['inmodel'] = model_name + sim['caldb'] = caldb + sim['irf'] = irf + sim['ra'] = ra + sim['dec'] = dec + sim['rad'] = rad_sim + sim['tmin'] = tstart + sim['tmax'] = tstop + sim['emin'] = emin + sim['emax'] = emax + sim.run() # Select events select = ctools.ctselect(sim.obs()) - select["ra"] = ra - select["dec"] = dec - select["rad"] = rad_select - select["tmin"] = tstart - select["tmax"] = tstop - select["emin"] = emin - select["emax"] = emax + select['ra'] = ra + select['dec'] = dec + select['rad'] = rad_select + select['tmin'] = tstart + select['tmax'] = tstop + select['emin'] = emin + select['emax'] = emax select.run() - self.test_try("Run ctselect") - try: - select.run() - self.test_try_success() - except: - self.test_try_failure("Exception occured in ctselect.") # Perform maximum likelihood fitting like = ctools.ctlike(select.obs()) - self.test_try("Run ctlike") - try: - like.run() - self.test_try_success() - except: - self.test_try_failure("Exception occured in ctlike.") + like.run() + + # Return + return diff --git a/test/test_python_cscripts.py b/test/test_python_cscripts.py index 1a95303..e45161a 100755 --- a/test/test_python_cscripts.py +++ b/test/test_python_cscripts.py @@ -74,13 +74,16 @@ def test(installed=False, debug=False): dirname = os.path.dirname(testdir) # Copy over test data and irf - os.system('cp -r %s %s' % (dirname+'/data', 'data')) - os.system('cp -r %s %s' % (dirname+'/iactdata', 'iactdata')) - os.system('cp -r %s %s' % (dirname+'/irf', 'irf')) + os.system('cp -r %s %s' % (dirname+'/data', 'data')) - # ... otherwise set the calibration database + # Set test data environment variable + os.environ['TEST_DATA'] = 'data' + + # ... otherwise set the calibration database to the one shipped with the + # package; we don't need to set the 'TEST_DATA', this is done by the + # test environment else: - os.environ['CALDB'] = '../caldb' + os.environ['CALDB'] = '%s/caldb' % (os.environ['TEST_SRCDIR']) # Set PFILES environment variable try: @@ -91,9 +94,11 @@ def test(installed=False, debug=False): # Copy over pfiles if not installed: - os.system('cp -r ../cscripts/*.par pfiles/') + os.system('cp -r %s/cscripts/*.par pfiles/'% (os.environ['TEST_SRCDIR'])) + os.system('chmod u+w pfiles/*') else: os.system('cp -r %s/syspfiles/*.par pfiles/' % (os.environ['CTOOLS'])) + os.system('chmod u+w pfiles/*') # Allocate test suite container suites = gammalib.GTestSuites('cscripts unit testing') diff --git a/test/test_python_cscripts.sh.in b/test/test_python_cscripts.sh.in index 2d6f23c..aafcb09 100755 --- a/test/test_python_cscripts.sh.in +++ b/test/test_python_cscripts.sh.in @@ -22,4 +22,4 @@ # # Run the Python test # =================== -@PYTHON_COVERAGE@./test_python_cscripts.py +@PYTHON_COVERAGE@@srcdir@/test_python_cscripts.py diff --git a/test/test_python_ctools.py b/test/test_python_ctools.py index 92d6291..deec734 100755 --- a/test/test_python_ctools.py +++ b/test/test_python_ctools.py @@ -54,6 +54,10 @@ def test(installed=False): installed : bool, optional Flag indicating whether the script has been installed or not """ + # Set environment variables first + if installed: + os.environ['TEST_DATA'] = 'data' + # Allocate test suite container suites = gammalib.GTestSuites('ctools unit testing') @@ -130,7 +134,10 @@ def test(installed=False): # Copy over test data and irf os.system('cp -r %s %s' % (dirname+'/data', 'data')) - os.system('cp -r %s %s' % (dirname+'/irf', 'irf')) + + # ... otherwise set the calibration database + else: + os.environ['CALDB'] = '%s/caldb' % (os.environ['TEST_SRCDIR']) # Set PFILES environment variable try: @@ -141,9 +148,11 @@ def test(installed=False): # Copy over pfiles if not installed: - os.system('cp -r ../src/*/*.par pfiles/') + os.system('cp -r %s/src/*/*.par pfiles/' % (os.environ['TEST_SRCDIR'])) + os.system('chmod u+w pfiles/*') else: os.system('cp -r %s/syspfiles/*.par pfiles/' % (os.environ['CTOOLS'])) + os.system('chmod u+w pfiles/*') # Run test suite success = suites.run() diff --git a/test/test_python_ctools.sh.in b/test/test_python_ctools.sh.in index ed7cf0b..f3884c2 100755 --- a/test/test_python_ctools.sh.in +++ b/test/test_python_ctools.sh.in @@ -22,4 +22,4 @@ # # Run the Python test # =================== -@PYTHON_COVERAGE@./test_python_ctools.py +@PYTHON_COVERAGE@@srcdir@/test_python_ctools.py diff --git a/test/testing.py b/test/testing.py index be0bec3..78512cc 100755 --- a/test/testing.py +++ b/test/testing.py @@ -37,6 +37,17 @@ class test(gammalib.GPythonTestSuite): # Call base class constructor gammalib.GPythonTestSuite.__init__(self) + # Set test data directory + self._datadir = os.environ['TEST_DATA'] + + # Set some standard test data (additional test data will be set in + # the derived classes as needed) + self._events = self._datadir + '/crab_events.fits' + self._cntcube = self._datadir + '/crab_cntmap.fits' + self._model = self._datadir + '/crab.xml' + self._caldb = 'prod2' + self._irf = 'South_0.5h' + # Return return @@ -45,9 +56,11 @@ class test(gammalib.GPythonTestSuite): """ Set script name """ - # Kluge to set the command. The installed version has no README.md file - if os.path.isfile('README.md'): - script = '../cscripts/'+name+'.py' + # Set script name dependent on whether the software is installed or + # not. If the software is not installed the 'TEST_BUILDDIR' environment + # variable will exist + if 'TEST_BUILDDIR' in os.environ: + script = os.environ['TEST_BUILDDIR'] + '/cscripts/'+name+'.py' else: script = name @@ -59,9 +72,11 @@ class test(gammalib.GPythonTestSuite): """ Set tool name """ - # Kluge to set the command. The installed version has no README.md file - if os.path.isfile('README.md'): - tool = '../src/'+name+'/'+name + # Set tool name dependent on whether the software is installed or + # not. If the software is not installed the 'TEST_BUILDDIR' environment + # variable will exist + if 'TEST_BUILDDIR' in os.environ: + tool = os.environ['TEST_BUILDDIR'] + '/src/'+name+'/'+name else: tool = name