@ -15,7 +15,7 @@ def detections_to_event_markers(fn_detections):
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 ( y peak) , float ( x peak) )
float ( latpeak ) , float ( lonpeak ) , float ( x peak) , float ( y peak) )
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. ,
@ -74,9 +74,9 @@ class LassieSnuffling(Snuffling):
detector_default = 100.
self . set_name ( ' Lassie investigate ' )
self . add_parameter ( Param ( ' Tsearch ' , ' tsearch ' , 1 ., 0.01 , 100 ) )
self . add_parameter ( Param ( ' Tsearch ' , ' tsearch ' , 20 ., 0.01 , 100 ) )
self . add_parameter ( Param (
' Detector threshold ' , ' detector_threshold ' , detector_default , 100 . ,
' Detector threshold ' , ' detector_threshold ' , detector_default , 1. ,
10000. ) )
self . add_parameter ( Switch ( ' Level Trace ' , ' level_trace ' , False ) )
self . add_parameter ( Switch (
@ -93,6 +93,7 @@ class LassieSnuffling(Snuffling):
self . markers_compare = [ ]
self . fig = None
self . fframe = None
self . grid = self . config . get_grid ( )
def mycleanup ( self ) :
viewer = self . get_viewer ( )
@ -104,14 +105,22 @@ class LassieSnuffling(Snuffling):
def call ( self ) :
self . mycleanup ( )
self . detections = [ ]
i_detection = 0
zpeak = 0.
lat = 0.
lon = 0.
for traces in self . chopper_selected_traces (
mode = ' all ' ,
trace_selector = lambda x : x . station == " SMAX " ,
fallback = True ) :
for tr_stackmax in traces :
tr_smax = filter ( lambda x : x . location == ' ' , traces )
tr_i = filter ( lambda x : x . location == ' i ' , traces )
if not tr_i :
tr_i = [ None ] * len ( tr_smax )
for tr_i , tr_stackmax in zip ( tr_i , tr_smax ) :
tpeaks , apeaks = tr_stackmax . peaks (
self . detector_threshold , self . tsearch )
if self . level_trace :
ltrace = tr_stackmax . copy ( data = False )
ltrace . set_ydata (
@ -119,11 +128,17 @@ class LassieSnuffling(Snuffling):
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 ) )
if tr_i :
lat , lon , xpeak , ypeak , zpeak = self . grid . index_to_location (
tr_i ( t ) [ 1 ] )
lat , lon = orthodrome . ne_to_latlon ( lat , lon , xpeak , ypeak )
e = model . Event (
time = t , name = " %s - %s " % ( i_detection , a ) , lat = lat ,
lon = lon , depth = zpeak )
self . detections . append (
gui_util . EventMarker (
event = e , kind = int ( self . marker_kind [ 0 ] ) ) )
i_detection + = 1
self . add_markers ( self . detections )
if self . hold_figure :
@ -236,6 +251,8 @@ def snuffle(config):
s . config = _lassie_config
s . setup ( )
win . pile_viewer . viewer . add_snuffling ( s , reloaded = True )
win . pile_viewer . viewer . add_blacklist_pattern ( ' *.SMAX.i.* ' )
s . detections = detections_to_event_markers (
_lassie_config . detections_path )
s . add_markers ( s . detections )