From 9612ec5726cf97e96b6f6d4de2bc06ce4e49798b Mon Sep 17 00:00:00 2001 From: Michael Mayer Date: Tue, 12 Jan 2016 13:53:11 +0100 Subject: [PATCH] Added support to handle GTIs in a separate file in ctselect. Added a test case for this purpose --- src/ctselect/ctselect.cpp | 11 +++++++++++ test/data/obs_unbinned_gti.xml | 11 +++++++++++ test/test_ctools.sh | 24 ++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 0 deletions(-) create mode 100644 test/data/obs_unbinned_gti.xml diff --git a/src/ctselect/ctselect.cpp b/src/ctselect/ctselect.cpp index 3fb27fd..346514e 100644 --- a/src/ctselect/ctselect.cpp +++ b/src/ctselect/ctselect.cpp @@ -1284,6 +1284,17 @@ void ctselect::save_event_list(const GCTAObservation* obs, // Save observation into FITS file obs->save(outfile, clobber()); + // If separate GTI file was present than create new filename + // and save to new file + if (!obs->gtifile().empty()) { + + // Set event output file name + std::string outgti = set_outfile_name(obs->gtifile()); + + // Save GTI extension to different file + obs->save_gti(outgti, true); + } + // Copy all extensions other than EVENTS and GTI from the input to // the output event list. The EVENTS and GTI extensions are written // by the save method, all others that may eventually be present diff --git a/test/data/obs_unbinned_gti.xml b/test/data/obs_unbinned_gti.xml new file mode 100644 index 0000000..a13b06d --- /dev/null +++ b/test/data/obs_unbinned_gti.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/test/test_ctools.sh b/test/test_ctools.sh index a730162..78e3793 100755 --- a/test/test_ctools.sh +++ b/test/test_ctools.sh @@ -443,6 +443,30 @@ $ECHO " ok" # +# Test ctselect (XML file) +# ======================== +$ECHO -n "Test ctselect (observation XML file): " +$ctselect inobs="data/obs_unbinned_gti.xml" \ +outobs="selected_obs.xml" \ +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_obs.xml" ] +then +$ECHO -n "." +else +$ECHO " selected_obs.xml file is not found" +exit 1 +fi +$ECHO " ok" + + +# # Test ctlike # =========== $ECHO -n "Test ctlike: " -- libgit2 0.21.4