Commit 1974e9c24a762f91baf29b9603e0886823c811aa

Authored by Luigi Tibaldo
1 parent 92b6363f

control of nthreads for use of csphagen within obsutils.sim

cscripts/cspull.py
@@ -256,8 +256,8 @@ class cspull(ctools.csobservation): @@ -256,8 +256,8 @@ class cspull(ctools.csobservation):
256 onsrc=onsrc, onrad=onrad, 256 onsrc=onsrc, onrad=onrad,
257 addbounds=True, seed=seed, 257 addbounds=True, seed=seed,
258 binsz=binsz, npix=npix, proj=proj, coord=coordsys, 258 binsz=binsz, npix=npix, proj=proj, coord=coordsys,
259 - edisp=edisp, log=False, debug=self._logDebug(),  
260 - chatter=self['chatter'].integer()) 259 + edisp=edisp, nthreads=1, log=False,
  260 + debug=self._logDebug(), chatter=self['chatter'].integer())
261 261
262 # Determine number of events in simulation 262 # Determine number of events in simulation
263 nevents = 0.0 263 nevents = 0.0
cscripts/cssens.py
@@ -418,7 +418,8 @@ class cssens(ctools.csobservation): @@ -418,7 +418,8 @@ class cssens(ctools.csobservation):
418 binsz=binsz, npix=npix, 418 binsz=binsz, npix=npix,
419 log=self._log_clients, 419 log=self._log_clients,
420 debug=self['debug'].boolean(), 420 debug=self['debug'].boolean(),
421 - edisp=self['edisp'].boolean()) 421 + edisp=self['edisp'].boolean(),
  422 + nthreads=1)
422 423
423 # Determine number of events in simulation by summing the events 424 # Determine number of events in simulation by summing the events
424 # over all observations in the observation container 425 # over all observations in the observation container
cscripts/cstsdist.py
@@ -196,9 +196,10 @@ class cstsdist(ctools.csobservation): @@ -196,9 +196,10 @@ class cstsdist(ctools.csobservation):
196 # only for event lists 196 # only for event lists
197 else: 197 else:
198 sim = obsutils.sim(self.obs(), 198 sim = obsutils.sim(self.obs(),
199 - seed = seed,  
200 - log = self._log_clients,  
201 - debug = self['debug'].boolean()) 199 + seed = seed,
  200 + log = self._log_clients,
  201 + debug = self['debug'].boolean(),
  202 + nthreads =1)
202 203
203 # Return simulated observation 204 # Return simulated observation
204 return sim 205 return sim
cscripts/obsutils.py
@@ -28,7 +28,7 @@ import cscripts @@ -28,7 +28,7 @@ import cscripts
28 # ===================== # 28 # ===================== #
29 def sim(obs, log=False, debug=False, chatter=2, edisp=False, seed=0, 29 def sim(obs, log=False, debug=False, chatter=2, edisp=False, seed=0,
30 emin=None, emax=None, nbins=0, onsrc=None, onrad=0.2, addbounds=False, 30 emin=None, emax=None, nbins=0, onsrc=None, onrad=0.2, addbounds=False,
31 - binsz=0.05, npix=200, proj='TAN', coord='GAL'): 31 + binsz=0.05, npix=200, proj='TAN', coord='GAL',nthreads=0):
32 """ 32 """
33 Simulate events for all observations in the container 33 Simulate events for all observations in the container
34 34
@@ -74,6 +74,8 @@ def sim(obs, log=False, debug=False, chatter=2, edisp=False, seed=0, @@ -74,6 +74,8 @@ def sim(obs, log=False, debug=False, chatter=2, edisp=False, seed=0,
74 Projection for binned simulation 74 Projection for binned simulation
75 coord : str, optional 75 coord : str, optional
76 Coordinate system for binned simulation 76 Coordinate system for binned simulation
  77 + nthreads : str, optional
  78 + Number of parallel processes for On/Off spectra computation (0=all available CPUs)
77 79
78 Returns 80 Returns
79 ------- 81 -------
@@ -133,6 +135,7 @@ def sim(obs, log=False, debug=False, chatter=2, edisp=False, seed=0, @@ -133,6 +135,7 @@ def sim(obs, log=False, debug=False, chatter=2, edisp=False, seed=0,
133 phagen['stack'] = False 135 phagen['stack'] = False
134 phagen['inexclusion'] = 'NONE' 136 phagen['inexclusion'] = 'NONE'
135 phagen['bkgmethod'] = 'REFLECTED' 137 phagen['bkgmethod'] = 'REFLECTED'
  138 + phagen['nthreads'] = nthreads
136 139
137 # Optionally open the log file 140 # Optionally open the log file
138 if log: 141 if log:
@@ -780,6 +783,8 @@ def get_onoff_obs(cls, obs, nthreads=0): @@ -780,6 +783,8 @@ def get_onoff_obs(cls, obs, nthreads=0):
780 cscript class 783 cscript class
781 obs : `~gammalib.GObservations` 784 obs : `~gammalib.GObservations`
782 Observation container 785 Observation container
  786 + nthreads : str, optional
  787 + Number of parallel processes for On/Off spectra computation (0=all available CPUs)
783 788
784 Returns 789 Returns
785 ------- 790 -------