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
2ffed940
Commit
2ffed940
authored
Oct 18, 2016
by
Sebastian Heimann
Browse files
grond check: allow selection of individual targets
parent
60ba210d
Changes
4
Hide whitespace changes
Inline
Side-by-side
apps/grond
View file @
2ffed940
...
...
@@ -175,7 +175,11 @@ def command_init(args):
def
command_check
(
args
):
def
setup
(
parser
):
pass
parser
.
add_option
(
'--target-ids'
,
dest
=
'target_string_ids'
,
metavar
=
'TARGET_IDS'
,
help
=
'process only selected targets. TARGET_IDS is a '
'comma-separated list of target IDs. Target IDs have the '
'form SUPERGROUP.GROUP.NETWORK.STATION.LOCATION.CHANNEL.'
)
parser
,
options
,
args
=
cl_parse
(
'check'
,
args
,
setup
)
if
len
(
args
)
<
2
:
...
...
@@ -186,9 +190,14 @@ def command_check(args):
config
=
grond
.
read_config
(
config_path
)
target_string_ids
=
None
if
options
.
target_string_ids
:
target_string_ids
=
options
.
target_string_ids
.
split
(
','
)
grond
.
check
(
config
,
event_names
=
event_names
)
event_names
=
event_names
,
target_string_ids
=
target_string_ids
)
def
command_go
(
args
):
...
...
src/cmt.py
View file @
2ffed940
...
...
@@ -175,13 +175,12 @@ class CMTProblem(core.Problem):
data
=
[]
results
=
[]
for
target
,
result
in
zip
(
self
.
targets
,
resp
.
results_list
[
0
]):
if
isinstance
(
result
,
gf
.
SeismosizerError
):
logger
.
debug
(
'%s.%s.%s.%s: %s'
%
(
target
.
codes
+
(
str
(
result
),)))
data
.
append
((
None
,
None
))
results
.
append
(
None
)
results
.
append
(
result
)
else
:
data
.
append
((
result
.
misfit_value
,
result
.
misfit_norm
))
results
.
append
(
result
)
...
...
src/core.py
View file @
2ffed940
...
...
@@ -1481,7 +1481,7 @@ def forward(rundir_or_config_path, event_names=None):
events
.
append
(
event
)
for
result
in
results
:
if
result
:
if
not
isinstance
(
result
,
gf
.
SeismosizerError
)
:
result
.
filtered_obs
.
set_codes
(
location
=
'ob'
)
result
.
filtered_syn
.
set_codes
(
location
=
'sy'
)
all_trs
.
append
(
result
.
filtered_obs
)
...
...
@@ -1553,11 +1553,10 @@ def check_problem(problem):
if
len
(
problem
.
targets
)
==
0
:
raise
GrondError
(
'no targets available'
)
g_state
=
{}
def
check
(
config
,
event_names
=
None
):
def
check
(
config
,
event_names
=
None
,
target_string_ids
=
None
):
from
matplotlib
import
pyplot
as
plt
from
grond.plot
import
colors
...
...
@@ -1566,6 +1565,12 @@ def check(config, event_names=None):
event
=
ds
.
get_event
()
try
:
problem
=
config
.
get_problem
(
event
)
if
target_string_ids
:
problem
.
targets
=
[
target
for
target
in
problem
.
targets
if
target
.
string_id
()
in
target_string_ids
]
check_problem
(
problem
)
xbounds
=
num
.
array
(
problem
.
bounds
(),
dtype
=
num
.
float
)
...
...
@@ -1580,7 +1585,7 @@ def check(config, event_names=None):
yabsmaxs
=
[]
for
results
in
results_list
:
result
=
results
[
itarget
]
if
result
:
if
not
isinstance
(
result
,
gf
.
SeismosizerError
)
:
yabsmaxs
.
append
(
num
.
max
(
num
.
abs
(
result
.
filtered_obs
.
get_ydata
())))
...
...
@@ -1593,7 +1598,7 @@ def check(config, event_names=None):
ii
=
0
for
results
in
results_list
:
result
=
results
[
itarget
]
if
result
:
if
not
isinstance
(
result
,
gf
.
SeismosizerError
)
:
if
fig
is
None
:
fig
=
plt
.
figure
()
axes
=
fig
.
add_subplot
(
1
,
1
,
1
)
...
...
@@ -1632,6 +1637,8 @@ def check(config, event_names=None):
t2
=
num
.
concatenate
((
t
,
t
[::
-
1
]))
axes
.
plot
(
t2
,
y2
*
0.5
+
0.5
,
color
=
'gray'
)
ii
+=
1
else
:
logger
.
info
(
str
(
result
))
if
fig
:
plt
.
show
()
...
...
src/plot.py
View file @
2ffed940
...
...
@@ -6,7 +6,7 @@ import os
import
os.path
as
op
import
numpy
as
num
from
scipy
import
signal
from
pyrocko
import
beachball
,
guts
,
trace
,
util
from
pyrocko
import
beachball
,
guts
,
trace
,
util
,
gf
from
pyrocko
import
hudson
from
grond
import
core
from
matplotlib
import
pyplot
as
plt
...
...
@@ -906,7 +906,7 @@ def draw_fits_figures(ds, model, plt):
dtraces
=
[]
for
target
,
result
in
zip
(
problem
.
targets
,
results
):
if
result
is
None
:
if
isinstance
(
result
,
gf
.
SeismosizerError
)
:
dtraces
.
append
(
None
)
continue
...
...
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