Browse Source

Merge branch 'snuffle_continued' into 'master'

Snuffle continued

Save indices of maxima of frames in addition to smax. Load that trace to retrieve the index of the underlying maxima when running detector from snuffling. Assign corresponding lat and lon to detections' events.
Makes the detection independent from stacking.

See merge request !6
plot3d
Marius Kriegerowski 6 years ago
parent
commit
ac9b0f4d6f
  1. 13
      src/core.py
  2. 33
      src/snuffling.py

13
src/core.py

@ -136,7 +136,7 @@ def scan(
nsls_selected, trs_selected = zip(*dataset)
trs_debug.extend(trs + list(trs_selected))
#trs_debug.extend(trs + list(trs_selected))
deltat_cf = trs_selected[0].deltat
@ -200,7 +200,7 @@ def scan(
deltat=deltat_cf,
ydata=frame_maxs)
trs_debug.append(tr_stackmax)
#trs_debug.append(tr_stackmax)
# trace.snuffle(trs_debug)
@ -214,6 +214,11 @@ def scan(
tpeaks, apeaks = tr_stackmax.peaks(
config.detector_threshold, shift_max + 1.0/fsmooth_min)
tr_stackmax_indx = tr_stackmax.copy(data=False)
imaxs = num.argmax(frames, axis=0)
tr_stackmax_indx.set_ydata(imaxs.astype(num.int32))
tr_stackmax_indx.set_location('i')
for (tpeak, apeak) in zip(tpeaks, apeaks):
if not (wmin <= tpeak and tpeak < wmax):
continue
@ -253,9 +258,9 @@ def scan(
if stop_after_first:
return
tr_stackmax.chop(wmin, wmax)
io.save([tr_stackmax], 'stackmax/trace_%(tmin_ms)s.mseed')
io.save([tr_stackmax, tr_stackmax_indx], 'stackmax/trace_%(tmin_ms)s.mseed')
__all__ = [

33
src/snuffling.py

@ -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(ypeak), float(xpeak))
float(latpeak), float(lonpeak), float(xpeak), float(ypeak))
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)

Loading…
Cancel
Save