Commit b1ccc7de authored by Marius Isken's avatar Marius Isken
Browse files

super_group -> normalisation_family; group -> path

parent 28946af0
...@@ -96,9 +96,9 @@ class Config(HasPaths): ...@@ -96,9 +96,9 @@ class Config(HasPaths):
ds = self.get_dataset(event.name) ds = self.get_dataset(event.name)
targets = [] targets = []
for igroup, target_config in enumerate(self.target_groups): for igroup, target_group in enumerate(self.target_groups):
targets.extend(target_config.get_targets( targets.extend(target_group.get_targets(
ds, event, 'group_%i' % igroup)) ds, event, 'target.%i' % igroup))
return targets return targets
......
...@@ -1151,17 +1151,21 @@ def draw_fits_figures(ds, model, plt): ...@@ -1151,17 +1151,21 @@ def draw_fits_figures(ds, model, plt):
target_to_result[target] = result target_to_result[target] = result
dtrace.meta = dict(super_group=target.super_group, group=target.group) dtrace.meta = dict(
normalisation_family=target.normalisation_family,
path=target.path)
dtraces.append(dtrace) dtraces.append(dtrace)
result.processed_syn.meta = dict( result.processed_syn.meta = dict(
super_group=target.super_group, group=target.group) normalisation_family=target.normalisation_family,
path=target.path)
all_syn_trs.append(result.processed_syn) all_syn_trs.append(result.processed_syn)
if result.spectrum_syn: if result.spectrum_syn:
result.spectrum_syn.meta = dict( result.spectrum_syn.meta = dict(
super_group=target.super_group, group=target.group) normalisation_family=target.normalisation_family,
path=target.path)
all_syn_specs.append(result.spectrum_syn) all_syn_specs.append(result.spectrum_syn)
...@@ -1170,7 +1174,7 @@ def draw_fits_figures(ds, model, plt): ...@@ -1170,7 +1174,7 @@ def draw_fits_figures(ds, model, plt):
return [] return []
def skey(tr): def skey(tr):
return tr.meta['super_group'], tr.meta['group'] return tr.meta['normalisation_family'], tr.meta['path']
trace_minmaxs = trace.minmax(all_syn_trs, skey) trace_minmaxs = trace.minmax(all_syn_trs, skey)
...@@ -1185,7 +1189,7 @@ def draw_fits_figures(ds, model, plt): ...@@ -1185,7 +1189,7 @@ def draw_fits_figures(ds, model, plt):
cg_to_targets = gather( cg_to_targets = gather(
problem.waveform_targets, problem.waveform_targets,
lambda t: (t.super_group, t.group, t.codes[3]), lambda t: (t.normalisation_family, t.path, t.codes[3]),
filter=lambda t: t in target_to_result) filter=lambda t: t in target_to_result)
cgs = sorted(cg_to_targets.keys()) cgs = sorted(cg_to_targets.keys())
...@@ -1283,7 +1287,8 @@ def draw_fits_figures(ds, model, plt): ...@@ -1283,7 +1287,8 @@ def draw_fits_figures(ds, model, plt):
target = frame_to_target[iy, ix] target = frame_to_target[iy, ix]
amin, amax = trace_minmaxs[target.super_group, target.group] amin, amax = trace_minmaxs[
target.normalisation_family, target.path]
absmax = max(abs(amin), abs(amax)) absmax = max(abs(amin), abs(amax))
ny_this = nymax # min(ny, nymax) ny_this = nymax # min(ny, nymax)
...@@ -1343,7 +1348,8 @@ def draw_fits_figures(ds, model, plt): ...@@ -1343,7 +1348,8 @@ def draw_fits_figures(ds, model, plt):
elif target.misfit_config.domain == 'frequency_domain': elif target.misfit_config.domain == 'frequency_domain':
asmax = amp_spec_maxs[target.super_group, target.group] asmax = amp_spec_maxs[
target.normalisation_family, target.path]
fmin, fmax = \ fmin, fmax = \
target.misfit_config.get_full_frequency_range() target.misfit_config.get_full_frequency_range()
...@@ -1848,7 +1854,8 @@ class SolverPlot(object): ...@@ -1848,7 +1854,8 @@ class SolverPlot(object):
self.bcolors = colors.hsv_to_rgb(hsv[num.newaxis, :, :])[0, :, :] self.bcolors = colors.hsv_to_rgb(hsv[num.newaxis, :, :])[0, :, :]
bounds = self.problem.get_parameter_bounds() + self.problem.get_dependant_bounds() bounds = self.problem.get_parameter_bounds()\
+ self.problem.get_dependant_bounds()
self.xlim = fixlim(*xpar.scaled(bounds[ixpar])) self.xlim = fixlim(*xpar.scaled(bounds[ixpar]))
self.ylim = fixlim(*ypar.scaled(bounds[iypar])) self.ylim = fixlim(*ypar.scaled(bounds[iypar]))
......
...@@ -337,17 +337,14 @@ class Problem(Object): ...@@ -337,17 +337,14 @@ class Problem(Object):
return gcms return gcms
def make_group_mask(self): def make_group_mask(self):
super_group_names = set() family_names = set()
groups = num.zeros(len(self.targets), dtype=num.int) families = num.zeros(len(self.targets), dtype=num.int)
ngroups = 0
for itarget, target in enumerate(self.targets):
if target.super_group not in super_group_names:
super_group_names.add(target.super_group)
ngroups += 1
groups[itarget] = ngroups - 1 for itarget, target in enumerate(self.targets):
family_names.add(target.normalisation_family)
families[itarget] = len(family_names) - 1
return groups, ngroups return families, len(family_names)
def get_group_mask(self): def get_group_mask(self):
if self._group_mask is None: if self._group_mask is None:
......
import numpy as num import numpy as num
import math import math
import logging
from pyrocko import gf, util, moment_tensor as mtm from pyrocko import gf, util, moment_tensor as mtm
from pyrocko.guts import String, Float, Dict, Int, StringChoice from pyrocko.guts import String, Float, Dict, Int, StringChoice
from .base import Problem, ProblemConfig, logger from .base import Problem, ProblemConfig
from ..meta import Forbidden, expand_template, Parameter from ..meta import Forbidden, expand_template, Parameter
guts_prefix = 'grond' guts_prefix = 'grond'
logger = logger.getChild('cmt') logger = logging.getLogger('grond.problems').getChild('cmt')
km = 1e3 km = 1e3
as_km = dict(scale_factor=km, scale_unit='km') as_km = dict(scale_factor=km, scale_unit='km')
......
import numpy as num import numpy as num
import logging
from pyrocko import gf, util from pyrocko import gf, util
from pyrocko.guts import String, Float, Dict, Int from pyrocko.guts import String, Float, Dict, Int
from .base import Problem, ProblemConfig, logger from .base import Problem, ProblemConfig
from ..meta import Forbidden, expand_template, Parameter from ..meta import Forbidden, expand_template, Parameter
guts_prefix = 'grond' guts_prefix = 'grond'
logger = logger.getChild('grond.doubleDC') logger = logging.getLogger('grond.problems').getChild('double_dc')
km = 1e3 km = 1e3
as_km = dict(scale_factor=km, scale_unit='km') as_km = dict(scale_factor=km, scale_unit='km')
......
import numpy as num import numpy as num
import logging
from pyrocko import gf from pyrocko import gf
from pyrocko.guts import String, Bool, Float, Dict, Int from pyrocko.guts import String, Bool, Float, Dict, Int
from .base import Problem, ProblemConfig, logger from .base import Problem, ProblemConfig
from ..meta import expand_template, Parameter from ..meta import expand_template, Parameter
guts_prefix = 'grond' guts_prefix = 'grond'
logger = logger.getChild('rectangular') logger = logging.getLogger('grond.problems').getChild('rectangular')
km = 1e3 km = 1e3
as_km = dict(scale_factor=km, scale_unit='km') as_km = dict(scale_factor=km, scale_unit='km')
......
...@@ -9,8 +9,8 @@ class MisfitConfig(Object): ...@@ -9,8 +9,8 @@ class MisfitConfig(Object):
class TargetGroup(Object): class TargetGroup(Object):
super_group = gf.StringID.T(default='', optional=True) normalisation_family = gf.StringID.T(default='', optional=True)
group = gf.StringID.T(optional=True) path = gf.StringID.T(optional=True)
weight = Float.T(default=1.0) weight = Float.T(default=1.0)
misfit_config = MisfitConfig.T(optional=True) misfit_config = MisfitConfig.T(optional=True)
...@@ -18,7 +18,7 @@ class TargetGroup(Object): ...@@ -18,7 +18,7 @@ class TargetGroup(Object):
interpolation = gf.InterpolationMethod.T() interpolation = gf.InterpolationMethod.T()
store_id = gf.StringID.T(optional=True) store_id = gf.StringID.T(optional=True)
def get_targets(self, ds, event, default_group): def get_targets(self, ds, event, default_path):
raise NotImplementedError() raise NotImplementedError()
...@@ -58,7 +58,7 @@ class MisfitTarget(object): ...@@ -58,7 +58,7 @@ class MisfitTarget(object):
self._result_mode = result_mode self._result_mode = result_mode
def string_id(self): def string_id(self):
return '.'.join([self.super_group, self.group, self.id]) return '.'.join([self.normalisation_family, self.path, self.id])
def post_process(self, engine, source, statics): def post_process(self, engine, source, statics):
raise NotImplementedError() raise NotImplementedError()
......
...@@ -14,7 +14,7 @@ logger = logging.getLogger('grond.target').getChild('satellite') ...@@ -14,7 +14,7 @@ logger = logging.getLogger('grond.target').getChild('satellite')
class SatelliteTargetGroup(TargetGroup): class SatelliteTargetGroup(TargetGroup):
kite_scenes = List.T(optional=True) kite_scenes = List.T(optional=True)
def get_targets(self, ds, event, default_group): def get_targets(self, ds, event, default_path):
logger.debug('Selecting satellite targets...') logger.debug('Selecting satellite targets...')
targets = [] targets = []
...@@ -50,8 +50,8 @@ class SatelliteTargetGroup(TargetGroup): ...@@ -50,8 +50,8 @@ class SatelliteTargetGroup(TargetGroup):
tsnapshot=None, tsnapshot=None,
interpolation=self.interpolation, interpolation=self.interpolation,
store_id=self.store_id, store_id=self.store_id,
super_group=self.super_group, normalisation_family=self.normalisation_family,
group=self.group or default_group, path=self.path or default_path,
misfit_config=self.misfit_config) misfit_config=self.misfit_config)
sat_target.set_dataset(ds) sat_target.set_dataset(ds)
...@@ -76,12 +76,12 @@ class SatelliteMisfitConfig(MisfitConfig): ...@@ -76,12 +76,12 @@ class SatelliteMisfitConfig(MisfitConfig):
class SatelliteMisfitTarget(gf.SatelliteTarget, MisfitTarget): class SatelliteMisfitTarget(gf.SatelliteTarget, MisfitTarget):
scene_id = String.T() scene_id = String.T()
super_group = gf.StringID.T() normalisation_family = gf.StringID.T()
misfit_config = SatelliteMisfitConfig.T() misfit_config = SatelliteMisfitConfig.T()
manual_weight = Float.T( manual_weight = Float.T(
default=1.0, default=1.0,
help='Relative weight of this target') help='Relative weight of this target')
group = gf.StringID.T( path = gf.StringID.T(
help='Group') help='Group')
parameters = [ parameters = [
......
...@@ -26,7 +26,7 @@ class WaveformTargetGroup(TargetGroup): ...@@ -26,7 +26,7 @@ class WaveformTargetGroup(TargetGroup):
limit = Int.T(optional=True) limit = Int.T(optional=True)
channels = List.T(String.T(), optional=True) channels = List.T(String.T(), optional=True)
def get_targets(self, ds, event, default_group): def get_targets(self, ds, event, default_path):
logger.debug('Selecting waveform targets...') logger.debug('Selecting waveform targets...')
origin = event origin = event
targets = [] targets = []
...@@ -51,8 +51,8 @@ class WaveformTargetGroup(TargetGroup): ...@@ -51,8 +51,8 @@ class WaveformTargetGroup(TargetGroup):
store_id=self.store_id, store_id=self.store_id,
misfit_config=self.misfit_config, misfit_config=self.misfit_config,
manual_weight=self.weight, manual_weight=self.weight,
super_group=self.super_group, normalisation_family=self.normalisation_family,
group=self.group or default_group) path=self.path or default_path)
if self.distance_min is not None and \ if self.distance_min is not None and \
target.distance_to(origin) < self.distance_min: target.distance_to(origin) < self.distance_min:
...@@ -212,8 +212,8 @@ class WaveformMisfitTarget(gf.Target, MisfitTarget): ...@@ -212,8 +212,8 @@ class WaveformMisfitTarget(gf.Target, MisfitTarget):
misfit_config = WaveformMisfitConfig.T() misfit_config = WaveformMisfitConfig.T()
flip_norm = Bool.T(default=False) flip_norm = Bool.T(default=False)
manual_weight = Float.T(default=1.0) manual_weight = Float.T(default=1.0)
super_group = gf.StringID.T() normalisation_family = gf.StringID.T()
group = gf.StringID.T() path = gf.StringID.T()
analysis_result = TargetAnalysisResult.T(optional=True) analysis_result = TargetAnalysisResult.T(optional=True)
parameters = [] parameters = []
...@@ -227,8 +227,7 @@ class WaveformMisfitTarget(gf.Target, MisfitTarget): ...@@ -227,8 +227,7 @@ class WaveformMisfitTarget(gf.Target, MisfitTarget):
self._target_ranges = None self._target_ranges = None
def string_id(self): def string_id(self):
return '.'.join(x for x in ( return '.'.join(x for x in (self.path) + self.codes if x)
self.super_group, self.group) + self.codes if x)
@property @property
def id(self): def id(self):
......
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