98 Detect sources in counts map
102 counts : `~gammalib.GSkyMap()`
106 for i
in range(self[
'maxsrcs'].integer()):
109 self._log_header3(gammalib.NORMAL,
'Iteration '+str(i+1))
112 mean, std = self.
_map_moments(counts, self[
'avgrad'].real())
115 sigmap = (counts - mean)/std
124 name =
'Src%3.3d' % (i+1)
127 self._log_value(gammalib.NORMAL,
'Map maximum', str(value))
128 self._log_value(gammalib.NORMAL, name+
' position', str(pos))
135 radius=self[
'exclrad'].real())
141 self._log_value(gammalib.NORMAL,
'Map maximum',
142 'None above threshold')
179 Remove maximum from sky map by replacing pixels with a given value
183 skymap : `~gammalib.GSkyMap()`
185 pos : `~gammalib.GSkyDir()`
186 Sky direction of maximum
187 value : float, optional
189 radius : float, optional
190 Radius within which pixel values are replaced
194 skymap : `~gammalib.GSkyMap()`
195 Sky map with maximum removed
198 skymap_copy = skymap.copy()
201 cos_radius = math.cos(math.radians(radius))
204 for i
in range(skymap_copy.npix()):
206 if skymap_dir.cos_dist(pos) > cos_radius:
207 skymap_copy[i] = value
288 Model type ('IRF', 'AEFF', 'CUBE' or 'RACC')
292 model : `~gammalib.GModelData()`
296 epivot = gammalib.GEnergy(1.0,
'TeV')
299 if modeltype ==
'IRF':
300 spectral = gammalib.GModelSpectralPlaw(1.0, 0.0, epivot)
301 model = gammalib.GCTAModelIrfBackground(spectral)
302 elif modeltype ==
'AEFF':
303 spectral = gammalib.GModelSpectralPlaw(1.0e-13, -2.5, epivot)
304 model = gammalib.GCTAModelAeffBackground(spectral)
305 elif modeltype ==
'CUBE':
306 spectral = gammalib.GModelSpectralPlaw(1.0, 0.0, epivot)
307 model = gammalib.GCTAModelCubeBackground(spectral)
308 elif modeltype ==
'RACC':
309 radial = gammalib.GCTAModelRadialGauss(3.0)
310 spectral = gammalib.GModelSpectralPlaw(1.0e-4, -2.5, epivot)
311 model = gammalib.GCTAModelRadialAcceptance(radial, spectral)
316 if model
is not None:
317 model.name(
'Background')
324 Set point source model
328 pos : `~gammalib.GSkyDir()`
329 Sky direction of model
333 model : `~gammalib.GModelSky()`
337 spatial = gammalib.GModelSpatialPointSource(pos)
340 fit_pos = self[
'fit_pos'].boolean()
347 if par.name() ==
'RA' or par.name() ==
'DEC':
354 spectral = gammalib.GModelSpectralPlaw(5.7e-18, -2.48,
355 gammalib.GEnergy(0.3,
'TeV'))
358 model = gammalib.GModelSky(spatial, spectral)
366 Smooth the input sky map if a valid kernel was supplied
370 skymap : `~gammalib.GSkyMap()`
374 self._log_header3(gammalib.NORMAL,
'Smoothing Skymap')
377 if self[
'corr_kern'].string().upper() !=
'NONE':
378 self._log_value(gammalib.NORMAL,
'Kernel', self[
'corr_kern'].string())
379 self._log_value(gammalib.NORMAL,
'Parameter', self[
'corr_rad'].real())
380 skymap.smooth(self[
'corr_kern'].string(), self[
'corr_rad'].real())
382 self._log_string(gammalib.NORMAL,
383 'Smoothing kernel is "NONE", smoothing will be ignored.')
436 if self.
_map.is_empty():
445 self._log_header1(gammalib.NORMAL,
'Source detection')
451 self._log_models(gammalib.NORMAL, self.
_models,
'Detected source model')
454 self._log_header1(gammalib.NORMAL,
'Add background model')
457 bkgmodel = self.
_set_bkg(self[
'bkgmodel'].string())
458 if bkgmodel
is not None:
464 self._log_string(gammalib.NORMAL, str(bkgmodel))
468 self._log_value(gammalib.NORMAL,
'Background model',
'None')
475 Save sources into model definition XML file and ds9 file
478 self._log_header1(gammalib.TERSE,
'Save sources')
481 outmodel = self[
'outmodel'].filename()
482 outds9file = self[
'outds9file'].filename()
487 msg = (
'Cannot save "'+outmodel.url()+
'": File already exists. '
488 'Use parameter clobber=yes to allow overwriting of files.')
489 raise RuntimeError(msg)
492 elif outds9file.exists()
and not self.
_clobber:
493 msg = (
'Cannot save "'+outds9file.url()+
'": File already exists. '
494 'Use parameter clobber=yes to allow overwriting of files.')
495 raise RuntimeError(msg)
500 self._log_value(gammalib.NORMAL,
'Model definition XML file',
507 self._log_value(gammalib.NORMAL,
'DS9 region file',
511 modutils.models2ds9file(self.
_models, outds9file.url())