Commit 718635be47eed799021a997d165f8456c14429f3
1 parent
a7737cd8
Avoid negative squared standard deviations in cssrcdetect (#3261)
Showing
4 changed files
with
19 additions
and
15 deletions
ChangeLog
| ... | ... | @@ -3,10 +3,10 @@ |
| 3 | 3 | * Version 1.7.0 released |
| 4 | 4 | ======================== |
| 5 | 5 | |
| 6 | + Avoid negative squared standard deviations in cssrcdetect (#3261) | |
| 6 | 7 | Add Interface Manual to User documentation (#3163) |
| 7 | 8 | Adapt show_pull_histogram.py to matplotlib > 3.1.0 (#3156) |
| 8 | 9 | Add On/Off analysis to ctlike reference manual (#3154) |
| 9 | - Avoid negative squared standard deviations in cssrcdetect | |
| 10 | 10 | Update user manual for latest CTA IRF (#3075) |
| 11 | 11 | Fix log file header repetition in some cscripts (#3066) |
| 12 | 12 | Add Moon constraints to csviscube (#3065) | ... | ... |
NEWS
| ... | ... | @@ -292,9 +292,11 @@ Add ebingamma parameter and support for POW binning (#2881). |
| 292 | 292 | cssrcdetect - Detects sources in sky map |
| 293 | 293 | ---------------------------------------- |
| 294 | 294 | The using of a smoothing kernel in the _map_moments() method can lead to |
| 295 | -negative squared standard deviations that lead to an exception when the | |
| 296 | -square root is taken. A filter was introduced that sets all small values | |
| 297 | -of mean and std to zero, avoiding thus the exception. | |
| 295 | +negative squared standard deviations that lead to an exception when the square | |
| 296 | +root is taken. To avoid negative values, the minimum pixel values for the | |
| 297 | +standard deviation map is computed and, if the minimum value is negative, | |
| 298 | +subtracted from the standard deviation map. Therefore, by definition, the | |
| 299 | +standard deviation map is non negative for all pixels (#3261). | |
| 298 | 300 | |
| 299 | 301 | |
| 300 | 302 | cstsdist - Computes Test Statistic distribution | ... | ... |
cscripts/cssrcdetect.py
| ... | ... | @@ -237,16 +237,17 @@ class cssrcdetect(ctools.cscript): |
| 237 | 237 | # Compute the squared of the standard deviation for each pixel |
| 238 | 238 | std = std - (mean*mean) |
| 239 | 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 | |
| 240 | + # Compute minimum value of standard deviation | |
| 241 | + std_offset = 0.0 | |
| 242 | + for index in range(std.npix()): | |
| 243 | + if std[index] < std_offset: | |
| 244 | + std_offset = std[index] | |
| 245 | + | |
| 246 | + # If minimum value is negative then subtract minimum value to guarantee | |
| 247 | + # a non-negative map of standard deviations | |
| 248 | + if std_offset < 0.0: | |
| 249 | + for index in range(std.npix()): | |
| 250 | + std[index] -= std_offset | |
| 250 | 251 | |
| 251 | 252 | # Compute standard deviation |
| 252 | 253 | std = std.sqrt() | ... | ... |
doc/source/admin/release_history/1.7.rst
| ... | ... | @@ -17,9 +17,10 @@ In particular, this release provides: |
| 17 | 17 | Bug fixes |
| 18 | 18 | --------- |
| 19 | 19 | |
| 20 | +* [`3261 <https://cta-redmine.irap.omp.eu/issues/3261>`_] - | |
| 21 | + Avoid negative squared standard deviations in :ref:`cssrcdetect` | |
| 20 | 22 | * [`3156 <https://cta-redmine.irap.omp.eu/issues/3156>`_] - |
| 21 | 23 | Adapt show_pull_histogram.py to matplotlib > 3.1.0 |
| 22 | -* Avoid negative squared standard deviations in :ref:`cssrcdetect` | |
| 23 | 24 | * [`3066 <https://cta-redmine.irap.omp.eu/issues/3066>`_] - |
| 24 | 25 | Fix log file header repetition in some cscripts |
| 25 | 26 | ... | ... |