Browse Source

grond report: allow controlling number of threads with --threads

grondown_fdsn
Sebastian Heimann 1 year ago
parent
commit
13d9630457
4 changed files with 23 additions and 9 deletions
  1. +13
    -6
      src/apps/grond.py
  2. +4
    -1
      src/report/base.py
  3. +5
    -1
      src/targets/satellite/target.py
  4. +1
    -1
      test/test_scenario.py

+ 13
- 6
src/apps/grond.py View File

@ -1081,7 +1081,7 @@ def command_tag(args):
die('Errors occurred, see log messages above.')
def make_report(env_args, event_name, conf, update_without_plotting):
def make_report(env_args, event_name, conf, update_without_plotting, nthreads):
from grond.environment import Environment
from grond.report import report
try:
@ -1093,7 +1093,8 @@ def make_report(env_args, event_name, conf, update_without_plotting):
env, conf,
update_without_plotting=update_without_plotting,
make_index=False,
make_archive=False)
make_archive=False,
nthreads=nthreads)
return True
@ -1173,6 +1174,10 @@ def command_report(args):
'--parallel', dest='nparallel', type=int, default=1,
help='set number of runs to process in parallel, '
'If set to more than one, --status=quiet is implied.')
parser.add_option(
'--threads', dest='nthreads', type=int, default=0,
help='set number of threads per process. This defaults to 0,'
'which is using all available cores.')
parser.add_option(
'--no-archive',
dest='no_archive',
@ -1226,15 +1231,17 @@ def command_report(args):
rundirs = args
all_failed = True
for rundir in rundirs:
payload.append(([rundir], None,
conf, options.update_without_plotting))
payload.append((
[rundir], None, conf, options.update_without_plotting,
options.nthreads))
elif args:
try:
env = Environment(args)
for event_name in env.get_selected_event_names():
payload.append((args, event_name,
conf, options.update_without_plotting))
payload.append((
args, event_name, conf, options.update_without_plotting,
options.nthreads))
except grond.GrondError as e:
die(str(e))


+ 4
- 1
src/report/base.py View File

@ -118,7 +118,7 @@ def copytree(src, dst):
def report(env, report_config=None, update_without_plotting=False,
make_index=True, make_archive=True):
make_index=True, make_archive=True, nthreads=0):
if report_config is None:
report_config = ReportConfig()
@ -128,6 +128,9 @@ def report(env, report_config=None, update_without_plotting=False,
problem = env.get_problem()
logger.info('Creating report entry for run "%s"...' % problem.name)
optimiser = env.get_optimiser()
optimiser.set_nthreads(nthreads)
fp = report_config.expand_path
entry_path = expand_template(
op.join(


+ 5
- 1
src/targets/satellite/target.py View File

@ -169,13 +169,17 @@ class SatelliteMisfitTarget(gf.SatelliteTarget, MisfitTarget):
def get_correlated_weights(self, nthreads=0):
''' is for L2-norm weighting, the square-rooted, inverse covar '''
if self._noise_weight_matrix is None:
logger.info('Inverting scene covariance matrix...')
logger.info(
'Inverting scene covariance matrix (nthreads=%i)...'
% nthreads)
cov = self.scene.covariance
cov.nthreads = nthreads
self._noise_weight_matrix = splinalg.sqrtm(
num.linalg.inv(cov.covariance_matrix))
logger.info('Inverting scene covariance matrix done.')
return self._noise_weight_matrix
@property


+ 1
- 1
test/test_scenario.py View File

@ -57,4 +57,4 @@ def test_scenario():
'--force',
*event_names)
rundir_paths = common.get_rundir_paths(config_path, event_names)
grond('report', '--parallel=2', *rundir_paths)
grond('report', '--parallel=2', '--threads=1', *rundir_paths)

Loading…
Cancel
Save