Commit e95aad8c60a916646c6589ddadcc28ff9908ca45
1 parent
a35f9317
Moved iniitalisation of private XML instance from run() to constructor
Showing
2 changed files
with
8 additions
and
9 deletions
cscripts/csiactobs.py
| ... | ... | @@ -80,6 +80,10 @@ class csiactobs(ctools.cscript): |
| 80 | 80 | |
| 81 | 81 | # Initialise application by calling the appropriate class constructor |
| 82 | 82 | self._init_cscript(argv) |
| 83 | + | |
| 84 | + # Append an observation list to XML instance | |
| 85 | + self._xml.append(gammalib.GXmlElement('observation_list title="observation list"')) | |
| 86 | + self._xml_obslist = self._xml.element('observation_list', 0) | |
| 83 | 87 | |
| 84 | 88 | # Return |
| 85 | 89 | return |
| ... | ... | @@ -555,12 +559,7 @@ class csiactobs(ctools.cscript): |
| 555 | 559 | |
| 556 | 560 | # Clear models |
| 557 | 561 | self._models.clear() |
| 558 | - | |
| 559 | - # Clear XML file and append an observation list | |
| 560 | - self._xml.clear() | |
| 561 | - self._xml.append(gammalib.GXmlElement('observation_list title="observation list"')) | |
| 562 | - lib = self._xml.element('observation_list', 0) | |
| 563 | - | |
| 562 | + | |
| 564 | 563 | # Log output |
| 565 | 564 | msg = 'Looping over %d runs' % len(self._runlist) |
| 566 | 565 | self._log_header1(gammalib.TERSE, msg) |
| ... | ... | @@ -709,7 +708,7 @@ class csiactobs(ctools.cscript): |
| 709 | 708 | run_emax.TeV())) |
| 710 | 709 | |
| 711 | 710 | # Append observation to XML and set attributes |
| 712 | - obs = lib.append('observation') | |
| 711 | + obs = self._xml_obslist.append('observation') | |
| 713 | 712 | obs.attribute('name', object_name) |
| 714 | 713 | obs.attribute('id', str(obs_id)) |
| 715 | 714 | obs.attribute('instrument', telescope) |
| ... | ... | @@ -764,7 +763,7 @@ class csiactobs(ctools.cscript): |
| 764 | 763 | self._write_summary() |
| 765 | 764 | |
| 766 | 765 | # Write warning in no observation could be used from runlist |
| 767 | - if lib.size() == 0: | |
| 766 | + if self._xml_obslist.size() == 0: | |
| 768 | 767 | self._log_string(gammalib.NORMAL, 'WARNING: No observation was ' |
| 769 | 768 | 'appended from specified runlist') |
| 770 | 769 | ... | ... |
test/test_csiactobs.py
| ... | ... | @@ -147,7 +147,7 @@ class Test(test): |
| 147 | 147 | iactobs.save() |
| 148 | 148 | |
| 149 | 149 | # Check empty observation definition XML file |
| 150 | - #self._check_obsdef('csiactobs_obs_py0.xml', 0) # See #1841 | |
| 150 | + self._check_obsdef('csiactobs_obs_py0.xml', 0) | |
| 151 | 151 | |
| 152 | 152 | # Check empty model definition XML file |
| 153 | 153 | self._check_moddef('csiactobs_bgd_py0.xml', 0) | ... | ... |