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
Peter Niemz
lassie
Commits
9f0488ee
Commit
9f0488ee
authored
Oct 28, 2016
by
Marius Kriegerowski
Browse files
lassie detection snuffling
parent
714af060
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/__init__.py
View file @
9f0488ee
...
...
@@ -6,3 +6,4 @@ from lassie.ifc import * # noqa
from
lassie.core
import
*
# noqa
from
lassie.plot
import
*
# noqa
from
lassie.config
import
*
# noqa
from
lassie.snuffling
import
*
# noqa
src/snuffling.py
0 → 100644
View file @
9f0488ee
import
copy
import
numpy
as
num
from
pyrocko
import
util
,
gui_util
,
model
,
orthodrome
,
pile
,
snuffler
from
pyrocko.snuffling
import
Snuffling
,
Param
,
Choice
,
Switch
class
LassieSnuffling
(
Snuffling
):
'''
Scrutinize Lassie Detections and Re-Detect
'''
def
__init__
(
self
):
Snuffling
.
__init__
(
self
)
self
.
config
=
None
def
setup
(
self
):
if
self
.
config
:
detector_default
=
self
.
config
.
detector_threshold
else
:
detector_default
=
100.
self
.
set_name
(
'Lassie investigate'
)
self
.
add_parameter
(
Param
(
'tsearch'
,
'tsearch'
,
1.
,
0.01
,
100
))
self
.
add_parameter
(
Param
(
'threshold'
,
'detector_threshold'
,
detector_default
,
100.
,
10000.
))
self
.
add_parameter
(
Switch
(
'Level Trace'
,
'level_trace'
,
False
))
self
.
add_parameter
(
Choice
(
'new marker kind'
,
'marker_kind'
,
'1 (green)'
,
[
'1 (green)'
,
'2 (blue)'
,
'3 (orange)'
,
'4 (purple)'
,
'5 (brown)'
,
'0 (red)'
]))
self
.
set_live_update
(
False
)
def
call
(
self
):
self
.
cleanup
()
self
.
detections
=
[]
for
traces
in
self
.
chopper_selected_traces
(
trace_selector
=
lambda
x
:
x
.
station
==
"SMAX"
,
fallback
=
True
):
for
tr_stackmax
in
traces
:
tpeaks
,
apeaks
=
tr_stackmax
.
peaks
(
self
.
detector_threshold
,
self
.
tsearch
)
if
self
.
level_trace
:
ltrace
=
tr_stackmax
.
copy
(
data
=
False
)
ltrace
.
set_ydata
(
num
.
ones
(
tr_stackmax
.
data_len
())
*
self
.
detector_threshold
)
self
.
add_trace
(
ltrace
)
for
t
,
a
in
zip
(
tpeaks
,
apeaks
):
e
=
model
.
Event
(
time
=
t
,
name
=
str
(
a
))
self
.
detections
.
append
(
gui_util
.
EventMarker
(
event
=
e
,
kind
=
int
(
self
.
marker_kind
[
0
])))
self
.
add_markers
(
self
.
detections
)
def
__snufflings__
():
return
[
LassieSnuffling
()]
def
snuffle
(
config
):
global
_lassie_config
_lassie_config
=
copy
.
deepcopy
(
config
)
def
load_snuffling
(
win
):
s
=
LassieSnuffling
()
s
.
config
=
_lassie_config
s
.
setup
()
win
.
pile_viewer
.
viewer
.
add_snuffling
(
s
)
receivers
=
config
.
get_receivers
()
stations
=
set
()
for
r
in
receivers
:
n
,
s
,
l
=
r
.
codes
[:
3
]
stations
.
add
(
model
.
Station
(
lat
=
r
.
lat
,
lon
=
r
.
lon
,
network
=
n
,
station
=
s
,
location
=
l
))
markers
=
[]
with
open
(
config
.
detections_path
,
'r'
)
as
f
:
for
line
in
f
.
readlines
():
data
=
line
.
split
()
i
,
t_d
,
t_t
,
apeak
,
latpeak
,
lonpeak
,
xpeak
,
ypeak
,
zpeak
=
data
lat
,
lon
=
orthodrome
.
ne_to_latlon
(
float
(
latpeak
),
float
(
lonpeak
),
float
(
ypeak
),
float
(
xpeak
))
t
=
util
.
str_to_time
(
"%s %s"
%
(
t_d
,
t_t
))
label
=
"%s-%s"
%
(
i
,
apeak
)
e
=
model
.
Event
(
lat
=
lat
,
lon
=
lon
,
depth
=
float
(
zpeak
)
*
1000.
,
name
=
label
,
time
=
t
)
m
=
gui_util
.
EventMarker
(
e
)
markers
.
append
(
m
)
paths
=
config
.
data_paths
paths
.
append
(
'stackmax'
)
p
=
pile
.
make_pile
(
paths
=
paths
,
fileformat
=
'detect'
)
snuffler
.
snuffle
(
p
,
markers
=
markers
,
stations
=
stations
,
launch_hook
=
load_snuffling
)
__all__
=
[
'snuffle'
]
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