Commit ff06df5480722716f5d7101aa98adbf1c1fdc680
1 parent
ec917f94
Add new parameters to cssrcdetect for smoothing. Implement smoothing methods in cssrcdetect.
Showing
2 changed files
with
30 additions
and
3 deletions
cscripts/cssrcdetect.par
| ... | ... | @@ -30,6 +30,8 @@ maxsrcs, i, h, 20,1,1000, "Maximum number of sources" |
| 30 | 30 | exclrad, r, h, 0.2,,, "Exclusion radius (deg)" |
| 31 | 31 | fit_pos, b, h, yes,,, "Fit source positions?" |
| 32 | 32 | fit_shape, b, h, yes,,, "Fit source shapes?" |
| 33 | +smoothkernel, s, a, NONE,NONE|DISK|GAUSSIAN,,"Smoothing kernel to use for smoothing the input sky map" | |
| 34 | +smoothparam, r, a, 0.05,,,"Smoothing kernel parameters (sigma for GAUS, radius for DISK)" | |
| 33 | 35 | |
| 34 | 36 | # |
| 35 | 37 | # Standard parameters | ... | ... |
cscripts/cssrcdetect.py
| ... | ... | @@ -72,6 +72,8 @@ class cssrcdetect(ctools.cscript): |
| 72 | 72 | self['exclrad'].real() |
| 73 | 73 | self['fit_pos'].boolean() |
| 74 | 74 | self['fit_shape'].boolean() |
| 75 | + self['smoothkernel'].string() | |
| 76 | + self['smoothparam'].real() | |
| 75 | 77 | |
| 76 | 78 | # Query ahead output model filename |
| 77 | 79 | if self._read_ahead(): |
| ... | ... | @@ -338,6 +340,26 @@ class cssrcdetect(ctools.cscript): |
| 338 | 340 | return model |
| 339 | 341 | |
| 340 | 342 | |
| 343 | + def _smooth_skymap(self, skymap): | |
| 344 | + """ | |
| 345 | + Smooth the input sky map if a valid kernel was supplied | |
| 346 | + | |
| 347 | + Parameters | |
| 348 | + ---------- | |
| 349 | + skymap : `~gammalib.GSkyMap()` | |
| 350 | + Sky map | |
| 351 | + """ | |
| 352 | + # Make sure the smoothing kernel is not 'NONE' | |
| 353 | + if self['smoothkernel'].string().upper() != 'NONE': | |
| 354 | + skymap.smooth(self['smoothkernel'].string(), | |
| 355 | + self['smoothparam'].real()) | |
| 356 | + else: | |
| 357 | + self._log_string(gammalib.NORMAL, | |
| 358 | + "Smoothing kernel is NONE, smoothing will be ignored.") | |
| 359 | + | |
| 360 | + return | |
| 361 | + | |
| 362 | + | |
| 341 | 363 | def _load_skymap(self): |
| 342 | 364 | """ |
| 343 | 365 | Load sky map |
| ... | ... | @@ -378,13 +400,16 @@ class cssrcdetect(ctools.cscript): |
| 378 | 400 | # Get parameters |
| 379 | 401 | self._get_parameters() |
| 380 | 402 | |
| 381 | - # Write header | |
| 382 | - self._log_header1(gammalib.NORMAL, 'Source detection') | |
| 383 | - | |
| 384 | 403 | # If sky map is empty then load it from input parameter |
| 385 | 404 | if self._map.is_empty(): |
| 386 | 405 | self._map = self._load_skymap() |
| 387 | 406 | |
| 407 | + # Smooth the map | |
| 408 | + self._smooth_skymap(self._map) | |
| 409 | + | |
| 410 | + # Write header | |
| 411 | + self._log_header1(gammalib.NORMAL, 'Source detection') | |
| 412 | + | |
| 388 | 413 | # Detect sources |
| 389 | 414 | self._detect_sources(self._map) |
| 390 | 415 | ... | ... |