#! /bin/sh # ========================================================================== # This script tests all cscripts that are shipped with ctools # # Copyright (C) 2011-2015 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 # # Creates pfiles directory # ======================== export PFILES=pfiles export CALDB=$PWD/caldb rm -rf $PFILES mkdir -p $PFILES cp -r ../src/*/*.par pfiles/ rm -rf $CALDB mkdir -p $CALDB # # Test csobsdef # ============= $ECHO -n "Test csobsdef: " chmod +x @abs_top_srcdir@/cscripts/csobsdef.py @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 csobs2caldb # ================ $ECHO -n "Test csobs2caldb: " chmod +x @abs_top_srcdir@/cscripts/csobs2caldb.py @abs_top_srcdir@/cscripts/csobs2caldb.py \ inobs="data/obs_unbinned.xml" \ rspname="test_irfs" \ chatter=4 #> csobs2caldb.log $ECHO -n "." if [ -s "$CALDB/data/cta/cta/bcf/test_irfs/irf_file.fits" ] then $ECHO -n "." else $ECHO " $CALDB/data/cta/cta/bcf/test_irfs/irf_file.fits file is not valid" exit 1 fi $ECHO " ok" # # Test csobsinfo # ============== $ECHO -n "Test csobsinfo: " chmod +x @abs_top_srcdir@/cscripts/csobsinfo.py @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 csiactobs # ============== $ECHO -n "Test csiactobs: " chmod +x @abs_top_srcdir@/cscripts/csiactobs.py @abs_top_srcdir@/cscripts/csiactobs.py \ datapath="iactdata/" \ prodname="unit-test" \ runlistfile="iactdata/runlist.txt" \ 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" # # Test csmodelinfo # ================ $ECHO -n "Test csmodelinfo: " chmod +x @abs_top_srcdir@/cscripts/csmodelinfo.py @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 (space-separated) # =================================== $ECHO -n "Test csmodelmerge (space-separated): " chmod +x @abs_top_srcdir@/cscripts/csmodelmerge.py @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 $ECHO " ok" # # Test csmodelmerge (comma-separated) # =================================== $ECHO -n "Test csmodelmerge (comma-separated): " chmod +x @abs_top_srcdir@/cscripts/csmodelmerge.py @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 $ECHO " ok" # # Test csmodelmerge (wildcard string) # =================================== $ECHO -n "Test csmodelmerge (wildcard string): " chmod +x @abs_top_srcdir@/cscripts/csmodelmerge.py @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 $ECHO " ok" # # Test csmodelmerge (ascii-file) # ============================== ls data/model_cube_background* > models.txt $ECHO -n "Test csmodelmerge (ascii-file): " chmod +x @abs_top_srcdir@/cscripts/csmodelmerge.py @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 (comma-separated) # =================================== $ECHO -n "Test cstsmapmerge (comma-separated): " chmod +x @abs_top_srcdir@/cscripts/cstsmapmerge.py @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 $ECHO " ok" # # Test cstsmapmerge (space-separated) # =================================== $ECHO -n "Test cstsmapmerge (space-separated): " chmod +x @abs_top_srcdir@/cscripts/cstsmapmerge.py @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 $ECHO " ok" # # Test cstsmapmerge (wildcard string) # =================================== $ECHO -n "Test cstsmapmerge (wildcard string): " chmod +x @abs_top_srcdir@/cscripts/cstsmapmerge.py @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 $ECHO " ok" # # Test cstsmapmerge (ascii-file) # ============================== ls data/tsmap_*.fits > tsmaps.txt $ECHO -n "Test cstsmapmerge (ascii-file): " chmod +x @abs_top_srcdir@/cscripts/cstsmapmerge.py @abs_top_srcdir@/cscripts/cstsmapmerge.py \ inmaps="@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 @abs_top_srcdir@/cscripts/cspull.py \ inmodel="data/crab.xml" \ outfile="pull.dat" \ ntrials="3" \ caldb="cta" \ irf="test_irfs" \ 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 @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 @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 @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 (unbinned) # ===================== $ECHO -n "Test csspec (unbinned): " chmod +x @abs_top_srcdir@/cscripts/csspec.py @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 $ECHO " ok" # # Test csspec (binned) # ==================== $ECHO -n "Test csspec (binned): " chmod +x @abs_top_srcdir@/cscripts/csspec.py @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" \ 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 (unbinned) # ========================== $ECHO -n "Test cslightcrv (unbinned): " chmod +x @abs_top_srcdir@/cscripts/cslightcrv.py @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 $ECHO " ok" # # Test cslightcrv (binned) # ======================== $ECHO -n "Test cslightcrv (binned): " chmod +x @abs_top_srcdir@/cscripts/cslightcrv.py @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"