From df492129c12c9bdd790c7a7960eee3e2999194cb Mon Sep 17 00:00:00 2001 From: Michael Mayer Date: Thu, 25 Feb 2016 20:29:49 +0100 Subject: [PATCH] Added minor improvements to two cscripts --- cscripts/csiactdata.py | 25 +++++++++++++++++++++++-- cscripts/csiactobs.py | 19 +++++++++++++++++++ 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/cscripts/csiactdata.py b/cscripts/csiactdata.py index 9d7aa08..d00f5e2 100755 --- a/cscripts/csiactdata.py +++ b/cscripts/csiactdata.py @@ -163,8 +163,11 @@ class csiactdata(ctools.cscript): hdu = os.path.join(self.datapath, config["hduindx"]) obs = os.path.join(self.datapath, config["obsindx"]) + filename_hdu = gammalib.GFilename(str(hdu)+"[HDU_INDEX]") + filename_obs = gammalib.GFilename(str(obs)+"[OBS_INDEX]") + # Check if index files are available - if not (gammalib.is_fits(str(hdu)) and gammalib.is_fits(str(obs))): + if not (filename_hdu.is_fits() and filename_obs.is_fits()): self.log.parformat(str(config["name"])) self.log("Not available") self.log("\n") @@ -180,13 +183,31 @@ class csiactdata(ctools.cscript): hdu = os.path.join(self.datapath, config["hduindx"]) obs = os.path.join(self.datapath, config["obsindx"]) + filename_hdu = gammalib.GFilename(str(hdu)+"[HDU_INDEX]") + filename_obs = gammalib.GFilename(str(obs)+"[OBS_INDEX]") + # Check if index files are available - if gammalib.is_fits(str(hdu)) and gammalib.is_fits(str(obs)): + if (filename_hdu.is_fits() and filename_obs.is_fits()): # Log data information self.log("\n") self.log.header3(str(config["name"])) + + # Print important informations first + self.log.parformat("Name") + self.log(str(config["name"])) + self.log("\n") + self.log.parformat("Observation index") + self.log(str(config["obsindx"])) + self.log("\n") + self.log.parformat("HDU index") + self.log(str(config["hduindx"])) + self.log("\n") + + # Print additional information for key in config: + if key in ["name","hduindx","obsindx"]: + continue self.log.parformat(str(key)) self.log(str(config[key])) self.log("\n") diff --git a/cscripts/csiactobs.py b/cscripts/csiactobs.py index a4af0d5..452a446 100755 --- a/cscripts/csiactobs.py +++ b/cscripts/csiactobs.py @@ -220,6 +220,25 @@ class csiactobs(ctools.cscript): # Return return + def runlist(self, runlist): + """ + Set observation list + """ + + # Type check + if isinstance(runlist, list): + + # Store a copy of input argument + self.runlist = list(runlist) + + else: + + # raise error if wrong type detected + raise RuntimeError("Argument of csiactobs.runlist() must be of type 'list'") + + # Return + return + def background_spectrum(self, run, prefactor, index, emin = 0.01, emax = 100.0): # Handle constant spectral model -- libgit2 0.21.4