From 71cb52641493fc4788cbe06a9c57d395cc4e53b8 Mon Sep 17 00:00:00 2001 From: Jürgen Knödlseder Date: Tue, 16 Feb 2016 17:38:05 +0100 Subject: [PATCH] GApplicationPar::filename() now returns GFilename instead of std::string. --- cscripts/csfindobs.py | 6 +++--- cscripts/csiactcopy.py | 9 +++++---- cscripts/csiactobs.py | 17 ++++++++--------- cscripts/csmodelinfo.py | 4 ++-- cscripts/csobsinfo.py | 4 ++-- cscripts/cspull.py | 6 +++--- cscripts/cssens.py | 4 ++-- cscripts/cstsdist.py | 6 +++--- 8 files changed, 28 insertions(+), 28 deletions(-) diff --git a/cscripts/csfindobs.py b/cscripts/csfindobs.py index ffd8481..ee03563 100755 --- a/cscripts/csfindobs.py +++ b/cscripts/csfindobs.py @@ -287,12 +287,12 @@ class csfindobs(ctools.cscript): def save(self, outfile): # Check for clobber - if os.path.isfile(outfile) and not self.clobber(): - self.log("File "+outfile+" already exists. Set clobber=yes to overwrite file") + if outfile.exists() and not self.clobber(): + self.log("File "+outfile.url()+" already exists. Set clobber=yes to overwrite file") self.log("\n") else: # Write runs to file - f = open(outfile,"w") + f = open(outfile.url(),"w") for run in self.runs: f.write(str(run)+" \n") f.close() diff --git a/cscripts/csiactcopy.py b/cscripts/csiactcopy.py index 6177b3f..f43d040 100755 --- a/cscripts/csiactcopy.py +++ b/cscripts/csiactcopy.py @@ -103,9 +103,10 @@ class csiactcopy(ctools.cscript): """ # Get Parameters - self.m_remote_master = gammalib.expand_env(self["remote_master"].filename()) - if not os.path.isfile(self.m_remote_master): - 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") + self.m_remote_master = self["remote_master"].filename() + #if not os.path.isfile(self.m_remote_master): + if not self.m_remote_master.exists(): + 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") # Get parameters self.m_prodname = self["prodname"].string() @@ -153,7 +154,7 @@ class csiactcopy(ctools.cscript): self.runlist = [] # Check if runlist file is available - if os.path.isfile(self.m_runlist): + if self.m_runlist.exists(): runfile = open(self.m_runlist) for line in runfile.readlines(): if len(line) == 0: diff --git a/cscripts/csiactobs.py b/cscripts/csiactobs.py index 86683ed..a4af0d5 100755 --- a/cscripts/csiactobs.py +++ b/cscripts/csiactobs.py @@ -2,7 +2,7 @@ # ========================================================================== # Generation of an IACT observation definition file. # -# Copyright (C) 2015 Michael Mayer +# Copyright (C) 2015-2016 Michael Mayer # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -138,7 +138,7 @@ class csiactobs(ctools.cscript): # Read user parameters self.m_prodname = self["prodname"].string() - self.m_runlistfile = gammalib.expand_env(self["infile"].filename()) + self.m_runlistfile = self["infile"].filename() self.m_bkgpars = self["bkgpars"].integer() # Output model file @@ -288,16 +288,15 @@ class csiactobs(ctools.cscript): prefactor = 1.0 index = 0.0 prefactor *= bkg_scale - spec = self.background_spectrum(obs_id, prefactor, index, emin, emax) + spec = self.background_spectrum(obs_id, prefactor, index, emin, emax) # Create background model instance bck = gammalib.GCTAModelIrfBackground(spec) # Set AeffBackground elif bkgtype == "aeff": - prefactor = bkg_scale * self.m_bkg_aeff_norm - spec = self.background_spectrum(obs_id, prefactor, self.m_bkg_aeff_index, emin, emax) + spec = self.background_spectrum(obs_id, prefactor, self.m_bkg_aeff_index, emin, emax) # Create background model instance bck = gammalib.GCTAModelAeffBackground(spec) @@ -393,7 +392,7 @@ class csiactobs(ctools.cscript): # Read runlist from file runlist = [] - runfile = open(self.m_runlistfile) + runfile = open(self.m_runlistfile.url()) for line in runfile.readlines(): if len(line) == 0: continue @@ -420,12 +419,12 @@ class csiactobs(ctools.cscript): obs_selection = "[OBS_ID=="+str(obs_id)+"]" # Open HDU index file - hduindx = gammalib.GFits(self.m_hdu_index+"[HDU_INDEX]"+obs_selection) + hduindx = gammalib.GFits(self.m_hdu_index+"[HDU_INDEX]"+obs_selection) hduindx_hdu = hduindx["HDU_INDEX"] # Initialise files and hdu names eventfile = aefffile = psffile = edispfile = bkgfile = "" - eventhdu = aeffhdu = "" + eventhdu = aeffhdu = "" types = [] formats = [] @@ -533,7 +532,7 @@ class csiactobs(ctools.cscript): fits.close() # Open effective area file to look for threshold - aeff_fits = gammalib.GFits(aefffile) + aeff_fits = gammalib.GFits(aefffile) aeff_table = aeff_fits[aeffhdu] # Set energy range from header keyword if present diff --git a/cscripts/csmodelinfo.py b/cscripts/csmodelinfo.py index 0cb4e4d..0e61b6b 100755 --- a/cscripts/csmodelinfo.py +++ b/cscripts/csmodelinfo.py @@ -2,7 +2,7 @@ # ========================================================================== # Dump information about models into log file # -# Copyright (C) 2015 Michael Mayer +# Copyright (C) 2015-2016 Michael Mayer # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -329,7 +329,7 @@ class csmodelinfo(ctools.cscript): self.log.header1("Save region file") # Open file - f = open(self.ds9file,"w") + f = open(self.ds9file.url(),"w") # Write coordinate system f.write("fk5\n") diff --git a/cscripts/csobsinfo.py b/cscripts/csobsinfo.py index c438563..585e784 100755 --- a/cscripts/csobsinfo.py +++ b/cscripts/csobsinfo.py @@ -2,7 +2,7 @@ # ========================================================================== # Dump information about observation into log file # -# Copyright (C) 2015 Michael Mayer +# Copyright (C) 2015-2016 Michael Mayer # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -381,7 +381,7 @@ class csobsinfo(ctools.cscript): if not self.ds9file == "NONE": # Open file - f = open(self.ds9file,"w") + f = open(self.ds9file.url(),"w") # Write coordinate system f.write("fk5\n") diff --git a/cscripts/cspull.py b/cscripts/cspull.py index 70be19c..726c526 100755 --- a/cscripts/cspull.py +++ b/cscripts/cspull.py @@ -2,7 +2,7 @@ # ========================================================================== # This script generates the pull distribution for all model parameters. # -# Copyright (C) 2011-2015 Juergen Knoedlseder +# Copyright (C) 2011-2016 Juergen Knoedlseder # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -319,11 +319,11 @@ class cspull(ctools.cscript): # Write out result immediately if seed == 0: - file = open(self.m_outfile, 'w') + file = open(self.m_outfile.url(), 'w') writer = csv.DictWriter(file, result['colnames']) writer.writerow(dict((_,_) for _ in result['colnames'])) else: - file = open(self.m_outfile, 'a') + file = open(self.m_outfile.url(), 'a') writer = csv.DictWriter(file, result['colnames']) writer.writerow(result['values']) file.close() diff --git a/cscripts/cssens.py b/cscripts/cssens.py index a0a12ae..e7c6c56 100755 --- a/cscripts/cssens.py +++ b/cscripts/cssens.py @@ -249,13 +249,13 @@ class cssens(ctools.cscript): # Write results if ieng == 0: - f = open(self.m_outfile, 'w') + f = open(self.m_outfile.url(), 'w') writer = csv.DictWriter(f, colnames) writer.writerow(dict((_,_) for _ in colnames)) writer.writerow(result) f.close() else: - f = open(self.m_outfile, 'a') + f = open(self.m_outfile.url(), 'a') writer = csv.DictWriter(f, colnames) writer.writerow(result) f.close() diff --git a/cscripts/cstsdist.py b/cscripts/cstsdist.py index c4b2b49..72dc384 100755 --- a/cscripts/cstsdist.py +++ b/cscripts/cstsdist.py @@ -3,7 +3,7 @@ # This script generates the TS distribution for a particular model based # on Monte-Carlo simulations. # -# Copyright (C) 2011-2015 Juergen Knoedlseder +# Copyright (C) 2011-2016 Juergen Knoedlseder # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -249,11 +249,11 @@ class cstsdist(ctools.cscript): # Write out result immediately if seed == 0: - file = open(self.m_outfile, 'w') + file = open(self.m_outfile.url(), 'w') writer = csv.DictWriter(file, result['colnames']) writer.writerow(dict((_,_) for _ in result['colnames'])) else: - file = open(self.m_outfile, 'a') + file = open(self.m_outfile.url(), 'a') writer = csv.DictWriter(file, result['colnames']) writer.writerow(result['values']) file.close() -- libgit2 0.21.4