diff --git a/cscripts/csobs2caldb.py b/cscripts/csobs2caldb.py index 78e6e66..2c4df80 100755 --- a/cscripts/csobs2caldb.py +++ b/cscripts/csobs2caldb.py @@ -87,7 +87,7 @@ class csobs2caldb(ctools.cscript): pars = gammalib.GApplicationPars() pars.append(gammalib.GApplicationPar("inobs","f","a","obs.xml","","","Input observation definition file")) pars.append(gammalib.GApplicationPar("rspname","s","a","NONE","","","Response output name (e.g. Zenith50)")) - pars.append(gammalib.GApplicationPar("outfile","f","h","irf_file.fits","","","Output IRF file name")) + pars.append(gammalib.GApplicationPar("outirfs","f","h","irf_file.fits","","","Output IRF file name")) pars.append(gammalib.GApplicationPar("index","i","h","0","","","Index of observation to be used from XML file")) pars.append_standard() pars.append(gammalib.GApplicationPar("logfile","f","h","csobs2caldb.log","","","Log filename")) @@ -119,7 +119,7 @@ class csobs2caldb(ctools.cscript): # Get config and file name self.m_rspname = self["rspname"].string() - self.m_outfile = self["outfile"].filename() + self.m_outfile = self["outirfs"].filename() # Make sure we have a cta observation if not self.observation.classname() == "GCTAObservation": @@ -141,6 +141,9 @@ class csobs2caldb(ctools.cscript): # retrieve response component rsp = self.observation.response() + # Initialise FITS file + fits = gammalib.GFits() + # Open FITS files of response components fits_aeff = gammalib.GFits(rsp.aeff().filename()) fits_psf = gammalib.GFits(rsp.psf().filename()) @@ -148,7 +151,6 @@ class csobs2caldb(ctools.cscript): fits_bkg = gammalib.GFits(rsp.background().filename()) # Bundle IRFs into one file - fits = gammalib.GFits() fits.append(fits_aeff["EFFECTIVE AREA"]) fits.append(fits_psf["POINT SPREAD FUNCTION"]) fits.append(fits_edisp["ENERGY DISPERSION"]) diff --git a/doc/source/reference_manual/csobs2caldb.rst b/doc/source/reference_manual/csobs2caldb.rst new file mode 100644 index 0000000..0dfa3e7 --- /dev/null +++ b/doc/source/reference_manual/csobs2caldb.rst @@ -0,0 +1,72 @@ +.. _csobs2caldb: + +csobs2caldb +========== + +Creates a caldb entry from an input observation + + +Synopsis +-------- + +This script creates an entry in the local calibration database from an +input observation container. The caldb entry can be used for simulations +with :doc:`ctobssim` later on. On default csobs2caldb uses the first observation +in the given container. This can be modified using the hidden parameter "index" +(e.g. index=3) instructs the tool to use the third observation in the container. +Note that for the moment, the script only works for unbinned observations which +use the latest CTA IRF format (i.e. 2D/3D FITS binary tables). + +In particular this script might be useful for simulations of current IACT data. +Provided a specific observation with IRFs e.g. at certain zenith/azimuth angle, +the user can create a caldb entry using this tool and subsequently simulate e.g. +50 hours using this configuration. + +General parameters +------------------ + +``inobs [file]`` + Input event list, counts cube or observation definition XML file. + +``rspname [string]`` + Response output name (e.g. Zenith50). + +``(outirfs = irf_file.fits) [file]`` + Output IRF file name. + +``(index = 0) [integer]`` + Index of observation to be used from XML file. + + +Standard parameters +------------------- + +``(chatter = 2) [integer]`` + Verbosity of the executable: + chatter = 0: no information will be logged + + chatter = 1: only errors will be logged + + chatter = 2: errors and actions will be logged + + chatter = 3: report about the task execution + + chatter = 4: detailed report about the task execution + +``(clobber = yes) [boolean]`` + Specifies whether an existing output counts cube should be overwritten. + +``(debug = no) [boolean]`` + Enables debug mode. In debug mode the executable will dump any log file output to the console. + +``(mode = ql) [string]`` + Mode of automatic parameters (default is "ql", i.e. "query and learn"). + +``(logfile = csobs2caldb.log) [filename]`` + Log filename. + + +Related tools or scripts +------------------------ + +:doc:`cscaldb` diff --git a/test/data/obs_unbinned.xml b/test/data/obs_unbinned.xml new file mode 100644 index 0000000..79fb549 --- /dev/null +++ b/test/data/obs_unbinned.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/test/test_cscripts.sh.in b/test/test_cscripts.sh.in index 628c16e..234166b 100755 --- a/test/test_cscripts.sh.in +++ b/test/test_cscripts.sh.in @@ -46,7 +46,7 @@ rm -rf pfiles mkdir -p pfiles cp -r ../src/*/*.par pfiles/ export PFILES=pfiles - +export CALDB=$PWD # # Test csobsdef @@ -72,6 +72,24 @@ else 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 cspull @@ -82,8 +100,8 @@ chmod +x @abs_top_srcdir@/cscripts/cspull.py inmodel="data/crab.xml" \ outfile="pull.dat" \ ntrials="3" \ - caldb="irf" \ - irf="cta_dummy_irf" \ + caldb="cta" \ + irf="test_irfs" \ ra=83.6331 \ dec=22.0145 \ emin=0.1 \