Commit 875f6e7c86d28e305144ce609144be0f42b82af3
1 parent
c796b9a8
Allow to pass an observation caontainer via Python
Showing
1 changed file
with
9 additions
and
4 deletions
examples/csbkgmodel.py
| @@ -49,12 +49,17 @@ class csbkgmodel(ctools.cscript): | @@ -49,12 +49,17 @@ class csbkgmodel(ctools.cscript): | ||
| 49 | self.name = "csbkgmodel" | 49 | self.name = "csbkgmodel" |
| 50 | self.version = "1.1.0" | 50 | self.version = "1.1.0" |
| 51 | 51 | ||
| 52 | - # Initialise some members | ||
| 53 | - self.obs = None | ||
| 54 | - | ||
| 55 | # Make sure that parfile exists | 52 | # Make sure that parfile exists |
| 56 | file = self.parfile() | 53 | file = self.parfile() |
| 57 | 54 | ||
| 55 | + # Initialise some members | ||
| 56 | + if len(argv) > 0 and isinstance(argv[0],gammalib.GObservations): | ||
| 57 | + self.obs = argv[0] | ||
| 58 | + argv = argv[1:] | ||
| 59 | + else: | ||
| 60 | + self.obs = gammalib.GObservations() | ||
| 61 | + self.obs.clear() | ||
| 62 | + | ||
| 58 | # Initialise application | 63 | # Initialise application |
| 59 | if len(argv) == 0: | 64 | if len(argv) == 0: |
| 60 | ctools.cscript.__init__(self, self.name, self.version) | 65 | ctools.cscript.__init__(self, self.name, self.version) |
| @@ -122,7 +127,7 @@ class csbkgmodel(ctools.cscript): | @@ -122,7 +127,7 @@ class csbkgmodel(ctools.cscript): | ||
| 122 | """ | 127 | """ |
| 123 | Get parameters from parfile and setup the observation. | 128 | Get parameters from parfile and setup the observation. |
| 124 | """ | 129 | """ |
| 125 | - if self.obs == None or self.obs.size() == 0: | 130 | + if self.obs.size() == 0: |
| 126 | self.obs = self.get_observations(False) | 131 | self.obs = self.get_observations(False) |
| 127 | 132 | ||
| 128 | # Read excluded regions, set flag if excluded regions are available | 133 | # Read excluded regions, set flag if excluded regions are available |