Commit 8991ebf8 authored by Marius Isken's avatar Marius Isken
Browse files

Several bugfixes // Converging RectSource Static & Seismo

parent 03561f34
......@@ -214,7 +214,8 @@ def command_init(args):
group='all',
interpolation='multilinear',
store_id='gf_store',
inner_satellite_misfit_config=grond.InnerSatelliteMisfitConfig(
kite_scenes=['*all'],
inner_misfit_config=grond.InnerSatelliteMisfitConfig(
use_weight_focal=False))]
problem_config = grond.RectangularProblemConfig(
......
import numpy as num
class ColorCycler(list):
def __init__(self, *args, **kwargs):
list.__init__(self, *args, **kwargs)
self.index = -1
def next(self):
self.index += 1
if self.index >= len(self):
self.index = 0
return self[self.index]
def makeColorGradient(misfits, fr=1., fg=.5, fb=1.,
pr=0, pg=2.5, pb=4):
misfits /= misfits.max()
r = num.sin(fr * misfits + pr) * 127 + 128
g = num.sin(fg * misfits + pg) * 127 + 128
b = num.sin(fb * misfits + pb) * 127 + 128
return ['#%02x%02x%02x' % (r[i], g[i], b[i]) for i in xrange(misfits.size)]
......@@ -34,6 +34,8 @@ logger = logging.getLogger('grond.baraddur')
class BaraddurModel(object):
def __init__(self, rundir):
if rundir is None:
return
logger.debug('Loading problem from %s' % rundir)
self.rundir = op.abspath(rundir)
self.problem = grond.core.load_problem_info(self.rundir)
......
......@@ -39,6 +39,11 @@ class Problem(Object):
self._target_weights = None
self._engine = None
self._group_mask = None
if hasattr(self, 'problem_waveform_parameters') and self.has_waveforms:
self.problem_parameters =\
self.problem_parameters + self.problem_waveform_parameters
logger.name = self.__class__.__name__
def get_engine(self):
......@@ -683,8 +688,7 @@ class DoubleDCProblemConfig(ProblemConfig):
class RectangularProblem(Problem):
# nucleation_x
# nucleation_y
# rupture_velocity
# t0
# time
# stf
problem_parameters = [
......@@ -699,9 +703,16 @@ class RectangularProblem(Problem):
Parameter('slip', 'm', label='Slip'),
]
problem_waveform_parameters = [
Parameter('nucleation_x', 'offset', label='Nucleation X'),
Parameter('nucleation_y', 'offset', label='Nucleation Y'),
Parameter('time', 's', label='Time'),
]
dependants = []
nbootstrap = 0
distance_min = Float.T(default=0.0)
nbootstrap = Int.T(default=10)
def pack(self, source):
return self.get_parameter_array(source)
......@@ -801,6 +812,8 @@ class RectangularProblemConfig(ProblemConfig):
ranges = Dict.T(String.T(), gf.Range.T())
apply_balancing_weights = Bool.T(default=False)
nbootstrap = Int.T(default=10)
distance_min = Float.T(default=0.)
def get_problem(self, event, targets):
base_source = gf.RectangularSource(
......@@ -815,6 +828,8 @@ class RectangularProblemConfig(ProblemConfig):
name=expand_template(self.name_template, event.name),
apply_balancing_weights=self.apply_balancing_weights,
base_source=base_source,
nbootstrap=self.nbootstrap,
distance_min=self.distance_min,
targets=targets,
ranges=self.ranges,)
......
......@@ -67,10 +67,6 @@ class GrondTarget(object):
def get_dataset(self):
return self._ds
@property
def id(self):
return self.scene_id
@property
def nparameters(self):
return len(self._target_parameters)
......@@ -103,7 +99,11 @@ class GrondTarget(object):
return '.'.join([self.super_group, self.group, self.id])
class InnerMisfitConfig(Object):
class InnerTargetConfig(Object):
pass
class InnerMisfitConfig(InnerTargetConfig):
fmin = Float.T()
fmax = Float.T()
ffactor = Float.T(default=1.5)
......@@ -185,6 +185,10 @@ class MisfitTarget(gf.Target, GrondTarget):
return '.'.join(x for x in (
self.super_group, self.group) + self.codes if x)
@property
def id(self):
return '.'.join(self.codes)
def get_plain_target(self):
d = dict(
(k, getattr(self, k)) for k in gf.Target.T.propnames)
......@@ -505,7 +509,7 @@ def _process(tr, tmin, tmax, taper, domain):
return tr_proc, trspec_proc
class InnerSatelliteMisfitConfig(Object):
class InnerSatelliteMisfitConfig(InnerTargetConfig):
use_weight_focal = Bool.T(default=False)
optimize_orbital_ramp = Bool.T(default=True)
ranges = Dict.T(String.T(), gf.Range.T(),
......@@ -538,6 +542,10 @@ class MisfitSatelliteTarget(gf.SatelliteTarget, GrondTarget):
self._target_parameters = None
self._target_ranges = None
@property
def id(self):
return self.scene_id
def post_process(self, engine, source, statics):
scene = self._ds.get_kite_scene(self.scene_id)
quadtree = scene.quadtree
......@@ -581,11 +589,10 @@ class TargetConfig(Object):
limit = Int.T(optional=True)
channels = List.T(String.T(), optional=True)
inner_misfit_config = InnerMisfitConfig.T(optional=True)
inner_satellite_misfit_config = InnerSatelliteMisfitConfig.T(
optional=True)
inner_misfit_config = InnerTargetConfig.T(optional=True)
interpolation = gf.InterpolationMethod.T()
store_id = gf.StringID.T()
kite_scenes = List.T(optional=True)
store_id = gf.StringID.T(optional=True)
weight = Float.T(default=1.0)
def get_targets(self, ds, event, default_group):
......@@ -596,6 +603,17 @@ class TargetConfig(Object):
scene_reference_frame = None
for scene in ds.get_kite_scenes():
if not self.kite_scenes:
continue
if scene.meta.scene_id not in self.kite_scenes and\
'*all' not in self.kite_scenes:
continue
if not isinstance(self.inner_misfit_config,
InnerSatelliteMisfitConfig):
raise AttributeError('inner_misfit_config must be of type'
' InnerSatelliteMisfitConfig')
qt = scene.quadtree
lats = num.empty(qt.nleafs)
......@@ -635,7 +653,7 @@ class TargetConfig(Object):
store_id=self.store_id,
super_group=self.super_group,
group=self.group or default_group,
inner_misfit_config=self.inner_satellite_misfit_config)
inner_misfit_config=self.inner_misfit_config)
sat_target.set_dataset(ds)
targets.append(sat_target)
......@@ -645,6 +663,11 @@ class TargetConfig(Object):
if ds.is_blacklisted((st.nsl() + (cha,))):
continue
if not isinstance(self.inner_misfit_config,
InnerMisfitConfig):
raise AttributeError('inner_misfit_config must be of type'
' InnerMisfitConfig')
target = MisfitTarget(
quantity='displacement',
codes=st.nsl() + (cha,),
......
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