Bug #1463

ctselect throws RuntimeError on runs where fits EVENTS table has 0 events

Added by Kelley-Hoskins Nathan almost 9 years ago. Updated almost 9 years ago.

Status:ClosedStart date:05/19/2015
Priority:HighDue date:
Assigned To:Knödlseder Jürgen% Done:

100%

Category:-
Target version:1.0.0
Duration:

Description

When a fits file with zero events in the EVENTS table is passed to ctselect, it throws a RuntimeError, and complains about missing columns from ctselect’s temporary fits file. The example script below, combined with the attached 'noevents.fits’, reproduces this error.

test_script.py:

#!/usr/bin/python
import gammalib, ctools

filename = 'noevents.fits'

obs = gammalib.GObservations()
run = gammalib.GCTAObservation('VERITAS')
run.load( filename )
obs.append( run )

sel = ctools.ctselect(obs)
sel['usepnt'].boolean(False)
sel['ra'    ].real(0.0)
sel['dec'   ].real(0.0)
sel['rad'   ].real(180.0)
sel['tmin'  ].real(0.0)
sel['tmax'  ].real(0.0)
sel['emin'  ].real(   0.3 )
sel['emax'  ].real( 100.0 )
sel.run()

I get the following error:

$ python test_script.py
Traceback (most recent call last):
  File "./test_script.py", line 20, in <module>
    sel.run()
  File "/afs/ifh.de/user/n/nkelhos/scratch/ctools/ctools-git/lib64/python2.6/site-packages/ctools/tools.py", line 522, in run
    return _tools.ctselect_run(self)
RuntimeError: *** ERROR in ctselect::run(): The following columns are missing in the "EVENTS" extension of input file "": "TIME", "ENERGY", "RA", "DEC" 

I break up each 20 minute veritas data run into multiple event lists, so that I can give more precise IRFs to each event list. But, this means that some of these event lists only cover 1-2 seconds of a run, and often won’t have any events, so the EVENTS table will have 0 rows. I’ve encountered this problem at least 4 times in 100 or so runs, so its a fairly disruptive bug.

The error pops up in ctselect::check_infile(), which calls on GFitsTable::contains(), which relies on GFitsTable::ptr_column(), which reads from GFitsTable::m_columns. Beyond that, I’m not sure why GFitsTable::m_columns is empty during ctselect::run().

noevents.fits (16.9 KB) Kelley-Hoskins Nathan, 05/19/2015 06:45 PM


Recurrence

No recurrence.

History

#1 Updated by Knödlseder Jürgen almost 9 years ago

Thanks for reporting this. I guess the solution would be to check fir if there are events, and abort ctselect silently if no events are comprised in the event file. Would this be okay for you or would you expect that ctselect writes out an empty event file?

#2 Updated by Kelley-Hoskins Nathan almost 9 years ago

I’m not sure I have a strong preference, since I mostly use ctselect within python scripts, rather than doing stuff with ctselect’s output fits file.

An empty file might still be useful, since even without events, its GTI would still keep track of detector live time. In not writing the file, I think we’d be throwing out that valid observing time, even if it is only a few seconds.

A warning (or something weaker-sounding) might be printed if ctselect ends up with 0 events, to let the user know of this unusual situation.

#3 Updated by Knödlseder Jürgen almost 9 years ago

  • Assigned To set to Knödlseder Jürgen

I agree that writing out an empty file would be a consistent ctselect behaviour. Of course, a warning will be written to the log file that the input file was empty.

#4 Updated by Knödlseder Jürgen almost 9 years ago

  • Status changed from New to Closed
  • Target version set to 1.0.0
  • % Done changed from 0 to 100

ctselect now checks prior to processing whether the event file is empty. If it’s empty it will be written out as is.

The change has been merged into devel.

Also available in: Atom PDF