Commit 632aa09fbfbadb5b3e4fc3575e5366e6cbacdb65

Authored by Iftach Sadeh
Committed by Jürgen Knödlseder
1 parent a6aedae3

add optional seed parameter for generating events

cscripts/cssens.par
... ... @@ -44,6 +44,7 @@ statistic, s, h, DEFAULT,DEFAULT|CSTAT|WSTAT|CHI2,, "Optimization s
44 44 min_src_events, i, h, -1,,, "minimal number of source counts"
45 45 non_source_uncert_frac, r, h, -1,,, "fraction of no-source counts serving as minimal threshold for source counts"
46 46 non_source_uncert_rad, r, h, 0.33,,, "radius for circular region in which to integrate no-source counts for threshold"
  47 +seed, i, h, 0,,, "optional seed parameter for generating events"
47 48  
48 49 #
49 50 # Standard parameters
... ...
cscripts/cssens.py
... ... @@ -376,6 +376,9 @@ class cssens(ctools.csobservation):
376 376 # set edisp off for the first iterations
377 377 self['edisp'] = False
378 378  
  379 + # optional seed parameter for generating events
  380 + seed = self['seed'].integer()
  381 +
379 382 # Set flux ratio precision required for convergence to 5%
380 383 ratio_precision = 0.05
381 384  
... ... @@ -428,7 +431,7 @@ class cssens(ctools.csobservation):
428 431  
429 432 # Simulate events for the models. "sim" holds an observation
430 433 # container with observations containing the simulated events.
431   - sim = obsutils.sim(self.obs(), nbins=enumbins, seed=iterations,
  434 + sim = obsutils.sim(self.obs(), nbins=enumbins, seed=(iterations + seed),
432 435 binsz=binsz, npix=npix,
433 436 log=self._log_clients,
434 437 debug=self['debug'].boolean(),
... ... @@ -718,6 +721,9 @@ class cssens(ctools.csobservation):
718 721 # on the background, which is taken as 1% of the non-source counts)
719 722 non_source_uncert_frac = self['non_source_uncert_frac'].real()
720 723  
  724 + # optional seed parameter for generating events
  725 + seed = self['seed'].integer()
  726 +
721 727 # end here if no cuts have been spesified
722 728 if min_src_events <= 0 and non_source_uncert_frac <= 0:
723 729 return True
... ... @@ -754,7 +760,7 @@ class cssens(ctools.csobservation):
754 760  
755 761 n_sim_evts = []
756 762 for n_sim in range(n_sims):
757   - seed = n_sim
  763 + seed = n_sim + seed
758 764  
759 765 sim_now = obsutils.sim(
760 766 obs_now,
... ...