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