Commit d51de83b0fbd14b07f7b1f24e24c497b96b08e9a

Authored by Jürgen Knödlseder
1 parent f3a1f6f2

Make cspull script compliant with Python 3

Showing 1 changed file with 17 additions and 7 deletions
cscripts/cspull.py
... ... @@ -170,6 +170,16 @@ class cspull(ctools.cscript):
170 170 if self._enumbins > enumbins:
171 171 enumbins = self._enumbins
172 172  
  173 + # Compute spatial binning for point spread function and
  174 + # energy dispersion cubes
  175 + binsz = 10.0 * self['binsz'].real()
  176 + nxpix = self['nxpix'].integer() // 10 # Make sure result is int
  177 + nypix = self['nypix'].integer() // 10 # Make sure result is int
  178 + if nxpix < 2:
  179 + nxpix = 2
  180 + if nypix < 2:
  181 + nypix = 2
  182 +
173 183 # Get stacked exposure
174 184 expcube = ctools.ctexpcube(self._obs)
175 185 expcube['incube'] = 'NONE'
... ... @@ -196,9 +206,9 @@ class cspull(ctools.cscript):
196 206 psfcube['incube'] = 'NONE'
197 207 psfcube['usepnt'] = True
198 208 psfcube['ebinalg'] = 'LOG'
199   - psfcube['binsz'] = self._binsz*10.0
200   - psfcube['nxpix'] = self._npix/10
201   - psfcube['nypix'] = self._npix/10
  209 + psfcube['binsz'] = binsz
  210 + psfcube['nxpix'] = nxpix
  211 + psfcube['nypix'] = nypix
202 212 psfcube['enumbins'] = enumbins
203 213 psfcube['emin'] = self['emin'].real()
204 214 psfcube['emax'] = self['emax'].real()
... ... @@ -218,9 +228,9 @@ class cspull(ctools.cscript):
218 228 edispcube['incube'] = 'NONE'
219 229 edispcube['usepnt'] = True
220 230 edispcube['ebinalg'] = 'LOG'
221   - edispcube['binsz'] = self._binsz*10.0
222   - edispcube['nxpix'] = self._npix/10
223   - edispcube['nypix'] = self._npix/10
  231 + edispcube['binsz'] = binsz
  232 + edispcube['nxpix'] = nxpix
  233 + edispcube['nypix'] = nypix
224 234 edispcube['enumbins'] = enumbins
225 235 edispcube['emin'] = self['emin'].real()
226 236 edispcube['emax'] = self['emax'].real()
... ... @@ -473,7 +483,7 @@ class cspull(ctools.cscript):
473 483 self._log('\n')
474 484  
475 485 # Signal if stacked analysis is requested
476   - stacked = self._enumbins > 0
  486 + stacked = self._obs.size() > 1 and self._enumbins > 0
477 487  
478 488 # If several observations and binned: prepare stacked irfs
479 489 if stacked:
... ...