Commit bd587f4b3edf23824c4f3be1e100c1baecc16f20
1 parent
e04fd450
Declare and initialise data members in csiactobs.__init__ method.
Showing
1 changed file
with
37 additions
and
13 deletions
cscripts/csiactobs.py
| 1 | #!/usr/bin/env python | 1 | #!/usr/bin/env python |
| 2 | # ========================================================================== | 2 | # ========================================================================== |
| 3 | -# Generation of an IACT observation definition file. | 3 | +# Generates an IACT observation definition XML file. |
| 4 | # | 4 | # |
| 5 | # Copyright (C) 2015-2016 Michael Mayer | 5 | # Copyright (C) 2015-2016 Michael Mayer |
| 6 | # | 6 | # |
| @@ -30,6 +30,8 @@ import json | @@ -30,6 +30,8 @@ import json | ||
| 30 | # =============== # | 30 | # =============== # |
| 31 | class csiactobs(ctools.cscript): | 31 | class csiactobs(ctools.cscript): |
| 32 | """ | 32 | """ |
| 33 | + Generates an IACT observation definition XML file. | ||
| 34 | + | ||
| 33 | This class implements the creation of a observation xml file for IACT | 35 | This class implements the creation of a observation xml file for IACT |
| 34 | data analysis. This class is dedicated for use inside a IACT | 36 | data analysis. This class is dedicated for use inside a IACT |
| 35 | Collaboration, i.e. it can only be used if you have access to IACT data | 37 | Collaboration, i.e. it can only be used if you have access to IACT data |
| @@ -48,12 +50,35 @@ class csiactobs(ctools.cscript): | @@ -48,12 +50,35 @@ class csiactobs(ctools.cscript): | ||
| 48 | self._version = "1.1.0" | 50 | self._version = "1.1.0" |
| 49 | 51 | ||
| 50 | # Initialise some members | 52 | # Initialise some members |
| 51 | - self._ebounds = gammalib.GEbounds() | ||
| 52 | - self._datapath = os.getenv("VHEFITS","") | ||
| 53 | - self._inmodels = None | ||
| 54 | - self._xml = gammalib.GXml() | ||
| 55 | - self._models = gammalib.GModels() | ||
| 56 | - self._runlist = [] | 53 | + self._ebounds = gammalib.GEbounds() |
| 54 | + self._datapath = os.getenv("VHEFITS","") | ||
| 55 | + self._inmodels = gammalib.GModels() | ||
| 56 | + self._prodname = "" | ||
| 57 | + self._xml = gammalib.GXml() | ||
| 58 | + self._models = gammalib.GModels() | ||
| 59 | + self._runlist = [] | ||
| 60 | + self._runlistfile = gammalib.GFilename() | ||
| 61 | + self._bkgpars = 0 | ||
| 62 | + self._outmodel = gammalib.GFilename() | ||
| 63 | + self._outobs = gammalib.GFilename() | ||
| 64 | + self._master_indx = "" | ||
| 65 | + self._use_bkg_scale = False | ||
| 66 | + self._ev_hiera = [""] | ||
| 67 | + self._aeff_hiera = [""] | ||
| 68 | + self._psf_hiera = [""] | ||
| 69 | + self._bkg_hiera = [""] | ||
| 70 | + self._edisp_hiera = [""] | ||
| 71 | + self._bkg_mod_hiera = [""] | ||
| 72 | + self._bkg_gauss_norm = 1.0 | ||
| 73 | + self._bkg_gauss_index = 0.0 | ||
| 74 | + self._bkg_gauss_sigma = 1.0 | ||
| 75 | + self._bkg_aeff_index = 0.0 | ||
| 76 | + self._bkg_aeff_norm = 1.0 | ||
| 77 | + self._bkg_range_factor = 1.0 | ||
| 78 | + self._hdu_index = "" | ||
| 79 | + self._obs_index = "" | ||
| 80 | + self._subdir = "" | ||
| 81 | + self._debug = False | ||
| 57 | 82 | ||
| 58 | # Initialise application by calling the appropriate class | 83 | # Initialise application by calling the appropriate class |
| 59 | # constructor. | 84 | # constructor. |
| @@ -68,7 +93,7 @@ class csiactobs(ctools.cscript): | @@ -68,7 +93,7 @@ class csiactobs(ctools.cscript): | ||
| 68 | """ | 93 | """ |
| 69 | Get parameters from parfile and setup the observation. | 94 | Get parameters from parfile and setup the observation. |
| 70 | """ | 95 | """ |
| 71 | - | 96 | + # Set data path |
| 72 | if self._datapath == "": | 97 | if self._datapath == "": |
| 73 | self._datapath = self["datapath"].string() | 98 | self._datapath = self["datapath"].string() |
| 74 | 99 | ||
| @@ -175,7 +200,6 @@ class csiactobs(ctools.cscript): | @@ -175,7 +200,6 @@ class csiactobs(ctools.cscript): | ||
| 175 | # Create base data directory from hdu index file location | 200 | # Create base data directory from hdu index file location |
| 176 | self._subdir = os.path.dirname(self._hdu_index) | 201 | self._subdir = os.path.dirname(self._hdu_index) |
| 177 | self._debug = False # Debugging in client tools | 202 | self._debug = False # Debugging in client tools |
| 178 | - self._clobber = self["clobber"].boolean() | ||
| 179 | 203 | ||
| 180 | # Return | 204 | # Return |
| 181 | return | 205 | return |
| @@ -583,18 +607,18 @@ class csiactobs(ctools.cscript): | @@ -583,18 +607,18 @@ class csiactobs(ctools.cscript): | ||
| 583 | self.run() | 607 | self.run() |
| 584 | 608 | ||
| 585 | # Save residual map | 609 | # Save residual map |
| 586 | - self.save(self._outobs, self._clobber) | 610 | + self.save() |
| 587 | 611 | ||
| 588 | # Return | 612 | # Return |
| 589 | return | 613 | return |
| 590 | 614 | ||
| 591 | - def save(self,outfile,clobber): | 615 | + def save(self): |
| 592 | 616 | ||
| 593 | # Save observation XML file | 617 | # Save observation XML file |
| 594 | - self._xml.save(outfile) | 618 | + self._xml.save(self._outobs) |
| 595 | 619 | ||
| 596 | # Save model XML file | 620 | # Save model XML file |
| 597 | - self._models.save(self._outmodel) | 621 | + self._models.save(self._outmodel, self._clobber()) |
| 598 | 622 | ||
| 599 | # Return | 623 | # Return |
| 600 | return | 624 | return |