Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Sebastian Heimann
grond
Commits
05c6fd34
Commit
05c6fd34
authored
Feb 25, 2017
by
Marius Isken
Browse files
Adapting SatelliteTarget // Cleaning refactor
parent
d0337554
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/__init__.py
View file @
05c6fd34
...
...
@@ -2,3 +2,4 @@ from .core import * # noqa
from
.dataset
import
*
# noqa
from
.problems
import
*
# noqa
from
.targets
import
*
# noqa
from
.meta
import
*
# noqa
src/problems.py
View file @
05c6fd34
...
...
@@ -9,7 +9,7 @@ from pyrocko import gf, util, guts, moment_tensor as mtm
from
pyrocko.guts
import
(
Object
,
String
,
Bool
,
List
,
Float
,
Dict
,
Int
,
StringChoice
)
from
.targets
import
Misfit
Target
from
.targets
import
Grond
Target
guts_prefix
=
'grond'
...
...
@@ -87,10 +87,13 @@ class ProblemConfig(Object):
class
Problem
(
Object
):
name
=
String
.
T
()
parameters
=
List
.
T
(
Parameter
.
T
())
ranges
=
Dict
.
T
(
String
.
T
(),
gf
.
Range
.
T
())
dependants
=
List
.
T
(
Parameter
.
T
())
apply_balancing_weights
=
Bool
.
T
(
default
=
True
)
base_source
=
gf
.
Source
.
T
()
targets
=
List
.
T
()
def
__init__
(
self
,
**
kwargs
):
Object
.
__init__
(
self
,
**
kwargs
)
self
.
_bootstrap_weights
=
None
...
...
@@ -303,9 +306,6 @@ class CMTProblem(Problem):
Parameter
(
'rel_moment_iso'
,
label
=
'$M_{0}^{ISO}/M_{0}$'
),
Parameter
(
'rel_moment_clvd'
,
label
=
'$M_{0}^{CLVD}/M_{0}$'
)]
targets
=
List
.
T
(
MisfitTarget
.
T
())
ranges
=
Dict
.
T
(
String
.
T
(),
gf
.
Range
.
T
())
distance_min
=
Float
.
T
(
default
=
0.0
)
nbootstrap
=
Int
.
T
(
default
=
10
)
mt_type
=
StringChoice
.
T
(
default
=
'full'
,
choices
=
[
'full'
,
'deviatoric'
])
...
...
@@ -538,11 +538,8 @@ class DoubleDCProblem(Problem):
Parameter
(
'mix'
,
label
=
'Mix'
),
Parameter
(
'duration1'
,
's'
,
label
=
'Duration 1'
),
Parameter
(
'duration2'
,
's'
,
label
=
'Duration 2'
)]
dependants
=
[]
targets
=
List
.
T
(
MisfitTarget
.
T
())
ranges
=
Dict
.
T
(
String
.
T
(),
gf
.
Range
.
T
())
dependants
=
[]
distance_min
=
Float
.
T
(
default
=
0.0
)
nbootstrap
=
Int
.
T
(
default
=
100
)
...
...
@@ -616,7 +613,6 @@ class DoubleDCProblem(Problem):
def
dependant_bounds
(
self
):
out
=
[]
return
out
def
evaluate
(
self
,
x
,
result_mode
=
'sparse'
):
...
...
@@ -711,9 +707,6 @@ class RectangularProblem(Problem):
dependants
=
[]
targets
=
List
.
T
(
gf
.
Target
.
T
())
ranges
=
Dict
.
T
(
String
.
T
(),
gf
.
Range
.
T
())
nbootstrap
=
0
def
pack
(
self
,
source
):
...
...
@@ -814,41 +807,11 @@ class RectangularProblem(Problem):
return
results
def
bootstrap_misfits
(
self
,
misfits
,
ibootstrap
):
w
=
self
.
get_bootstrap_weights
(
ibootstrap
)[
num
.
newaxis
,
:]
*
\
self
.
get_target_weights
()[
num
.
newaxis
,
:]
*
\
self
.
inter_group_weights2
(
misfits
[:,
:,
1
])
bms
=
num
.
sqrt
(
num
.
nansum
((
w
*
misfits
[:,
:,
0
])
**
2
,
axis
=
1
)
/
num
.
nansum
((
w
*
misfits
[:,
:,
1
])
**
2
,
axis
=
1
))
return
bms
def
global_misfit
(
self
,
ms
,
ns
):
ws
=
self
.
get_target_weights
()
*
self
.
inter_group_weights
(
ns
)
m
=
num
.
sqrt
(
num
.
nansum
((
ws
*
ms
)
**
2
)
/
num
.
nansum
((
ws
*
ns
)
**
2
))
return
m
def
global_misfits
(
self
,
misfits
):
ws
=
self
.
get_target_weights
()[
num
.
newaxis
,
:]
*
\
self
.
inter_group_weights2
(
misfits
[:,
:,
1
])
gms
=
num
.
sqrt
(
num
.
nansum
((
ws
*
misfits
[:,
:,
0
])
**
2
,
axis
=
1
)
/
num
.
nansum
((
ws
*
misfits
[:,
:,
1
])
**
2
,
axis
=
1
))
return
gms
def
global_contributions
(
self
,
misfits
):
ws
=
self
.
get_target_weights
()[
num
.
newaxis
,
:]
*
\
self
.
inter_group_weights2
(
misfits
[:,
:,
1
])
gcms
=
(
ws
*
misfits
[:,
:,
0
])
**
2
/
\
num
.
nansum
((
ws
*
misfits
[:,
:,
1
])
**
2
,
axis
=
1
)[:,
num
.
newaxis
]
return
gcms
class
RectangularProblemConfig
(
ProblemConfig
):
ranges
=
Dict
.
T
(
String
.
T
(),
gf
.
Range
.
T
())
apply_balancing_weights
=
False
apply_balancing_weights
=
Bool
.
T
(
default
=
False
)
def
get_problem
(
self
,
event
,
targets
):
base_source
=
gf
.
RectangularSource
(
...
...
src/targets.py
View file @
05c6fd34
...
...
@@ -463,7 +463,7 @@ def _process(tr, tmin, tmax, taper, domain):
class
InnerSatelliteMisfitConfig
(
Object
):
use_weight_focal
=
Bool
.
T
(
default
=
Tru
e
)
use_weight_focal
=
Bool
.
T
(
default
=
Fals
e
)
class
MisfitSatelliteTarget
(
gf
.
SatelliteTarget
):
...
...
@@ -506,6 +506,11 @@ class MisfitSatelliteTarget(gf.SatelliteTarget):
return
1.
class
GrondTarget
(
MisfitSatelliteTarget
,
MisfitTarget
):
def
__init__
(
self
,
args
):
super
(
MisfitSatelliteTarget
,
self
).
__init__
()
class
TargetConfig
(
Object
):
super_group
=
gf
.
StringID
.
T
(
default
=
''
,
optional
=
True
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment