[bugfix] various bugfixes originating from changes (more picks) in dictionary (refs #233 refs #234)

This commit is contained in:
Marcel Paffrath 2018-07-25 14:05:15 +02:00
parent bfc745dd30
commit bf5c371459
5 changed files with 30 additions and 12 deletions

View File

@ -7,6 +7,7 @@ import argparse
import datetime
import glob
import os
import traceback
import pylot.core.loc.focmec as focmec
import pylot.core.loc.hash as hash
@ -283,7 +284,11 @@ def autoPyLoT(input_dict=None, parameter=None, inputfile=None, fnames=None, even
corr_dat = None
if metadata:
# rotate stations to ZNE
wfdat = check4rotated(wfdat, metadata)
try:
wfdat = check4rotated(wfdat, metadata)
except Exception as e:
print('Could not rotate station {} to ZNE:\n{}'.format(wfdat[0].stats.station,
traceback.format_exc()))
if locflag:
print("Restitute data ...")
corr_dat = restitute_data(wfdat.copy(), metadata, ncores=ncores)

View File

@ -137,8 +137,8 @@ def call_autopickstation(input_tuple):
return autopickstation(wfstream, pickparam, verbose, fig_dict=fig_dict, iplot=iplot, metadata=metadata,
origin=origin)
except Exception as e:
traceback.print_exc()
return traceback.format_exc(), wfstream[0].stats.station
tbe = traceback.format_exc()
return tbe, wfstream[0].stats.station
def autopickstation(wfstream, pickparam, verbose=False,
@ -254,19 +254,22 @@ def autopickstation(wfstream, pickparam, verbose=False,
# split components
zdat = wfstream.select(component="Z")
if len(zdat) == 0: # check for other components
print('HIT: 3')
zdat = wfstream.select(component="3")
edat = wfstream.select(component="E")
if len(edat) == 0: # check for other components
edat = wfstream.select(component="2")
print('HIT: 2')
ndat = wfstream.select(component="N")
if len(ndat) == 0: # check for other components
ndat = wfstream.select(component="1")
print('HIT: 1')
picks = {}
station = zdat[0].stats.station
station = wfstream[0].stats.station
if not zdat:
print('No z-component found for station {}. STOP'.format(wfstream[0].stats.station))
print('No z-component found for station {}. STOP'.format(station))
return picks, station
if algoP == 'HOS' or algoP == 'ARZ' and zdat is not None:

View File

@ -279,7 +279,7 @@ class AICPicker(AutoPicker):
try:
imaxs, = argrelmax(dataslope)
imax = imaxs[0]
except ValueError as e:
except (ValueError, IndexError) as e:
print(e, 'picker: argrelmax not working!')
imax = np.argmax(dataslope)
iislope = islope[0][0:imax + 1]

View File

@ -606,14 +606,18 @@ def wadaticheck(pickdic, dttolerance, iplot=0, fig_dict=None):
ibad = 0
for key in list(pickdic.keys()):
if pickdic[key]['P']['weight'] < 4 and pickdic[key]['S']['weight'] < 4:
ppick = pickdic[key].get('P')
spick = pickdic[key].get('S')
if not ppick or not spick:
continue
if ppick['weight'] < 4 and spick['weight'] < 4:
# calculate S-P time
spt = pickdic[key]['S']['mpp'] - pickdic[key]['P']['mpp']
spt = spick['mpp'] - ppick['mpp']
# add S-P time to dictionary
pickdic[key]['SPt'] = spt
# add P onsets and corresponding S-P times to list
UTCPpick = UTCDateTime(pickdic[key]['P']['mpp'])
UTCSpick = UTCDateTime(pickdic[key]['S']['mpp'])
UTCPpick = UTCDateTime(ppick['mpp'])
UTCSpick = UTCDateTime(spick['mpp'])
Ppicks.append(UTCPpick.timestamp)
Spicks.append(UTCSpick.timestamp)
SPtimes.append(spt)
@ -870,9 +874,12 @@ def checkPonsets(pickdic, dttolerance, jackfactor=5, iplot=0, fig_dict=None):
Ppicks = []
stations = []
for station in pickdic:
if pickdic[station]['P']['weight'] < 4:
pick = pickdic[station].get('P')
if not pick:
continue
if pick['weight'] < 4:
# add P onsets to list
UTCPpick = UTCDateTime(pickdic[station]['P']['mpp'])
UTCPpick = UTCDateTime(pick['mpp'])
Ppicks.append(UTCPpick.timestamp)
stations.append(station)

View File

@ -975,6 +975,9 @@ def check4rotated(data, metadata=None, verbosity=1):
except (KeyError, TypeError) as e:
print('Failed to rotate trace {}, no azimuth or dip available in metadata'.format(trace_id))
return wfstream
if len(wfstream) < 3:
print('Failed to rotate Stream {}, not enough components available.'.format(wfstream))
return wfstream
# to rotate all traces must have same length, so trim them
wfstream = trim_station_components(wfstream, trim_start=True, trim_end=True)
z, n, e = rotate2zne(wfstream[0], azimuts[0], dips[0],