Commit d086ddbbe4c5e23409611d455c7a6c340b06d369

Authored by Jürgen Knödlseder
1 parent 27f0166e

Avoid negative squared standard deviations in cssrcdetect

Showing 1 changed file with 15 additions and 2 deletions
cscripts/cssrcdetect.py
... ... @@ -2,7 +2,7 @@
2 2 # ==========================================================================
3 3 # Detects sources in a sky map
4 4 #
5   -# Copyright (C) 2016-2018 Juergen Knoedlseder
  5 +# Copyright (C) 2016-2019 Juergen Knoedlseder
6 6 #
7 7 # This program is free software: you can redistribute it and/or modify
8 8 # it under the terms of the GNU General Public License as published by
... ... @@ -234,8 +234,21 @@ class cssrcdetect(ctools.cscript):
234 234 mean.smooth('DISK', radius)
235 235 std.smooth('DISK', radius)
236 236  
237   - # Compute the standard deviation for each pixel
  237 + # Compute the squared of the standard deviation for each pixel
238 238 std = std - (mean*mean)
  239 +
  240 + # Set all pixels with small number of events or small number of
  241 + # squared standard deviation to zero. Such pixels may occur due to
  242 + # the smoothing operation that uses a fast fourrier transform.
  243 + for iy in range(std.ny()):
  244 + offset = iy * std.nx()
  245 + for ix in range(std.nx()):
  246 + index = ix + offset
  247 + if mean[index] < 1.0 or std[index] < 1.0:
  248 + mean[index] = 0.0
  249 + std[index] = 0.0
  250 +
  251 + # Compute standard deviation
239 252 std = std.sqrt()
240 253  
241 254 # Return mean and standard deviation
... ...