Commit d6d31814ef4b23ecdcf67153d0dbbbe1a093fe2f

Authored by Jürgen Knödlseder
1 parent 62bb3946

Integrate code (#2498)

Showing 1 changed file with 14 additions and 10 deletions
cscripts/cssrcdetect.py
@@ -51,7 +51,9 @@ class cssrcdetect(ctools.cscript): @@ -51,7 +51,9 @@ class cssrcdetect(ctools.cscript):
51 else: 51 else:
52 self._map = gammalib.GSkyMap() 52 self._map = gammalib.GSkyMap()
53 53
  54 + # Initialise other members
54 self._map_dirs = [] 55 self._map_dirs = []
  56 +
55 # Return 57 # Return
56 return 58 return
57 59
@@ -76,14 +78,14 @@ class cssrcdetect(ctools.cscript): @@ -76,14 +78,14 @@ class cssrcdetect(ctools.cscript):
76 78
77 # Query the smoothing parameters 79 # Query the smoothing parameters
78 self['smoothkernel'].string() 80 self['smoothkernel'].string()
79 - if self['smoothkernel'].string().upper() != "NONE": 81 + if self['smoothkernel'].string().upper() != 'NONE':
80 self['smoothparam'].real() 82 self['smoothparam'].real()
81 83
82 # Query ahead output model filename 84 # Query ahead output model filename
83 if self._read_ahead(): 85 if self._read_ahead():
84 self['outmodel'].filename() 86 self['outmodel'].filename()
85 self['outds9file'].filename() 87 self['outds9file'].filename()
86 - self["momentradius"].real() 88 + self['momentradius'].real()
87 89
88 # Write input parameters into logger 90 # Write input parameters into logger
89 self._log_parameters(gammalib.TERSE) 91 self._log_parameters(gammalib.TERSE)
@@ -107,7 +109,7 @@ class cssrcdetect(ctools.cscript): @@ -107,7 +109,7 @@ class cssrcdetect(ctools.cscript):
107 self._log_header3(gammalib.NORMAL, 'Iteration '+str(i+1)) 109 self._log_header3(gammalib.NORMAL, 'Iteration '+str(i+1))
108 110
109 # Get map moments 111 # Get map moments
110 - mean, std = self._map_moments(counts, self["momentradius"].real()) 112 + mean, std = self._map_moments(counts, self['momentradius'].real())
111 113
112 # Compute threshold 114 # Compute threshold
113 sigmap = (counts - mean)/std 115 sigmap = (counts - mean)/std
@@ -229,8 +231,8 @@ class cssrcdetect(ctools.cscript): @@ -229,8 +231,8 @@ class cssrcdetect(ctools.cscript):
229 std *= std 231 std *= std
230 232
231 # Convolve by disk to get bin-by-bin mean 233 # Convolve by disk to get bin-by-bin mean
232 - mean.smooth("DISK", radius)  
233 - std.smooth("DISK", radius) 234 + mean.smooth('DISK', radius)
  235 + std.smooth('DISK', radius)
234 236
235 # Compute the standard deviation for each pixel 237 # Compute the standard deviation for each pixel
236 std = std - (mean*mean) 238 std = std - (mean*mean)
@@ -348,18 +350,20 @@ class cssrcdetect(ctools.cscript): @@ -348,18 +350,20 @@ class cssrcdetect(ctools.cscript):
348 skymap : `~gammalib.GSkyMap()` 350 skymap : `~gammalib.GSkyMap()`
349 Sky map 351 Sky map
350 """ 352 """
351 - self._log_header3(gammalib.NORMAL, "Smoothing Skymap") 353 + # Log header
  354 + self._log_header3(gammalib.NORMAL, 'Smoothing Skymap')
  355 +
352 # Make sure the smoothing kernel is not 'NONE' 356 # Make sure the smoothing kernel is not 'NONE'
353 if self['smoothkernel'].string().upper() != 'NONE': 357 if self['smoothkernel'].string().upper() != 'NONE':
354 - self._log_value(gammalib.NORMAL, "Kernel", 358 + self._log_value(gammalib.NORMAL, 'Kernel',
355 self['smoothkernel'].string()) 359 self['smoothkernel'].string())
356 - self._log_value(gammalib.NORMAL, "Parameter",  
357 - self["smoothparam"].real()) 360 + self._log_value(gammalib.NORMAL, 'Parameter',
  361 + self['smoothparam'].real())
358 skymap.smooth(self['smoothkernel'].string(), 362 skymap.smooth(self['smoothkernel'].string(),
359 self['smoothparam'].real()) 363 self['smoothparam'].real())
360 else: 364 else:
361 self._log_string(gammalib.NORMAL, 365 self._log_string(gammalib.NORMAL,
362 - "Smoothing kernel is NONE, smoothing will be ignored.") 366 + 'Smoothing kernel is NONE, smoothing will be ignored.')
363 367
364 return 368 return
365 369