Bug #1841

An empty csiactobs script should write an empty observation definition XML file

Added by Knödlseder Jürgen over 7 years ago. Updated over 7 years ago.

Status:ClosedStart date:08/11/2016
Priority:NormalDue date:
Assigned To:Mayer Michael% Done:

100%

Category:-
Target version:1.2.0
Duration:

Description

Saving an empty csiastobs script gives an incomplete observation definition XML file:

iactobs = cscripts.csiactobs()
iactobs['outobs']   = 'csiactobs_obs_py0.xml'
iactobs['outmodel'] = 'csiactobs_bgd_py0.xml'
iactobs['logfile']  = 'csiactobs_py0.log'
iactobs.logFileOpen()
iactobs.save()

gives the following csiactobs_obs_py0.xml file:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>

The observation_list tag is missing.


Recurrence

No recurrence.

History

#1 Updated by Mayer Michael over 7 years ago

The problem ist that only in the run()-method, we have the following code:

self._xml.clear()
self._xml.append(gammalib.GXmlElement('observation_list title="observation list"'))
lib = self._xml.element('observation_list', 0)

Without calling run(), the XML file stays empty. I guess an easy fix would be to move this code snippet to the constructor? Alternatively, we could include a check in the save method, that simply saves an empty observation container in case (self._xml.size() == 0). Do you have a preference?

#2 Updated by Knödlseder Jürgen over 7 years ago

Mayer Michael wrote:

The problem ist that only in the run()-method, we have the following code:
[...]
Without calling run(), the XML file stays empty. I guess an easy fix would be to move this code snippet to the constructor? Alternatively, we could include a check in the save method, that simply saves an empty observation container in case (self._xml.size() == 0). Do you have a preference?

I was indeed thinking of moving this code to the constructor. If you do this, please also look in the test_csiactobs.py script where the relevant unit test is commented.

#3 Updated by Mayer Michael over 7 years ago

  • Status changed from New to Pull request
  • Assigned To set to Mayer Michael
  • Target version set to 1.2.0
  • % Done changed from 0 to 100

Branch 1841-csiactobs-handle-empty-observations.

Of course, when we will implement the clear method, we need to make sure that this is properly initialised again (#1842).

#4 Updated by Knödlseder Jürgen over 7 years ago

  • Status changed from Pull request to Closed

Merged into devel

Also available in: Atom PDF