Commit bf2d5cb7c0df122f5b17c7af914710cd18e4f153
Merge branch '1841-csiactobs-handle-empty-observations' into integration
# Conflicts: # test/test_csiactobs.py
Showing
2 changed files
with
8 additions
and
9 deletions
cscripts/csiactobs.py
| ... | ... | @@ -85,6 +85,10 @@ class csiactobs(ctools.cscript): |
| 85 | 85 | # Initialise application by calling the appropriate class constructor |
| 86 | 86 | self._init_cscript(argv) |
| 87 | 87 | |
| 88 | + # Append an observation list to XML instance | |
| 89 | + self._xml.append(gammalib.GXmlElement('observation_list title="observation list"')) | |
| 90 | + self._xml_obslist = self._xml.element('observation_list', 0) | |
| 91 | + | |
| 88 | 92 | # Return |
| 89 | 93 | return |
| 90 | 94 | |
| ... | ... | @@ -559,12 +563,7 @@ class csiactobs(ctools.cscript): |
| 559 | 563 | |
| 560 | 564 | # Clear models |
| 561 | 565 | self._models.clear() |
| 562 | - | |
| 563 | - # Clear XML file and append an observation list | |
| 564 | - self._xml.clear() | |
| 565 | - self._xml.append(gammalib.GXmlElement('observation_list title="observation list"')) | |
| 566 | - lib = self._xml.element('observation_list', 0) | |
| 567 | - | |
| 566 | + | |
| 568 | 567 | # Log output |
| 569 | 568 | msg = 'Looping over %d runs' % len(self._runlist) |
| 570 | 569 | self._log_header1(gammalib.TERSE, msg) |
| ... | ... | @@ -713,7 +712,7 @@ class csiactobs(ctools.cscript): |
| 713 | 712 | run_emax.TeV())) |
| 714 | 713 | |
| 715 | 714 | # Append observation to XML and set attributes |
| 716 | - obs = lib.append('observation') | |
| 715 | + obs = self._xml_obslist.append('observation') | |
| 717 | 716 | obs.attribute('name', object_name) |
| 718 | 717 | obs.attribute('id', str(obs_id)) |
| 719 | 718 | obs.attribute('instrument', telescope) |
| ... | ... | @@ -768,7 +767,7 @@ class csiactobs(ctools.cscript): |
| 768 | 767 | self._write_summary() |
| 769 | 768 | |
| 770 | 769 | # Write warning in no observation could be used from runlist |
| 771 | - if lib.size() == 0: | |
| 770 | + if self._xml_obslist.size() == 0: | |
| 772 | 771 | self._log_string(gammalib.NORMAL, 'WARNING: No observation was ' |
| 773 | 772 | 'appended from specified runlist') |
| 774 | 773 | ... | ... |
test/test_csiactobs.py