Commit 71cb52641493fc4788cbe06a9c57d395cc4e53b8

Authored by Jürgen Knödlseder
1 parent c5a2d15f

GApplicationPar::filename() now returns GFilename instead of std::string.

cscripts/csfindobs.py
... ... @@ -287,12 +287,12 @@ class csfindobs(ctools.cscript):
287 287 def save(self, outfile):
288 288  
289 289 # Check for clobber
290   - if os.path.isfile(outfile) and not self.clobber():
291   - self.log("File "+outfile+" already exists. Set clobber=yes to overwrite file")
  290 + if outfile.exists() and not self.clobber():
  291 + self.log("File "+outfile.url()+" already exists. Set clobber=yes to overwrite file")
292 292 self.log("\n")
293 293 else:
294 294 # Write runs to file
295   - f = open(outfile,"w")
  295 + f = open(outfile.url(),"w")
296 296 for run in self.runs:
297 297 f.write(str(run)+" \n")
298 298 f.close()
... ...
cscripts/csiactcopy.py
... ... @@ -103,9 +103,10 @@ class csiactcopy(ctools.cscript):
103 103 """
104 104  
105 105 # Get Parameters
106   - self.m_remote_master = gammalib.expand_env(self["remote_master"].filename())
107   - if not os.path.isfile(self.m_remote_master):
108   - raise RuntimeError("*** ERROR: FITS data not available. No master index file found in \""+self.m_remote_master+"\". Make sure remote file system is properly mounted")
  106 + self.m_remote_master = self["remote_master"].filename()
  107 + #if not os.path.isfile(self.m_remote_master):
  108 + if not self.m_remote_master.exists():
  109 + raise RuntimeError("*** ERROR: FITS data not available. No master index file found in \""+self.m_remote_master.url()+"\". Make sure remote file system is properly mounted")
109 110  
110 111 # Get parameters
111 112 self.m_prodname = self["prodname"].string()
... ... @@ -153,7 +154,7 @@ class csiactcopy(ctools.cscript):
153 154 self.runlist = []
154 155  
155 156 # Check if runlist file is available
156   - if os.path.isfile(self.m_runlist):
  157 + if self.m_runlist.exists():
157 158 runfile = open(self.m_runlist)
158 159 for line in runfile.readlines():
159 160 if len(line) == 0:
... ...
cscripts/csiactobs.py
... ... @@ -2,7 +2,7 @@
2 2 # ==========================================================================
3 3 # Generation of an IACT observation definition file.
4 4 #
5   -# Copyright (C) 2015 Michael Mayer
  5 +# Copyright (C) 2015-2016 Michael Mayer
6 6 #
7 7 # This program is free software: you can redistribute it and/or modify
8 8 # it under the terms of the GNU General Public License as published by
... ... @@ -138,7 +138,7 @@ class csiactobs(ctools.cscript):
138 138  
139 139 # Read user parameters
140 140 self.m_prodname = self["prodname"].string()
141   - self.m_runlistfile = gammalib.expand_env(self["infile"].filename())
  141 + self.m_runlistfile = self["infile"].filename()
142 142 self.m_bkgpars = self["bkgpars"].integer()
143 143  
144 144 # Output model file
... ... @@ -288,16 +288,15 @@ class csiactobs(ctools.cscript):
288 288 prefactor = 1.0
289 289 index = 0.0
290 290 prefactor *= bkg_scale
291   - spec = self.background_spectrum(obs_id, prefactor, index, emin, emax)
  291 + spec = self.background_spectrum(obs_id, prefactor, index, emin, emax)
292 292  
293 293 # Create background model instance
294 294 bck = gammalib.GCTAModelIrfBackground(spec)
295 295  
296 296 # Set AeffBackground
297 297 elif bkgtype == "aeff":
298   -
299 298 prefactor = bkg_scale * self.m_bkg_aeff_norm
300   - spec = self.background_spectrum(obs_id, prefactor, self.m_bkg_aeff_index, emin, emax)
  299 + spec = self.background_spectrum(obs_id, prefactor, self.m_bkg_aeff_index, emin, emax)
301 300  
302 301 # Create background model instance
303 302 bck = gammalib.GCTAModelAeffBackground(spec)
... ... @@ -393,7 +392,7 @@ class csiactobs(ctools.cscript):
393 392  
394 393 # Read runlist from file
395 394 runlist = []
396   - runfile = open(self.m_runlistfile)
  395 + runfile = open(self.m_runlistfile.url())
397 396 for line in runfile.readlines():
398 397 if len(line) == 0:
399 398 continue
... ... @@ -420,12 +419,12 @@ class csiactobs(ctools.cscript):
420 419 obs_selection = "[OBS_ID=="+str(obs_id)+"]"
421 420  
422 421 # Open HDU index file
423   - hduindx = gammalib.GFits(self.m_hdu_index+"[HDU_INDEX]"+obs_selection)
  422 + hduindx = gammalib.GFits(self.m_hdu_index+"[HDU_INDEX]"+obs_selection)
424 423 hduindx_hdu = hduindx["HDU_INDEX"]
425 424  
426 425 # Initialise files and hdu names
427 426 eventfile = aefffile = psffile = edispfile = bkgfile = ""
428   - eventhdu = aeffhdu = ""
  427 + eventhdu = aeffhdu = ""
429 428  
430 429 types = []
431 430 formats = []
... ... @@ -533,7 +532,7 @@ class csiactobs(ctools.cscript):
533 532 fits.close()
534 533  
535 534 # Open effective area file to look for threshold
536   - aeff_fits = gammalib.GFits(aefffile)
  535 + aeff_fits = gammalib.GFits(aefffile)
537 536 aeff_table = aeff_fits[aeffhdu]
538 537  
539 538 # Set energy range from header keyword if present
... ...
cscripts/csmodelinfo.py
... ... @@ -2,7 +2,7 @@
2 2 # ==========================================================================
3 3 # Dump information about models into log file
4 4 #
5   -# Copyright (C) 2015 Michael Mayer
  5 +# Copyright (C) 2015-2016 Michael Mayer
6 6 #
7 7 # This program is free software: you can redistribute it and/or modify
8 8 # it under the terms of the GNU General Public License as published by
... ... @@ -329,7 +329,7 @@ class csmodelinfo(ctools.cscript):
329 329 self.log.header1("Save region file")
330 330  
331 331 # Open file
332   - f = open(self.ds9file,"w")
  332 + f = open(self.ds9file.url(),"w")
333 333  
334 334 # Write coordinate system
335 335 f.write("fk5\n")
... ...
cscripts/csobsinfo.py
... ... @@ -2,7 +2,7 @@
2 2 # ==========================================================================
3 3 # Dump information about observation into log file
4 4 #
5   -# Copyright (C) 2015 Michael Mayer
  5 +# Copyright (C) 2015-2016 Michael Mayer
6 6 #
7 7 # This program is free software: you can redistribute it and/or modify
8 8 # it under the terms of the GNU General Public License as published by
... ... @@ -381,7 +381,7 @@ class csobsinfo(ctools.cscript):
381 381 if not self.ds9file == "NONE":
382 382  
383 383 # Open file
384   - f = open(self.ds9file,"w")
  384 + f = open(self.ds9file.url(),"w")
385 385  
386 386 # Write coordinate system
387 387 f.write("fk5\n")
... ...
cscripts/cspull.py
... ... @@ -2,7 +2,7 @@
2 2 # ==========================================================================
3 3 # This script generates the pull distribution for all model parameters.
4 4 #
5   -# Copyright (C) 2011-2015 Juergen Knoedlseder
  5 +# Copyright (C) 2011-2016 Juergen Knoedlseder
6 6 #
7 7 # This program is free software: you can redistribute it and/or modify
8 8 # it under the terms of the GNU General Public License as published by
... ... @@ -319,11 +319,11 @@ class cspull(ctools.cscript):
319 319  
320 320 # Write out result immediately
321 321 if seed == 0:
322   - file = open(self.m_outfile, 'w')
  322 + file = open(self.m_outfile.url(), 'w')
323 323 writer = csv.DictWriter(file, result['colnames'])
324 324 writer.writerow(dict((_,_) for _ in result['colnames']))
325 325 else:
326   - file = open(self.m_outfile, 'a')
  326 + file = open(self.m_outfile.url(), 'a')
327 327 writer = csv.DictWriter(file, result['colnames'])
328 328 writer.writerow(result['values'])
329 329 file.close()
... ...
cscripts/cssens.py
... ... @@ -249,13 +249,13 @@ class cssens(ctools.cscript):
249 249  
250 250 # Write results
251 251 if ieng == 0:
252   - f = open(self.m_outfile, 'w')
  252 + f = open(self.m_outfile.url(), 'w')
253 253 writer = csv.DictWriter(f, colnames)
254 254 writer.writerow(dict((_,_) for _ in colnames))
255 255 writer.writerow(result)
256 256 f.close()
257 257 else:
258   - f = open(self.m_outfile, 'a')
  258 + f = open(self.m_outfile.url(), 'a')
259 259 writer = csv.DictWriter(f, colnames)
260 260 writer.writerow(result)
261 261 f.close()
... ...
cscripts/cstsdist.py
... ... @@ -3,7 +3,7 @@
3 3 # This script generates the TS distribution for a particular model based
4 4 # on Monte-Carlo simulations.
5 5 #
6   -# Copyright (C) 2011-2015 Juergen Knoedlseder
  6 +# Copyright (C) 2011-2016 Juergen Knoedlseder
7 7 #
8 8 # This program is free software: you can redistribute it and/or modify
9 9 # it under the terms of the GNU General Public License as published by
... ... @@ -249,11 +249,11 @@ class cstsdist(ctools.cscript):
249 249  
250 250 # Write out result immediately
251 251 if seed == 0:
252   - file = open(self.m_outfile, 'w')
  252 + file = open(self.m_outfile.url(), 'w')
253 253 writer = csv.DictWriter(file, result['colnames'])
254 254 writer.writerow(dict((_,_) for _ in result['colnames']))
255 255 else:
256   - file = open(self.m_outfile, 'a')
  256 + file = open(self.m_outfile.url(), 'a')
257 257 writer = csv.DictWriter(file, result['colnames'])
258 258 writer.writerow(result['values'])
259 259 file.close()
... ...