Commit 2c92bb5a authored by Marius Isken's avatar Marius Isken
Browse files

bugfixes

parent f7c37727
......@@ -54,6 +54,9 @@ def weed(origin, targets, limit, neighborhood=3):
return targets_weeded, meandists_kept, deleted
class BadProblem(Exception):
pass
class EngineConfig(HasPaths):
gf_stores_from_pyrocko_config = Bool.T(default=True)
gf_store_superdirs = List.T(Path.T())
......
......@@ -287,16 +287,16 @@ class Problem(Object):
self.raise_invalid_norm_exponent()
def bootstrap_misfit(self, ms, ns, ibootstrap=None):
# Should this be nbootstrap?
exp, root = self.get_norm_functions()
w = self.get_bootstrap_weights(ibootstrap) * \
self.get_target_weights() * self.inter_group_weights(ns)
w = self.get_target_weights() * self.inter_group_weights(ns)
if ibootstrap is None:
return root(
num.nansum(exp(w*ms[num.newaxis, :]), axis=1) /
num.nansum(exp(w*ns[num.newaxis, :]), axis=1))
else:
w *= self.get_bootstrap_weights(ibootstrap)
return root(num.nansum(exp(w*ms)) / num.nansum(exp(w*ns)))
def bootstrap_misfits(self, misfits, ibootstrap):
......
......@@ -14,6 +14,36 @@ km = 1e3
as_km = dict(scale_factor=km, scale_unit='km')
class DoubleDCProblemConfig(ProblemConfig):
ranges = Dict.T(String.T(), gf.Range.T())
distance_min = Float.T(default=0.0)
nbootstrap = Int.T(default=100)
def get_problem(self, event, targets):
if event.depth is None:
event.depth = 0.
base_source = gf.DoubleDCSource.from_pyrocko_event(event)
base_source.stf = gf.HalfSinusoidSTF(duration=event.duration or 0.0)
subs = dict(
event_name=event.name,
event_time=util.time_to_str(event.time))
problem = DoubleDCProblem(
name=expand_template(self.name_template, subs),
apply_balancing_weights=self.apply_balancing_weights,
base_source=base_source,
targets=targets,
ranges=self.ranges,
distance_min=self.distance_min,
nbootstrap=self.nbootstrap,
norm_exponent=self.norm_exponent)
return problem
class DoubleDCProblem(Problem):
problem_parameters = [
......@@ -153,33 +183,3 @@ class DoubleDCProblem(Problem):
results.append(result)
return results
class DoubleDCProblemConfig(ProblemConfig):
ranges = Dict.T(String.T(), gf.Range.T())
distance_min = Float.T(default=0.0)
nbootstrap = Int.T(default=100)
def get_problem(self, event, targets):
if event.depth is None:
event.depth = 0.
base_source = gf.DoubleDCSource.from_pyrocko_event(event)
base_source.stf = gf.HalfSinusoidSTF(duration=event.duration or 0.0)
subs = dict(
event_name=event.name,
event_time=util.time_to_str(event.time))
problem = DoubleDCProblem(
name=expand_template(self.name_template, subs),
apply_balancing_weights=self.apply_balancing_weights,
base_source=base_source,
targets=targets,
ranges=self.ranges,
distance_min=self.distance_min,
nbootstrap=self.nbootstrap,
norm_exponent=self.norm_exponent)
return problem
Markdown is supported
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