Commit 6d60543090936c0c1e81b489ae47a9e0ce06c2ae

Authored by Andreas Specovius
Committed by Luigi Tibaldo
1 parent f722fd73

Added new class member _excl_reg_map and new combined getter and setter for that…

… member. Also took care about pickling.
Showing 1 changed file with 48 additions and 22 deletions
cscripts/csphasecrv.py
... ... @@ -62,13 +62,14 @@ class csphasecrv(ctools.csobservation):
62 62  
63 63 # Initialise some members. Phases are stored in a nested list
64 64 # [[ph1min,ph1max], [ph2min,ph2max],..]
65   - self._srcname = ''
66   - self._phbins = [[0.0,1.0]]
67   - self._onoff = False
68   - self._stacked = False
69   - self._fits = gammalib.GFits()
70   - self._fitmodels = {}
71   - self._nthreads = 0
  65 + self._srcname = ''
  66 + self._phbins = [[0.0,1.0]]
  67 + self._onoff = False
  68 + self._stacked = False
  69 + self._fits = gammalib.GFits()
  70 + self._fitmodels = {}
  71 + self._nthreads = 0
  72 + self._excl_reg_map = None # Exclusion region map for on/off analysis
72 73  
73 74 # Return
74 75 return
... ... @@ -84,14 +85,15 @@ class csphasecrv(ctools.csobservation):
84 85 Pickled instance
85 86 """
86 87 # Set pickled dictionary
87   - state = {'base' : ctools.csobservation.__getstate__(self),
88   - 'srcname' : self._srcname,
89   - 'phbins' : self._phbins,
90   - 'stacked' : self._stacked,
91   - 'onoff' : self._onoff,
92   - 'fits' : self._fits,
93   - 'fitmodels': self._fitmodels,
94   - 'nthreads' : self._nthreads}
  88 + state = {'base' : ctools.csobservation.__getstate__(self),
  89 + 'srcname' : self._srcname,
  90 + 'phbins' : self._phbins,
  91 + 'stacked' : self._stacked,
  92 + 'onoff' : self._onoff,
  93 + 'fits' : self._fits,
  94 + 'fitmodels' : self._fitmodels,
  95 + 'nthreads' : self._nthreads
  96 + 'excl_reg_map' : self._excl_reg_map}
95 97  
96 98 # Return pickled dictionary
97 99 return state
... ... @@ -106,13 +108,14 @@ class csphasecrv(ctools.csobservation):
106 108 Pickled instance
107 109 """
108 110 ctools.csobservation.__setstate__(self, state['base'])
109   - self._srcname = state['srcname']
110   - self._phbins = state['phbins']
111   - self._onoff = state['onoff']
112   - self._stacked = state['stacked']
113   - self._fits = state['fits']
114   - self._fitmodels= state['fitmodels']
115   - self._nthreads = state['nthreads']
  111 + self._srcname = state['srcname']
  112 + self._phbins = state['phbins']
  113 + self._onoff = state['onoff']
  114 + self._stacked = state['stacked']
  115 + self._fits = state['fits']
  116 + self._fitmodels = state['fitmodels']
  117 + self._nthreads = state['nthreads']
  118 + self._excl_reg_map = state['excl_reg_map']
116 119  
117 120 # Return
118 121 return
... ... @@ -545,6 +548,29 @@ class csphasecrv(ctools.csobservation):
545 548 # Return
546 549 return self._fitmodels
547 550  
  551 + def exclregmap(self, regmapobj=None):
  552 + """
  553 + Access exclusion region map object
  554 +
  555 + Parameters
  556 + ----------
  557 + regmapobj : `~gammalib.GSkyRegionMap`
  558 + Excluded regions region map instance
  559 +
  560 + Returns
  561 + -------
  562 + reg : `~gammalib.GSkyRegionMap`
  563 + Excluded regions region map instance
  564 + """
  565 + # Check if exclusion map object was provided
  566 + if regmapobj is not None:
  567 +
  568 + # Set exclusion region map
  569 + self._excl_reg_map = gammalib.GSkyRegionMap(regmapobj)
  570 +
  571 + # Return
  572 + return self._excl_reg_map
  573 +
548 574  
549 575 # ======================== #
550 576 # Main routine entry point #
... ...