Bug #2291
reading observations from list crashes when there is a blank line at end of a obsdef text file
Status: | In Progress | Start date: | 12/13/2017 | |
---|---|---|---|---|
Priority: | Normal | Due date: | ||
Assigned To: | Knödlseder Jürgen | % Done: | 0% | |
Category: | - | |||
Target version: | - | |||
Duration: |
Description
Hi,
I had a very annoying bug which costed my a lot of CPU time and circumvented all my tests: After going through a long list of observation definitions in a obsdef file according to
lgal,bgal,duration,caldb,irf
-180.0000,-32.0900,154.5330,prod3b,South_z20_average_5h
....
the event simulation crashed at the very end when trying to read in the last entry of the file which was a blank line in my case (the I/O routine apparently does not recognize if a line is completely empty).
I strongly recommend to fix this. I also recommend to comply with the standard to be allowed to mark comment lines with a leading hash, #. This also concerns reading in spectra from a file where it is not allowed to specify the columns in the file with a leading comment line (I did not test it with the newest gammalib version, though, maybe it has been already changed).
Here my exact error message obtained with ctools/gammalib version 1.4.3. The error occured in ctools’ obsutils, but I think it is a gammalib problem:
=⇒ simulate observation patch 2978
Number of observations in patch: 1
obsdeflist 0 : {'rad’: 6.0, 'emin’: 0.029999999999999999, 'emax’: 0.070000000000000007, 'duration’: nan, 'caldb’: nan, 'instrument’: 'CTA’, 'ra’: nan, 'deadc’: 0.94999999999999996, 'dec’: nan, 'irf’: nan}
File "/lustre/fs19/group/cta/users/mhuetten/workdata/IACT-anisotropy-simulation/17-12-12-DMandAstroSurvey500h_homExp_1deg/tautau/Inputfiles/subhaloFluctResponse.sim.py”, line 922, in <module>
main(sys.argv[1:])
File "/lustre/fs19/group/cta/users/mhuetten/workdata/IACT-anisotropy-simulation/17-12-12-DMandAstroSurvey500h_homExp_1deg/tautau/Inputfiles/subhaloFluctResponse.sim.py”, line 319, in main
observations = obsutils.set_obs_list(obsdeflist)
File "/afs/ifh.de/group/cta/scratch/mhuetten/CTA/ctools/lib64/python2.6/site-packages/cscripts/obsutils.py”, line 342, in set_obs_list
obsid=obsid)
File "/afs/ifh.de/group/cta/scratch/mhuetten/CTA/ctools/lib64/python2.6/site-packages/cscripts/obsutils.py”, line 224, in set_obs
if (gammalib.dir_exists(caldb)):
File "/afs/ifh.de/group/cta/scratch/mhuetten/CTA/gammalib/lib64/python2.6/site-packages/gammalib/support.py”, line 384, in dir_exists
return _support.dir_exists(*args)
TypeError: in method 'dir_exists’, argument 1 of type 'std::string const &'
Recurrence
No recurrence.
History
#1 Updated by Knödlseder Jürgen about 7 years ago
- Project changed from GammaLib to ctools
- Target version set to 1.5.0
#2 Updated by Knödlseder Jürgen almost 7 years ago
- Status changed from New to In Progress
- Assigned To set to Knödlseder Jürgen
I was not able to reproduce the problem with csobsdef
. Could you post your script and pointing definition file that produced the problem?
Running csobsdef
with
lgal,bgal,duration,caldb,irf -180.0000,-32.0900,154.5330,prod3b,South_z20_average_5h(including some blank lines) should produce
Traceback (most recent call last): File "/usr/local/gamma/bin/csobsdef", line 405, in <module> app.execute() File "/usr/local/gamma/lib/python2.7/site-packages/ctools/tools.py", line 1167, in _execute self.run() File "/usr/local/gamma/bin/csobsdef", line 242, in run raise RuntimeError('No (ra,dec) or (lon,lat) columns ' RuntimeError: No (ra,dec) or (lon,lat) columns found in pointing definition file.while running
csobsdef
withlon,lat,duration,caldb,irf -180.0000,-32.0900,154.5330,prod2,South_0.5h(including some blank lines) produces a valid output observation definition XML file.
#3 Updated by Knödlseder Jürgen almost 7 years ago
- Target version deleted (
1.5.0)