diff --git a/cscripts/csiactobs.py b/cscripts/csiactobs.py index 0972e35..1bf704a 100755 --- a/cscripts/csiactobs.py +++ b/cscripts/csiactobs.py @@ -85,6 +85,10 @@ class csiactobs(ctools.cscript): # Initialise application by calling the appropriate class constructor self._init_cscript(argv) + # Append an observation list to XML instance + self._xml.append(gammalib.GXmlElement('observation_list title="observation list"')) + self._xml_obslist = self._xml.element('observation_list', 0) + # Return return @@ -559,12 +563,7 @@ class csiactobs(ctools.cscript): # Clear models self._models.clear() - - # Clear XML file and append an observation list - self._xml.clear() - self._xml.append(gammalib.GXmlElement('observation_list title="observation list"')) - lib = self._xml.element('observation_list', 0) - + # Log output msg = 'Looping over %d runs' % len(self._runlist) self._log_header1(gammalib.TERSE, msg) @@ -713,7 +712,7 @@ class csiactobs(ctools.cscript): run_emax.TeV())) # Append observation to XML and set attributes - obs = lib.append('observation') + obs = self._xml_obslist.append('observation') obs.attribute('name', object_name) obs.attribute('id', str(obs_id)) obs.attribute('instrument', telescope) @@ -768,7 +767,7 @@ class csiactobs(ctools.cscript): self._write_summary() # Write warning in no observation could be used from runlist - if lib.size() == 0: + if self._xml_obslist.size() == 0: self._log_string(gammalib.NORMAL, 'WARNING: No observation was ' 'appended from specified runlist') diff --git a/test/test_csiactobs.py b/test/test_csiactobs.py index a55bfde..2a99389 100755 --- a/test/test_csiactobs.py +++ b/test/test_csiactobs.py @@ -148,7 +148,7 @@ class Test(test): # Check empty observation definition XML file self._check_obsdef('csiactobs_obs_py0.xml', 0) - + # Check empty model definition XML file self._check_moddef('csiactobs_bgd_py0.xml', 0)