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
46276a26
Commit
46276a26
authored
Feb 20, 2017
by
Sebastian Heimann
Browse files
implemented autoshift feature
parent
41a74614
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/core.py
View file @
46276a26
...
@@ -265,12 +265,37 @@ class InnerMisfitConfig(Object):
...
@@ -265,12 +265,37 @@ class InnerMisfitConfig(Object):
fmin
=
Float
.
T
()
fmin
=
Float
.
T
()
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
(
tmax
=
gf
.
Timing
.
T
()
help
=
'Start of main time window used for waveform fitting.'
)
tfade
=
Float
.
T
(
optional
=
True
)
tmax
=
gf
.
Timing
.
T
(
pick_synthetic_traveltime
=
gf
.
Timing
.
T
(
optional
=
True
)
help
=
'End of main time window used for waveform fitting.'
)
pick_phasename
=
String
.
T
(
optional
=
True
)
tfade
=
Float
.
T
(
domain
=
DomainChoice
.
T
(
default
=
'time_domain'
)
optional
=
True
,
help
=
'Decay time of taper prepended and appended to main time window '
'used for waveform fitting [s].'
)
pick_synthetic_traveltime
=
gf
.
Timing
.
T
(
optional
=
True
,
help
=
'Synthetic phase arrival definition for alignment of observed '
'and synthetic traces.'
)
pick_phasename
=
String
.
T
(
optional
=
True
,
help
=
'Name of picked phase for alignment of observed and synthetic '
'traces.'
)
domain
=
DomainChoice
.
T
(
default
=
'time_domain'
,
help
=
'Type of data characteristic to be fitted.
\n\n
Available choices '
'are: %s'
%
', '
.
join
(
"``'%s'``"
%
s
for
s
in
DomainChoice
.
choices
))
tautoshift_max
=
Float
.
T
(
default
=
0.0
,
help
=
'If non-zero, allow synthetic and observed traces to be shifted '
'against each other by up to +/- the given value [s].'
)
autoshift_penalty_max
=
Float
.
T
(
default
=
0.0
,
help
=
'If non-zero, a penalty misfit is added for non-zero shift '
'values.
\n\n
The penalty value is computed as '
'``autoshift_penalty_max * normalization_factor * tautoshift**2 '
'/ tautoshift_max**2``'
)
def
get_full_frequency_range
(
self
):
def
get_full_frequency_range
(
self
):
return
self
.
fmin
/
self
.
ffactor
,
self
.
fmax
*
self
.
ffactor
return
self
.
fmin
/
self
.
ffactor
,
self
.
fmax
*
self
.
ffactor
...
@@ -466,7 +491,9 @@ class MisfitTarget(gf.Target):
...
@@ -466,7 +491,9 @@ class MisfitTarget(gf.Target):
domain
=
config
.
domain
,
domain
=
config
.
domain
,
exponent
=
2
,
exponent
=
2
,
flip
=
self
.
flip_norm
,
flip
=
self
.
flip_norm
,
result_mode
=
self
.
_result_mode
)
result_mode
=
self
.
_result_mode
,
tautoshift_max
=
config
.
tautoshift_max
,
autoshift_penalty_max
=
config
.
autoshift_penalty_max
)
mr
.
tobs_shift
=
float
(
tobs_shift
)
mr
.
tobs_shift
=
float
(
tobs_shift
)
mr
.
tsyn_pick
=
float_or_none
(
tsyn
)
mr
.
tsyn_pick
=
float_or_none
(
tsyn
)
...
@@ -479,7 +506,8 @@ class MisfitTarget(gf.Target):
...
@@ -479,7 +506,8 @@ class MisfitTarget(gf.Target):
def
misfit
(
def
misfit
(
tr_obs
,
tr_syn
,
taper
,
domain
,
exponent
,
flip
,
result_mode
=
'sparse'
):
tr_obs
,
tr_syn
,
taper
,
domain
,
exponent
,
tautoshift_max
,
autoshift_penalty_max
,
flip
,
result_mode
=
'sparse'
):
'''
'''
Calculate misfit between observed and synthetic trace.
Calculate misfit between observed and synthetic trace.
...
@@ -490,6 +518,12 @@ def misfit(
...
@@ -490,6 +518,12 @@ def misfit(
:py:class:`pyrocko.trace.Taper`
:py:class:`pyrocko.trace.Taper`
:param domain: how to calculate difference, see :py:class:`DomainChoice`
:param domain: how to calculate difference, see :py:class:`DomainChoice`
:param exponent: exponent of Lx type norms
:param exponent: exponent of Lx type norms
:param tautoshift_max: if non-zero, return lowest misfit when traces are
allowed to shift against each other by up to +/- ``tautoshift_max``
:param autoshift_penalty_max: if non-zero, a penalty misfit is added for
for non-zero shift values. The penalty value is
``autoshift_penalty_max * normalization_factor *
\
tautoshift**2 / tautoshift_max**2``
:param flip: ``bool``, if set to ``True``, normalization factor is
:param flip: ``bool``, if set to ``True``, normalization factor is
computed against *tr_syn* rather than *tr_obs*
computed against *tr_syn* rather than *tr_obs*
:param result_mode: ``'full'``, include traces and spectra or ``'sparse'``,
:param result_mode: ``'full'``, include traces and spectra or ``'sparse'``,
...
@@ -506,12 +540,39 @@ def misfit(
...
@@ -506,12 +540,39 @@ def misfit(
cc_shift
=
None
cc_shift
=
None
ctr
=
None
ctr
=
None
deltat
=
tr_proc_obs
.
deltat
if
domain
in
(
'time_domain'
,
'envelope'
,
'absolute'
):
if
domain
in
(
'time_domain'
,
'envelope'
,
'absolute'
):
a
,
b
=
tr_proc_syn
.
ydata
,
tr_proc_obs
.
ydata
a
,
b
=
tr_proc_syn
.
ydata
,
tr_proc_obs
.
ydata
if
flip
:
if
flip
:
b
,
a
=
a
,
b
b
,
a
=
a
,
b
m
,
n
=
trace
.
Lx_norm
(
a
,
b
,
norm
=
exponent
)
nshift_max
=
max
(
0
,
min
(
a
.
size
-
1
,
int
(
math
.
floor
(
tautoshift_max
/
deltat
))))
if
nshift_max
==
0
:
m
,
n
=
trace
.
Lx_norm
(
a
,
b
,
norm
=
exponent
)
else
:
mns
=
[]
for
ishift
in
xrange
(
-
nshift_max
,
nshift_max
+
1
):
if
ishift
<
0
:
a_cut
=
a
[
-
ishift
:]
b_cut
=
b
[:
ishift
]
elif
ishift
==
0
:
a_cut
=
a
b_cut
=
b
elif
ishift
>
0
:
a_cut
=
a
[:
-
ishift
]
b_cut
=
b
[
ishift
:]
mns
.
append
(
trace
.
Lx_norm
(
a_cut
,
b_cut
,
norm
=
exponent
))
ms
,
ns
=
num
.
array
(
mns
).
T
iarg
=
num
.
argmin
(
ms
)
tshift
=
(
iarg
-
nshift_max
)
*
deltat
m
,
n
=
ms
[
iarg
],
ns
[
iarg
]
m
+=
autoshift_penalty_max
*
n
*
tshift
**
2
/
tautoshift_max
**
2
elif
domain
==
'cc_max_norm'
:
elif
domain
==
'cc_max_norm'
:
...
...
Write
Preview
Markdown
is supported
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