Commit eef2b11e authored by Sebastian Heimann's avatar Sebastian Heimann
Browse files

grond check: can now plot synthetics of reference solution against data

parent 6c93b58b
......@@ -201,7 +201,14 @@ def command_check(args):
parser.add_option(
'--plot', dest='show_plot', action='store_true',
help='plot sample synthetics and data')
help='plot sample synthetics and data.')
parser.add_option(
'--nrandom', dest='n_random_synthetics', metavar='N', type='int',
default=10,
help='set number of random synthetics to forward model (default: '
'10). If set to zero, create synthetics for the reference '
'solution.')
parser, options, args = cl_parse('check', args, setup)
if len(args) < 2:
......@@ -220,7 +227,8 @@ def command_check(args):
config,
event_names=event_names,
target_string_ids=target_string_ids,
show_plot=options.show_plot)
show_plot=options.show_plot,
n_random_synthetics=options.n_random_synthetics)
def command_go(args):
......
......@@ -1599,7 +1599,13 @@ def check_problem(problem):
raise GrondError('no targets available')
def check(config, event_names=None, target_string_ids=None, show_plot=False):
def check(
config,
event_names=None,
target_string_ids=None,
show_plot=False,
n_random_synthetics=10):
from matplotlib import pyplot as plt
from grond.plot import colors
......@@ -1626,11 +1632,19 @@ def check(config, event_names=None, target_string_ids=None, show_plot=False):
xbounds = num.array(problem.bounds(), dtype=num.float)
results_list = []
for i in xrange(10):
x = problem.random_uniform(xbounds)
if n_random_synthetics == 0:
x = problem.pack(problem.base_source)
ms, ns, results = problem.evaluate(x, result_mode='full')
results_list.append(results)
else:
for i in xrange(n_random_synthetics):
x = problem.random_uniform(xbounds)
ms, ns, results = problem.evaluate(x, result_mode='full')
results_list.append(results)
if show_plot:
for itarget, target in enumerate(problem.targets):
yabsmaxs = []
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment