Commit 9612ec5726cf97e96b6f6d4de2bc06ce4e49798b
1 parent
3af8c312
Added support to handle GTIs in a separate file in ctselect. Added a test case for this purpose
Showing
3 changed files
with
46 additions
and
0 deletions
src/ctselect/ctselect.cpp
| @@ -1284,6 +1284,17 @@ void ctselect::save_event_list(const GCTAObservation* obs, | @@ -1284,6 +1284,17 @@ void ctselect::save_event_list(const GCTAObservation* obs, | ||
| 1284 | // Save observation into FITS file | 1284 | // Save observation into FITS file |
| 1285 | obs->save(outfile, clobber()); | 1285 | obs->save(outfile, clobber()); |
| 1286 | 1286 | ||
| 1287 | + // If separate GTI file was present than create new filename | ||
| 1288 | + // and save to new file | ||
| 1289 | + if (!obs->gtifile().empty()) { | ||
| 1290 | + | ||
| 1291 | + // Set event output file name | ||
| 1292 | + std::string outgti = set_outfile_name(obs->gtifile()); | ||
| 1293 | + | ||
| 1294 | + // Save GTI extension to different file | ||
| 1295 | + obs->save_gti(outgti, true); | ||
| 1296 | + } | ||
| 1297 | + | ||
| 1287 | // Copy all extensions other than EVENTS and GTI from the input to | 1298 | // Copy all extensions other than EVENTS and GTI from the input to |
| 1288 | // the output event list. The EVENTS and GTI extensions are written | 1299 | // the output event list. The EVENTS and GTI extensions are written |
| 1289 | // by the save method, all others that may eventually be present | 1300 | // by the save method, all others that may eventually be present |
test/data/obs_unbinned_gti.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
| 2 | +<observation_list title="observation list"> | ||
| 3 | + <observation name="" id="00001" instrument="CTA"> | ||
| 4 | + <parameter name="EventList" file="data/crab_events.fits" /> | ||
| 5 | + <parameter name="GoodTimeIntervals" file="data/crab_events.fits" /> | ||
| 6 | + <parameter name="EffectiveArea" file="irf/irf_file.fits" /> | ||
| 7 | + <parameter name="PointSpreadFunction" file="irf/irf_file.fits" /> | ||
| 8 | + <parameter name="EnergyDispersion" file="irf/irf_file.fits" /> | ||
| 9 | + <parameter name="Background" file="irf/irf_file.fits" /> | ||
| 10 | + </observation> | ||
| 11 | +</observation_list> |
test/test_ctools.sh
| @@ -443,6 +443,30 @@ $ECHO " ok" | @@ -443,6 +443,30 @@ $ECHO " ok" | ||
| 443 | 443 | ||
| 444 | 444 | ||
| 445 | # | 445 | # |
| 446 | +# Test ctselect (XML file) | ||
| 447 | +# ======================== | ||
| 448 | +$ECHO -n "Test ctselect (observation XML file): " | ||
| 449 | +$ctselect inobs="data/obs_unbinned_gti.xml" \ | ||
| 450 | +outobs="selected_obs.xml" \ | ||
| 451 | +ra=83.63 \ | ||
| 452 | +dec=22.01 \ | ||
| 453 | +rad=10.0 \ | ||
| 454 | +tmin=0.0 \ | ||
| 455 | +tmax=1800.0 \ | ||
| 456 | +emin=0.1 \ | ||
| 457 | +emax=100.0 | ||
| 458 | +$ECHO -n "." | ||
| 459 | +if [ -s "selected_obs.xml" ] | ||
| 460 | +then | ||
| 461 | +$ECHO -n "." | ||
| 462 | +else | ||
| 463 | +$ECHO " selected_obs.xml file is not found" | ||
| 464 | +exit 1 | ||
| 465 | +fi | ||
| 466 | +$ECHO " ok" | ||
| 467 | + | ||
| 468 | + | ||
| 469 | +# | ||
| 446 | # Test ctlike | 470 | # Test ctlike |
| 447 | # =========== | 471 | # =========== |
| 448 | $ECHO -n "Test ctlike: " | 472 | $ECHO -n "Test ctlike: " |