Commit 1dfb64b6 authored by Marius Isken's avatar Marius Isken
Browse files

Integrating SatelliteTarget

parent b55c490a
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
import math import math
import sys import sys
import logging import logging
import os.path as op
from optparse import OptionParser from optparse import OptionParser
from pyrocko import util from pyrocko import util
...@@ -132,43 +133,81 @@ def help_and_die(parser, message): ...@@ -132,43 +133,81 @@ def help_and_die(parser, message):
def command_init(args): def command_init(args):
dataset_config = grond.DatasetConfig( def setup(parser):
stations_path='stations.txt', parser.add_option(
events_path='events.txt', '--waveform', dest='waveform', action='store_true', default=True,
waveform_paths=['data']) help='Create an example configuration for waveform inversion.')
parser.add_option(
target_configs = [grond.TargetConfig( '--static', dest='static', action='store_true',
distance_min=10*km, help='Create an example configuration for static displacement'
distance_max=1000*km, ' targets using kite scene containers.')
channels=['Z', 'R', 'T'],
interpolation='multilinear', parser, options, args = cl_parse('init', args, setup)
store_id='global_2s',
inner_misfit_config=grond.InnerMisfitConfig( if options.waveform and not options.static:
fmin=0.01, dataset_config = grond.DatasetConfig(
fmax=0.1))] stations_path='stations.txt',
events_path='events.txt',
s2 = math.sqrt(2.0) waveform_paths=['data'])
problem_config = grond.CMTProblemConfig( target_configs = [grond.TargetConfig(
name_template='cmt_%(event_name)s', distance_min=10*km,
distance_min=2.*km, distance_max=1000*km,
nbootstrap=100, channels=['Z', 'R', 'T'],
mt_type='deviatoric', interpolation='multilinear',
ranges=dict( store_id='global_2s',
time=Range(0, 10.0, relative='add'), inner_misfit_config=grond.InnerMisfitConfig(
north_shift=Range(-16*km, 16*km), fmin=0.01,
east_shift=Range(-16*km, 16*km), fmax=0.1))]
depth=Range(1*km, 11*km),
magnitude=Range(4.0, 6.0), s2 = math.sqrt(2.0)
rmnn=Range(-s2, s2), problem_config = grond.CMTProblemConfig(
rmee=Range(-s2, s2), name_template='cmt_%(event_name)s',
rmdd=Range(-s2, s2), distance_min=2.*km,
rmne=Range(-1.0, 1.0), nbootstrap=100,
rmnd=Range(-1.0, 1.0), mt_type='deviatoric',
rmed=Range(-1.0, 1.0), ranges=dict(
duration=Range(1.0, 15.0))) time=Range(0, 10.0, relative='add'),
north_shift=Range(-16*km, 16*km),
east_shift=Range(-16*km, 16*km),
depth=Range(1*km, 11*km),
magnitude=Range(4.0, 6.0),
rmnn=Range(-s2, s2),
rmee=Range(-s2, s2),
rmdd=Range(-s2, s2),
rmne=Range(-1.0, 1.0),
rmnd=Range(-1.0, 1.0),
rmed=Range(-1.0, 1.0),
duration=Range(1.0, 15.0))
)
elif options.static:
dataset_config = grond.DatasetConfig(
kite_scene_paths=['scenes']
)
target_configs = [grond.TargetConfig(
interpolation='multilinear',
store_id='global_2s',
inner_satellite_misfit_config=grond.InnerSatelliteMisfitConfig(
use_kite_covariance=True))]
problem_config = grond.RectangularProblemConfig(
name_template='rect_source',
ranges=dict(
north_shift=Range(-20*km, 20*km),
east_shift=Range(-20*km, 20*km),
depth=Range(0*km, 10*km),
length=Range(20*km, 40*km),
width=Range(5*km, 12*km),
dip=Range(20, 70),
strike=Range(0, 180),
rake=Range(0, 90),
slip=Range(1, 3))
)
config = grond.Config( config = grond.Config(
rundir_template=op.abspath(op.curdir),
dataset_config=dataset_config, dataset_config=dataset_config,
target_configs=target_configs, target_configs=target_configs,
problem_config=problem_config) problem_config=problem_config)
......
...@@ -8,7 +8,7 @@ setup( ...@@ -8,7 +8,7 @@ setup(
version='0.1', version='0.1',
author='Sebastian Heimann', author='Sebastian Heimann',
author_email='sebastian.heimann@gfz-potsdam.de', author_email='sebastian.heimann@gfz-potsdam.de',
packages=['grond'], packages=['grond', 'grond.problems'],
package_dir={'grond': 'src'}, package_dir={'grond': 'src'},
scripts=['apps/grond'], scripts=['apps/grond'],
package_data={'grond': []}, package_data={'grond': []},
......
...@@ -266,8 +266,10 @@ class InnerMisfitConfig(Object): ...@@ -266,8 +266,10 @@ class InnerMisfitConfig(Object):
fmax = Float.T() fmax = Float.T()
ffactor = Float.T(default=1.5) ffactor = Float.T(default=1.5)
tmin = gf.Timing.T( tmin = gf.Timing.T(
optional=True,
help='Start of main time window used for waveform fitting.') help='Start of main time window used for waveform fitting.')
tmax = gf.Timing.T( tmax = gf.Timing.T(
optional=True,
help='End of main time window used for waveform fitting.') help='End of main time window used for waveform fitting.')
tfade = Float.T( tfade = Float.T(
optional=True, optional=True,
...@@ -301,6 +303,10 @@ class InnerMisfitConfig(Object): ...@@ -301,6 +303,10 @@ class InnerMisfitConfig(Object):
return self.fmin / self.ffactor, self.fmax * self.ffactor return self.fmin / self.ffactor, self.fmax * self.ffactor
class InnerSatelliteMisfitConfig(Object):
use_kite_covariance = Bool.T(default=True)
class TargetAnalysisResult(Object): class TargetAnalysisResult(Object):
balancing_weight = Float.T() balancing_weight = Float.T()
...@@ -620,6 +626,7 @@ tautoshift**2 / tautoshift_max**2`` ...@@ -620,6 +626,7 @@ tautoshift**2 / tautoshift_max**2``
class MisfitSatelliteTarget(gf.SatelliteTarget): class MisfitSatelliteTarget(gf.SatelliteTarget):
scene_id = guts.String.T() scene_id = guts.String.T()
super_group = gf.StringID.T() super_group = gf.StringID.T()
inner_misfit_config = InnerSatelliteMisfitConfig.T()
group = gf.StringID.T() group = gf.StringID.T()
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
...@@ -898,15 +905,17 @@ class SyntheticTest(Object): ...@@ -898,15 +905,17 @@ class SyntheticTest(Object):
class DatasetConfig(HasPaths): class DatasetConfig(HasPaths):
stations_path = Path.T(optional=True) stations_path = Path.T(optional=True)
stations_stationxml_paths = List.T(Path.T()) stations_stationxml_paths = List.T(Path.T(), optional=True)
events_path = Path.T() events_path = Path.T(optional=True)
waveform_paths = List.T(Path.T()) waveform_paths = List.T(Path.T(), optional=True)
clippings_path = Path.T(optional=True) clippings_path = Path.T(optional=True)
responses_sacpz_path = Path.T(optional=True) responses_sacpz_path = Path.T(optional=True)
responses_stationxml_paths = List.T(Path.T()) responses_stationxml_paths = List.T(Path.T(), optional=True)
station_corrections_path = Path.T(optional=True) station_corrections_path = Path.T(optional=True)
apply_correction_factors = Bool.T(default=True) apply_correction_factors = Bool.T(optional=True,
apply_correction_delays = Bool.T(default=True) default=True)
apply_correction_delays = Bool.T(optional=True,
default=True)
picks_paths = List.T(Path.T()) picks_paths = List.T(Path.T())
blacklist_paths = List.T(Path.T()) blacklist_paths = List.T(Path.T())
blacklist = List.T( blacklist = List.T(
...@@ -922,7 +931,7 @@ class DatasetConfig(HasPaths): ...@@ -922,7 +931,7 @@ class DatasetConfig(HasPaths):
'Note: ''when whitelisting on channel level, both, the raw and ' 'Note: ''when whitelisting on channel level, both, the raw and '
'the processed channel codes have to be listed.') 'the processed channel codes have to be listed.')
synthetic_test = SyntheticTest.T(optional=True) synthetic_test = SyntheticTest.T(optional=True)
kite_displacement_paths = List.T(Path.T, optional=True) kite_scene_paths = List.T(Path.T(), optional=True)
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
HasPaths.__init__(self, *args, **kwargs) HasPaths.__init__(self, *args, **kwargs)
...@@ -960,9 +969,9 @@ class DatasetConfig(HasPaths): ...@@ -960,9 +969,9 @@ class DatasetConfig(HasPaths):
ds.add_events(filename=fp(self.events_path)) ds.add_events(filename=fp(self.events_path))
ds.add_waveforms(paths=fp(self.waveform_paths)) ds.add_waveforms(paths=fp(self.waveform_paths))
if self.kite_displacement_paths: if self.kite_scene_paths:
ds.add_kite_displacement( ds.add_kite_displacement(
filenames=fp(self.kite_displacement_paths)) filenames=fp(self.kite_scene_paths))
if self.clippings_path: if self.clippings_path:
ds.add_clippings(markers_filename=fp(self.clippings_path)) ds.add_clippings(markers_filename=fp(self.clippings_path))
...@@ -1030,8 +1039,10 @@ class TargetConfig(Object): ...@@ -1030,8 +1039,10 @@ class TargetConfig(Object):
depth_min = Float.T(optional=True) depth_min = Float.T(optional=True)
depth_max = Float.T(optional=True) depth_max = Float.T(optional=True)
limit = Int.T(optional=True) limit = Int.T(optional=True)
channels = List.T(String.T()) channels = List.T(String.T(), optional=True)
inner_misfit_config = InnerMisfitConfig.T() inner_misfit_config = InnerMisfitConfig.T(optional=True)
inner_satellite_misfit_config = InnerSatelliteMisfitConfig.T(
optional=True)
interpolation = gf.InterpolationMethod.T() interpolation = gf.InterpolationMethod.T()
store_id = gf.StringID.T() store_id = gf.StringID.T()
weight = Float.T(default=1.0) weight = Float.T(default=1.0)
...@@ -1066,7 +1077,8 @@ class TargetConfig(Object): ...@@ -1066,7 +1077,8 @@ class TargetConfig(Object):
interpolation=self.interpolation, interpolation=self.interpolation,
store_id=self.store_id, store_id=self.store_id,
super_group=self.super_group, super_group=self.super_group,
group=self.group or default_group) group=self.group or default_group,
inner_misfit_config=self.inner_satellite_misfit_config)
for st in ds.get_stations(): for st in ds.get_stations():
for cha in self.channels: for cha in self.channels:
...@@ -1130,16 +1142,6 @@ class TargetConfig(Object): ...@@ -1130,16 +1142,6 @@ class TargetConfig(Object):
return targets return targets
class SatelliteTargetConfig(Object):
super_group = gf.StringID.T(default='', optional=True)
group = gf.StringID.T(optional=True)
limit = Int.T(optional=True)
inner_misfit_config = InnerMisfitConfig.T()
interpolation = gf.InterpolationMethod.T()
store_id = gf.StringID.T()
weight = Float.T(default=1.0)
class AnalyserConfig(Object): class AnalyserConfig(Object):
niter = Int.T(default=1000) niter = Int.T(default=1000)
...@@ -2340,9 +2342,11 @@ __all__ = ''' ...@@ -2340,9 +2342,11 @@ __all__ = '''
Problem Problem
ProblemConfig ProblemConfig
MisfitTarget MisfitTarget
MisfitSatelliteTarget
MisfitResult MisfitResult
Forbidden Forbidden
InnerMisfitConfig InnerMisfitConfig
InnerSatelliteMisfitConfig
DatasetConfig DatasetConfig
TargetConfig TargetConfig
SamplerDistributionChoice SamplerDistributionChoice
......
...@@ -33,10 +33,9 @@ class RectangularProblem(core.Problem): ...@@ -33,10 +33,9 @@ class RectangularProblem(core.Problem):
dependants = [] dependants = []
targets = List.T(gf.Target.T()) targets = List.T(gf.Target.T())
ranges = Dict.T(String.T(), gf.Range.T()) ranges = Dict.T(String.T(), gf.Range.T())
distance_min = Float.T(default=0.0)
nbootstrap = Int.T(default=10) nbootstrap = 0
def pack(self, source): def pack(self, source):
return self.parameter_array(source) return self.parameter_array(source)
...@@ -219,22 +218,17 @@ class RectangularProblem(core.Problem): ...@@ -219,22 +218,17 @@ class RectangularProblem(core.Problem):
class RectangularProblemConfig(core.ProblemConfig): class RectangularProblemConfig(core.ProblemConfig):
ranges = Dict.T(String.T(), gf.Range.T()) ranges = Dict.T(String.T(), gf.Range.T())
name = String.T()
distance_min = Float.T(default=0.0)
nbootstrap = Int.T(default=0)
apply_balancing_weights = False apply_balancing_weights = False
def get_problem(self, rect_source, targets): def get_problem(self, rect_source, targets):
base_source = gf.RecangularSource.load(rect_source) base_source = gf.RecangularSource.load(rect_source)
problem = RectangularProblem( problem = RectangularProblem(
name=core.expand_template(self.name_template, self.name), name=core.expand_template(self.name_template),
apply_balancing_weights=self.apply_balancing_weights, apply_balancing_weights=self.apply_balancing_weights,
base_source=base_source, base_source=base_source,
targets=targets, targets=targets,
ranges=self.ranges, ranges=self.ranges,
distance_min=self.distance_min,
nbootstrap=self.nbootstrap,
mt_type=self.mt_type) mt_type=self.mt_type)
return problem 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