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